Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get Resharper to treat Specflow Bindings, Step Def etc. annotations as Implicitly Used

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>  
like image 992
Dave00Galloway Avatar asked Apr 29 '14 08:04

Dave00Galloway


1 Answers

  1. Put your TechTalk.SpecFlow.xml to C:\Program Files (x86)\JetBrains\ReSharper\v8.2\Bin\ExternalAnnotations\;

  2. Remove ".dll" extension from <assembly name="TechTalk.SpecFlow.dll"> in xml you mentioned to get <assembly name="TechTalk.SpecFlow">;

  3. Reopen Visual Studio;

  4. Clean ReSharper caches for the solution;

like image 70
Alexander Kurakin Avatar answered Nov 03 '22 01:11

Alexander Kurakin