views:

79

answers:

2

I am curious how other Resharper users deal wih R#'s complaint about virtual methods it thinks are unused because it can't tell that NHIb will use them at runtime. I currently leave it as a hint, reluctantly, although am tempted to shut it off completely.

Cheers,
Berryl

example property or method where R# sees that a virtual member is never overriden

   public virtual string Hello{ get { return "Hello"; } }
+2  A: 

You can safely keep them as hints.

It would be nice if R# allowed different settings per project, so you could disable it for your Domain classes only.

It's important to remember R# is just a tool; don't let it do the thinking for you. If an inspection is unhelpful most of the time, just disable it (or leave it as a hint, like you did)

Diego Mijelshon
+1 I just disable it.
Mauricio Scheffer
I'd rather save my limited brain cycles for other things, which R# helps me do! Sorry, R# told me to say that :--)
Berryl
Yeah, looks like turning it down to a hint is the best available option at this time. Cheers
Berryl
You can set a different set of rule per solution but not per Project (shame)
Saint Gerbil
+3  A: 

Have you tried adding the UsedImplicitlyAttribute?

EDIT: This works for me at the method level to suppress "Method 'Fink' is never used":

[UsedImplicitly]
private void Fink()
{
   Console.WriteLine("Fink!");
}

Note that you can also go to ReSharper/Options/Code Inspection/Settings and add to the Generated code regions. We do that for our CodeSmith templates.

TrueWill
this sounds like what I am looking for; need to read it. can you post a sample usage in the meantime? Cheers
Berryl
That attribute works for an unused class only. Thanks for the tip about tthe attributes tho. Cheers
Berryl
@TrueWill: it is certainly similar but different, as you can see from the example I added an above. Cheers
Berryl
@Berryl - Thanks for the clarification. We have that set to Show as suggestion. So +1 for Diego's answer!
TrueWill