views:

85

answers:

1

I'm playing with SpecFlow, and ReSharper thinks that my step definitions are unused (I guess because they're used via reflection):

[Binding]
public class StepDefinitions
{
    // ...

    [When(@"I press add")]
    public void WhenIPressAdd()   // R# thinks this is unused
    {
        _calculator.PressAdd();
    }

    // ...
}

How can I tell ReSharper that methods with [Given], [When], [Then] attributes (etc.) are actually used? I don't want to use // ReSharper disable UnusedMember.Global comments.

I could also mark each method (or the whole class) with [JetBrains.Annotations.UsedImplicitly]. I don't particularly want to do that either.

+1  A: 

You need to use JetBrains Annotations, and mark attribute with an MeansImplicitUseAttribute. You can either reference JetBrains.Annotations.dll or copy annotations source code from Options / Code Inspection / Code Annotations, and put them into your solution.

If you need to annotate some external assembly you don't own, you need to create an External Annotation file (xml) in the following folder: %ReSharperInstallDir%\Bin\ExternalAnnotations. There are plenty of examples, you can just copy some.

Ilya Ryzhenkov
Cool. Is there a way to mark an attribute that I don't own?
Roger Lipscombe
Yes, you can. You need to create an External Annotation file (xml) in the following folder: %ReSharperInstallDir%\Bin\ExternalAnnotations. There are plenty of examples, you can just copy some.
Ilya Ryzhenkov

related questions