Temporarily disable code analysis for single code file with Resharper 3.0.2 and VS 2008

If you hit a code file that’s using one of the new funky features of C# 3.0, and Resharper code analysis doesn’t recognize it, like property initializers, var, etc, just press the following to disable code analysis for the current code file only:

CTRL+8

Code analysis will turn off, and the red will go away.  Resharper will remember this preference for that code file until you close and reopen Visual Studio.

If you want to turn code analysis back on, just press CTRL+8 again.  You can turn it on and off as much as you like.  I’m finding this especially useful when giving presentations such as the ones at DevTeach.  I want to keep Resharper enabled in order to use all the features, but for some of the code files, I need code analysis turned off.  CTRL+8 allows me to keep the global option on and just turn it off for a single code file.  I love little hidden gems!!

This entry was posted in Uncategorized. Bookmark the permalink. Follow any comments here with the RSS feed for this post.

4 Responses to Temporarily disable code analysis for single code file with Resharper 3.0.2 and VS 2008

  1. @Andrew,
    Glad to help.

  2. Thanks man! You’re a life saver. I can’t wait for the next version of ReSharper so that it works properly with all the new C# widgetry!!!

  3. Joe Ocampo says:

    You made my day! Thanks!

  4. Dave White says:

    This is a great little tidbit of information when you open or step into a really large autogenerated file that normally has lots and lots of things that Resharper doesn’t like.

    I’ve asked the Resharper guys if we could get a feature where you could create a “Do Not Analyze” list of files so that Resharper remembers our preferences across sessions.

    Cheers,
    Dave

Leave a Reply