Introducing ReSharper 5.0: Solution-Wide Warnings and Suggestions

Previous posts introducing ReSharper 5.0:

Over the years, ReSharper has gradually advanced from plainly highlighting errors and problems in individual code files to somehow summing up errors and problems in a larger scope, up to the entire solution.

Back in 2007, ReSharper 3.1 was the first product version to introduce Solution-Wide Error Analysis to gather data on all errors in the solution using a single tool window. ReSharper 4.5 split many code inspections to execute in private and public scope, with the latter only available when you turned on Solution-Wide Error Analysis.

Taking another huge step towards instantly seeing every problem anywhere in your solution, ReSharper 5 introduces a new code analysis feature called Solution-Wide Warnings and Suggestions. As you’ve probably guessed, it lists all warnings and suggestions that ReSharper displays in the scope of your whole solution or in a narrower scope, depending on how you call it. In other words, any code smells or other problems that you may have in your solution can now be summarized in a single tool window, making tool-based code review much easier.

When you switch on Solution-Wide Errors Analysis, Solution-Wide Warnings and Suggestions starts showing errors as well, plus warnings and suggestions that work in non-private scope.

That doesn’t mean Errors in Solution tool window becomes obsolete with R# 5: when your goal is as simple as to make your code compile, Errors in Solution quickly indicates that something in the solution went awfully wrong and you should fix things up before you can compile.

However, as soon as you’re ambitious enough to make your code green – that is, eliminate compiler warnings, implement best practices, or upgrade your code to leverage the latest language opportunities – Solution-Wide Warnings and Suggestions is exactly what you need to get the job done quickly.

The feature includes two items:

  • Inspect Code – a new command that is available by right-clicking any node in Solution Explorer, from a single file to the whole solution:
  • Inspection Results – a tool window that actually shows problems found in a certain scope, broken up into several categories:

The Inspection Results tool window is pretty much similar to other ReSharper tool windows like Type Hierarchy or Find Results: it provides common navigation, grouping and export options. It also has a code preview pane where you can instantly see the context of a problem without opening the corresponding file in the text editor:

The tool window is not updated automatically, so as soon as you’ve made substantial changes, make sure to click the Refresh button to see up-to-date inspection results:

In many scenarios, chances are you don’t want to review all code problems you may have in a scope – you’d rather focus on a particular subset. Inspection Results lets you do this by clicking the glaring Filter button:

This displays the Filter Issues dialog box where you can select or unselect individual inspections or even entire inspection groups. For example, here’s how you can discover code that can be transformed to leverage C# 3.0 and C# 4.0 language features:

When you double-click an item in Inspection Results, the corresponding file opens in the text editor in the right position for you to actually take measures: apply a quick-fix, refactor or clean up code, or whatever:

However, instead of double-clicking through all inspections, in many cases you can apply fixes right from Inspection Results: say, you’re inspecting a single file that has three inspection items:

Of the three inspection items, two can be safely fixed using Code Cleanup, which can both delete a redundant “using” directive and make an explicitly typed variable implicitly typed. Then, you press Ctrl+Alt+F right on one of these two inspection items, and the Code Cleanup dialog box displays:

You launch Code Cleanup with Full Cleanup profile, and ReSharper applies fixes for both inspections straight away! Upon refreshing Inspection Results, you only have one inspection left:

In addition to cleaning up code, you can also apply refactorings and navigation actions right from Inspection Results. I hope to cover scenarios involving this approach in subsequent posts about ReSharper 5.

To try out Solution-Wide Warnings and Inspections in its latest incarnation, make sure to download a fresh ReSharper 5 nightly build!

This entry was posted in How-To's, ReSharper Tips&Tricks and tagged , , . Bookmark the permalink.

19 Responses to Introducing ReSharper 5.0: Solution-Wide Warnings and Suggestions

  1. Joe White says:

    Is there a way to get these inspection results for all of the currently-open editor files? I’d love a way to make sure I didn’t introduce any ReSharper warnings into any of the files I just edited (and am about to check into source control).

  2. @Joe You can move the inspection-level to error (via Alt+ENTER). If it’s so important, you should it handle as errors.

  3. @Joe I guess not, other than to select the files in Solution Explorer by hand (which is next to ridiculous). Please request the feature.

  4. @Albert I don’t see how promoting inspection level to error solves the problem of narrowing the scope of files being inspected to those currently open.

  5. Pingback: JetBrains .NET Tools Blog » Blog Archive » ReSharper 5.0 Preview … Reviews Me

  6. Joe White says:

    @Jura, I already did suggest this a while ago (RSRP-88095). But a JIRA ticket with Fix Version of “Next Major” doesn’t really give me any clue whether it’s in 5.0 or not, so it’s worth asking.

  7. Joe White says:

    @Albert, if our code base was already 100% free of ReSharper warnings, then maybe we could promote them to errors and get some benefit. But that’s not the case. Most of our approximately million-line code base was translated from Delphi (a non-.NET language) to C# via an automated tool. It’s stuffed full of ReSharper warnings. We’re cleaning them up, but we have to prioritize — it’s simply not feasible to fix them all at once.

    Per the 80/20 rule, there are a lot of source files that we hardly ever touch. So by definition, if I had to open a file in the editor, it’s more interesting (in terms of code cleanup) than a file I never opened. That’s why I would see a lot of value in being able to view the code inspections for all of the current editor files. I wouldn’t necessarily know that the file was clean before I started changing it, but if I see just a few warnings, I might commit my change and then spend my next commit on cleaning up a few warnings.

  8. @Joe I’ve voted for it and I’ll try to find out if it can be resolved for 5# or a subsequent minor release.
    However, there might be some issues using the feature as you describe it because 1) “open files” is not equal to “modified files to commit” and 2) fixing inspections in open files may lead to modifying other files that you may or may not want to even touch

  9. Pingback: Twitter Trackbacks for JetBrains .NET Tools Blog » Blog Archive » ReSharper 5.0 Preview: Solution-Wide Warnings and Suggestions [] on

  10. Joe White says:

    @Jura, fair points — I didn’t think about the fixes that would change other files. Still, it seems like “open files” is a good first approximation. Better yet if I can tell which warnings come from which files, and can remove individual files from the inspection if they’re generating too much noise — but I could always just close the file and refresh (or re-run) the inspection.

  11. Fabio Maulo says:

    Would be very useful and option to filter projects to inspects (test projects may not need some inspection)

  12. @Fabio,
    You can select projects to inspect in Solution Explorer one by one, thereby bypassing your test projects.

  13. I installed the current preview on a clean VS 2010 Ultimate RC. Resharper works fine so far, unfortunately the underlining is completely missing. Any ideas what’s the problem?

  14. Pingback: JetBrains .NET Tools Blog » Blog Archive » ReSharper 5 Beta 2 Released

  15. @Stefan Barthel

    What do you mean underlining? Do you mean highlighting of errors, warnings, and suggestions in the text editor? Can you provide a screenshot?

  16. Pingback: JetBrains .NET Tools Blog » Blog Archive » Introducing ReSharper 5.0: Call Tracking

  17. Pingback: JetBrains .NET Tools Blog » Blog Archive » Introducing ReSharper 5.0: Structural Search and Replace

  18. Pingback: JetBrains .NET Tools Blog » Blog Archive » ReSharper 5.0 Is Out!

  19. Pingback: JetBrains .NET Tools Blog » Blog Archive » Introducing ReSharper 5.0: Value Tracking

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>