Solution-Wide Code Inspections
The majority of code inspections only need the source code of a single file to work and detect code issues. In addition to these inspections, ReSharper provides solution-wide inspections, that target code issues only detectable in scope of entire solution:
- They only work when the solution-wide analysis is enabled. .
- Most of them help detect unused non-private members (see the list below for details).
- Similar to any other inspection, you can disable or change severity level of any solution-wide inspection. This can be done on the page of ReSharper options — solution-wide inspections are marked with Non-private accessibility label. Note that you cannot set the 'Error' severity for solution-wide inspections.
- When the solution-wide analysis is enabled, issues detected by the solution-wide inspections are highlighted in the opened files in the same way as other issues, and they also appear in the Inspection Results window when you run code inspection in specific scope. However, they do not appear in the Errors/Warnings in Solution window.
- As usual, for any such warning or suggestion, ReSharper provides one or several quick-fixes.
If necessary, you can disable solution-wide inspections or only enable solution-wide inspections for internal symbols in specific project. To do so, select the project in the Solution Explorer and using the Solution-Wide Inspections selector in the Visual Studio's Properties window.
Note that independently of the value in this selector, solution-wide inspections would be disabled if the solution-wide analysis is disabled in ReSharper options.
Specifically, solution-wide warnings and suggestions help you discover:
- Unused non-private type or member declarations:
- Unused return values of non-private methods.
- Unused parameters in non-private members.
- Unassigned fields.
- Unaccessed non-private fields.
- Members and types that can be made internal, private or protected instead of public:
- Non-private classes that can be made sealed.
- Non-private classes or members that can be made static.
- Non-private local variables or fields that can be converted to constants.
- Non-private fields that can be made read-only:
- Non-private classes with never overridden virtual members.
- Non-private events that are never subscribed to.
- Abstract or virtual events that are never invoked:
- Auto-implemented non-private property accessors that are never used.
- Suspicious type conversions or checks.
- Non-private type members that are never used via base type or interface
- Non-private type members that are only accessed from overrides
- Parameters of non-private methods that can be declared with IEnumerable<T> type
- Non-private methods that can have IEnumerable<T> return type
- Redundant method overloads
- Non-static classes that are never instantiated