|Home||Back to Index|
ReSharper version 4.5 added significant functionality to the Solution-wide Analysis feature. I have found this to be a valuable tool. However, it’s wise to be extremely cautious about removing public members that ReSharper says are never used.
I would not expect ReSharper to know about projects that are not part of the current solution. If you’re creating a shared library, you’re likely to see a lot of “unused” public members.
What was less obvious to me is that data binding is not detected by ReSharper in this context. For example, say I have a public string property named FullName on a class. ReSharper displays a hint that “Property ‘FullName’ is never used". ReSharper’s Find Usages likewise finds no references. The property may still be data-bound to a control, though, since data binding generally references the property name as a string. Removing the property would cause a runtime failure.
ReSharper’s Find Usages Advanced can be used to find the binding, if Textual occurences is checked.
“Class ‘Foo’ is never instantiated” hints may also be incorrect. IoC containers (such as Unity) or other Reflection-based techniques can fool ReSharper.
Please note that I’m not suggesting turning off Solution-wide Analysis (and if you’re not using ReSharper, you’re working harder, not smarter!). Just be aware of its limitations.
Update - August 17, 2009
The UsedImplicitlyAttribute can be used where necessary to mitigate this problem.