ReSharper and MEF - Properties marked as unused

Hello Community,

in one of my projects I'm using MEF quite heavily, for instance to acquire view model instances for UI elements. This leads to a lot of warnings for unused properties. Can I get rid of these warnings without using the comments to switch them off?

I have attached a small solution (VS 2010) demonstrating the problem.



Attachment(s):
WpfBindingTest.zip
4 comments
Comment actions Permalink

Hello Mathias
     You can mark your types with UsedImplicitlyAttribute (see http://www.jetbrains.com/resharper/webhelp/Code_Analysis__External_Annotations.html for more detail). Thank you!

Andrey Serebryansky

Senior Support Engineer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"

0
Comment actions Permalink

Unfortunately, using the annotations is not an option for me because the use of foreign libraries is restricted.

I'd prefer to have a configuration switch to consider public properties of public classes used - at least when they are in class libraries. What do you think about this idea?

Regards,
Mathias

0
Comment actions Permalink

Hello Mathias

You can actually copy/paste the annotation attribute definitions into your solution and use the copied versions instead of referencing the annotations library (see the procedures at the end of that help topic). You can also turn off the 'Type or type member is never used' inspection completely for 'Non-private' accessibility under ReSharper | Options | Code Inspection | Inspection Severity. Thank you!

Andrey Serebryansky

Senior Support Engineer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"

0
Comment actions Permalink

That's exactly what I've been looking for! Thanks a lot.

0

Please sign in to leave a comment.