I'm using Reshaper with Specflow, and the ResharperCode Inspection is flagging Step Definitions, Bindings and Hooks as never used.
I tried to use the answer from here
but wasn't able to successfully get the External Annotations to be picked up correctly. Here's what I tried in the External Annotations file:-
<assembly name="TechTalk.SpecFlow.dll">
<member name="T:TechTalk.SpecFlow.BindingAttribute">
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
</member>
<member name="T:TechTalk.SpecFlow.GivenAttribute">
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
</member>
<member name="T:TechTalk.SpecFlow.WhenAttribute">
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
</member>
<member name="T:TechTalk.SpecFlow.ThenAttribute">
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
</member>
</assembly>
which I've tried saving in C:\Program Files (x86)\JetBrains\ReSharper\v8.2\Bin and C:\Program Files (x86)\JetBrains\ReSharper\v8.2\Bin\ExternalAnnotations (wasn't too clear where it should go since the ExternalAnnotations folder didn't exist in the default install)
but when I close and reopen VS, the Inspection still picks up the Bindings and step defs as unused:-
Solution qdf.AcceptanceTests.sln
Project Alpari.QualityAssurance.SpecFlowExtensions
Alpari.QualityAssurance.SpecFlowExtensions\Steps\CrossStepDefinitionFileTwo.cs:7 Class 'CrossStepDefinitionFileTwo' is never used
Alpari.QualityAssurance.SpecFlowExtensions\Steps\CrossStepDefinitionFileTwo.cs:10 Method 'GivenICreateAnInstanceOfStepDefinitionOneFromStepDefinitionTwo' is never used
Alpari.QualityAssurance.SpecFlowExtensions\Steps\CrossStepDefinitionFileTwo.cs:42 Method 'GivenICallAMethodInStepDefinitionTwoThatCallsTheSameMethodInStepDefinitionFileOne' is never used
Can anyone tell me what I've done wrong in configuring this please?
EDIT completed xml which worked fine after following Alexander's post:-
<!--Deploy to %ReSharperInstallDir%\Bin\ExternalAnnotations
to check the ExternalAnnotations have worked, highlight one and press Ctrl-Shift-F1
see https://stackoverflow.com/questions/23359738/how-can-i-get-resharper-to-treat-specflow-bindings-step-def-etc-annotations-as
for additional info
-->
<assembly name="TechTalk.SpecFlow">
<member name="T:TechTalk.SpecFlow.BindingAttribute">
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
</member>
<member name="T:TechTalk.SpecFlow.GivenAttribute">
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
</member>
<member name="T:TechTalk.SpecFlow.WhenAttribute">
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
</member>
<member name="T:TechTalk.SpecFlow.ThenAttribute">
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
</member>
<member name="T:TechTalk.SpecFlow.BeforeTestRunAttribute">
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
</member>
<member name="T:TechTalk.SpecFlow.AfterTestRunAttribute">
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
</member>
<member name="T:TechTalk.SpecFlow.BeforeFeatureAttribute">
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
</member>
<member name="T:TechTalk.SpecFlow.AfterFeatureAttribute">
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
</member>
<member name="T:TechTalk.SpecFlow.BeforeScenarioAttribute">
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
</member>
<member name="T:TechTalk.SpecFlow.AfterScenarioAttribute">
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
</member>
<member name="T:TechTalk.SpecFlow.BeforeAttribute">
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
</member>
<member name="T:TechTalk.SpecFlow.AfterAttribute">
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
</member>
<member name="T:TechTalk.SpecFlow.BeforeScenarioBlockAttribute">
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
</member>
<member name="T:TechTalk.SpecFlow.AfterScenarioBlockAttribute">
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
</member>
<member name="T:TechTalk.SpecFlow.BeforeStepAttribute">
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
</member>
<member name="T:TechTalk.SpecFlow.AfterStepAttribute">
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
</member>
<member name="T:TechTalk.SpecFlow.StepArgumentTransformationAttribute">
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
</member>
<member name="T:TechTalk.SpecFlow.StepDefinitionAttribute">
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
</member>
<member name="T:TechTalk.SpecFlow.ScopeAttribute">
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
</member>
</assembly>
Put your TechTalk.SpecFlow.xml to C:\Program Files (x86)\JetBrains\ReSharper\v8.2\Bin\ExternalAnnotations\;
Remove ".dll" extension from <assembly name="TechTalk.SpecFlow.dll">
in xml you mentioned to get <assembly name="TechTalk.SpecFlow">
;
Reopen Visual Studio;
Clean ReSharper caches for the solution;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With