Am having some problems with ReSharper (latest, 2023.1, installed for VS2017) and detection of unused types.
When opening class files, some class names are ghosted as though they're not referenced, but on running Find All References
on the type it's clear that they are, sometimes in many places.
Additionally, when using Find Code Issues
from a right-click in Solution Explorer on the solution or a project, many in-use types are listed in the "Type is never used" issue class.
As far as I can see these two problems don't always necessarily match up, in that they have different opinions about what's in use and what isn't.
Commenting-out a class which is shown as unused, but which isn't, causes ReSharper to immediately recognise a problem and display a red symbol at bottom right, so it seems as though it potentially knows the truth!
I've tried clearing ReSharper's cache via Options
-> General
, and cleaning and rebuilding the solution (with all of the solution's projects included in the build). The latter brought down the number of false positives shown by Find Code Issues
, but neither have solved it completely.
The only irregular thing I can think of about the solution itself is that some of the assemblies are set up for two target frameworks (.Net Standard and .Net Core), but I don't know if that could have this effect.
Has anyone run into similar problems and found a way to solve them?
ReSharper performs usage inspections based on the currently selected target framework. For example, if a class is utilized within the context of .NET Core but not within the context of .NET Standard, ReSharper will flag this class as unused when the target framework is set to .NET Standard. If this is not a case, I'd suggest to file an issue to the ReSharper's bugtracker