Rog*_*mbe 27 resharper resharper-5.0
我正在玩SpecFlow,而ReSharper认为我的步骤定义未使用(我猜因为它们是通过反射使用的):
[Binding]
public class StepDefinitions
{
// ...
[When(@"I press add")]
public void WhenIPressAdd() // R# thinks this is unused
{
_calculator.PressAdd();
}
// ...
}
Run Code Online (Sandbox Code Playgroud)
我怎么能告诉ReSharper的与方法[Given],[When],[Then](等)在实际使用属性?我不想使用// ReSharper disable UnusedMember.Global评论.
我也可以标记每个方法(或整个类)[JetBrains.Annotations.UsedImplicitly].我也不是特别想这样做.
Ily*_*kov 28
您需要使用JetBrains Annotations,并使用a标记属性MeansImplicitUseAttribute.您可以JetBrains.Annotations.dll直接引用,也可以将注释源代码(从ReSharper/Options/Code Inspection/Code Annotations)复制到解决方案中.
如果您需要注释你没有自己的一些外部组件,您需要创建以下文件夹的外部注释文件(XML) %ReSharperInstallDir%\Bin\ExternalAnnotations.有很多例子,你可以复制一些.
如果命名,外部注释文件也可以与DLL在同一路径中DllNameWithoutExtension.ExternalAnnotations.xml.
有很多例子,但是如果你不想追查一个例子,我想要更加明确一些.:)
在%ReSharperInstallDir%\ Bin\ExternalAnnotations中创建一个具有属性程序集(.xml)名称的文件.例如,我制作了Microsoft.VisualStudio.QualityTools.CodedUITestFramework.xml并将此XML放入其中:
<assembly name="Microsoft.VisualStudio.QualityTools.CodedUITestFramework">
<member name="T:Microsoft.VisualStudio.TestTools.UITesting.CodedUITestAttribute">
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
</member>
</assembly>
Run Code Online (Sandbox Code Playgroud)
重启VS,你就在路上!
| 归档时间: |
|
| 查看次数: |
6323 次 |
| 最近记录: |