[MeansImplicitUse] on methods?


I have some code that I have decorated with a MessageSink Attribute to perform a mediator pattern communication between ViewModels.

The problem I get is: that this method then become marked as unused methods by Resharper.

So I got the hint that I should use MeansImplicitUse to avoid this.
However I tried to annote them with MeansImplicitUse and get the error message that it can only be used on classes.  So I cant put it on my decorated method, and putting it on my MessageSinkAttribute class doesnt actually imply the use in the class where the decorated method is.

I would like to avoid putting it on the whole ViewModel if possible but I am not quite sure how this is supposed to work. Is there something I have overlooked or any hints in the right direction would be appreciated.

Comment actions Permalink

Hello Jon
     The MeansImplicitUse attribute can be applied to some custom attribute class A that you have in order to tell ReSharper that everything that has attribute A is used implicitly. There's also the UsedImplicitly attribute, that can tell ReSharper that the symbol with that attribute is used implicitly and it shouldn't be counted as unused. So in order to achieve your goal you can either put MeansImplicitUse attribute on your MessageSinkAttribute class or put UsedImplicitly attribute on all methods that you don't want ReSharper to count as unused. Let me know if this helps. Thank you!

Andrey Serebryansky

Senior Support Engineer

JetBrains, Inc


"Develop with pleasure!"

Comment actions Permalink

Ah thank you Andrey Serbanski

The UsedImplicitly was what I was looking for. I had some problems when I tried to use the code that you get from the options menu instead of the dll directly but I guess it was a namespace issue.

But it works if I referenced the dll directly and use that decorator.

Thank you so much for your patience with me.

On a related note: This guide mentions 4.0 of resharper is this still the latest up to date documentation for all available annotations.http://www.jetbrains.com/resharper/webhelp/Code_Analysis__External_Annotations.html?

Jon Warghed
Software Developer
Atea Services and Software


Please sign in to leave a comment.