views:

164

answers:

3

As I implement the MVVM pattern with WPF, I'm finding that Resharper is often warning me that certain properties are never used in my ViewModels. The problem is that they are being used, but only by the data binding system. Has anyone else encountered this annoyance and is there a way to help Resharper realize that these properties are, indeed, being used? I am glad, at least, that VS 2010 properly realizes that [Import] tagged members won't "always be null", but hopefully I can fix this issue as well.

+1  A: 

A crude workaround would be to disable the warning altogether:

Under Resharper > Options > Code Inspection > Inspection Severity, set the warning level for this item to "Do not show".

This is obviously not ideal, but it depends on your level of annoyance with the false positives.

Ben Hoffstein
+1  A: 

You can try two different options. One is to reduce the severity of the Resharper inspection to "Hint". The other option is to use the "Suppress inspection with comment" item Resharper provides for the properties that generate the warning that you know are being used. Personally, I'd go with reducing the severity to "Hint".

Matthew Ferreira
Reducing the severity to Hint works well enough for now. It was bothering me to see unresolved orange lines to the right of my classes.
Dan Bryant
A: 

Are the properties public or internal? In my experience, ReSharper doesn't warn on pubic (since there's no way it could tell that the members aren't being used externally) but it will warn on internal members since they can only be used within that assembly (InternalsVisibleTo notwithstanding)

Maxx Daymon
They're public and I was able to change the settings to Hint for only public properties. I will still see a Warning for private/internal properties, which is fine. The warning shows up in the context of Solution-wide analysis as "Auto-implemented property accessor is never used."
Dan Bryant