从添加批注停止ReSharper的 [英] Stop ReSharper from Adding Annotations

查看:440
本文介绍了从添加批注停止ReSharper的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的C#项目使用ReSharper的,一般我喜欢它。然而,它使添加注解,当我做一些重构操作的代码。

I'm using ReSharper in my C# projects, and generally I love it. However, it keeps adding annotations to the code when I do certain refactoring actions.

例如,它增加了 [NOTNULL] 当我使用检查空参数上下文动作:

For example, it adds [NotNull] when I use the "Check parameter for null" context action:

// Before context action
public void Foo(object input)
{
}

// After context action
public void Foo([NotNull] object input)
{
    if (input == null)
    {
        throw new ArgumentNullException("input");
    }
}

此外,ReSharper的然后添加使用JetBrains.Annotations 来的文件,即使我没有引用其中该属性定义JetBrains的组装。

Additionally, ReSharper then adds using JetBrains.Annotations to the file, even though I'm not referencing the JetBrains assembly where the attribute is defined.

我想继续使用上下文行动,因为他们是非常有用的,但我不能在代码中引入外部注释。 ReSharper的提供更改默认注释命名空间和注释属性的源代码复制到你的项目的选项,但是这也不是这个项目的选项。

I would like to continue using the context actions, as they're very useful, but I can't introduce external annotations in the code. ReSharper provides an option to change the default annotation namespace and to copy the annotation attribute source code into your project, but that also isn't an option for this project.

时有什么办法可以告诉ReSharper的完全停止添加注释?我试过在取消选中JetBrains.Annotations与代码注释属性的命名空间的选项,但是这似乎并没有对是否摆在首位生成注释任何影响。

Is there any way to tell ReSharper to stop adding annotations entirely? I've tried in the options unchecking JetBrains.Annotations as a namespace with code annotation attributes, but that doesn't seem to have any effect on whether the annotations are generated in the first place.

更新:虽然我实际上并没有引用JetBrains.Annotations.dll,我引用另一个DLL,它重新实现在同一个命名空间JetBrains.Annotations相同的注释属性。删除该DLL引用将防止从ReSharper的添加注释。这会是很好,如果仍有关闭这个功能选项,但解决方法符合这种情况。

Update: While I wasn't actually referencing JetBrains.Annotations.dll, I was referencing another DLL that re-implemented the same annotation attributes in the same JetBrains.Annotations namespace. Removing that DLL reference will prevent ReSharper from adding the annotations. It'd be nice if there was still an option to turn this off, but the workaround fits for this situation.

推荐答案

当您引用JetBrains.Annotations.dll,对于检查参数为空的默认操作似乎是使用 NOTNULL 属性(尽管添加与NotNullAttribute注释选项。

When you reference the JetBrains.Annotations.dll, the default action for "Check parameter for null" seems to be to use the NotNull attribute (despite adding an "Annotate with 'NotNullAttribute'" option.

这是我所知道的是不引用唯一的解决方法 JetBrains.Annotations.dll

The only workaround that I know is to not reference JetBrains.Annotations.dll.

寻找更成这样,似乎有一个建议/错误, [NOTNULL] 请求时,注释DLL包括在内,检查参数空添加:的 http://youtrack.jetbrains.com/issue/RSRP-70350 如果任何人发生过这个奇事为什么 ...

looking more into this, it seems that there was a suggestion/bug that [NotNull] be added when the annotations dll is included and "Check parameter for null" is requested: http://youtrack.jetbrains.com/issue/RSRP-70350 In case anyone else happens across this and wonders why...

这篇关于从添加批注停止ReSharper的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆