简体   繁体   English

如何关闭“限定符”这个。 在Resharper是多余的“警告?

[英]How to turn off “Qualifier 'this.' is redundant” warnings in Resharper?

In my code I have a lot of this. 在我的代码中,我有很多this. qualifiers (a habit from writing Python code), so I have a lot little orange warning markers in the right hand gutter saying "Qualifier 'this.' 限定词(编写Python代码的习惯),所以我在右边的排水沟中有很多小的橙色警告标记,上面写着“限定符”这个。 is redundant". 是多余的“。 I don't want to remove the this. 我不想删除this. qualifiers. 预选赛。 How can I turn off the orange warning markers? 如何关闭橙色警告标记?

For Resharper 9 it's been moved. 对于Resharper 9,它被移动了。 Actually I never noticed in Resharper 8, because I use " this " for clarity. 实际上我从未在Resharper 8中注意到,因为我使用“ this ”来表示清晰。 My problem is that now it's all over the place and it drives me insane. 我的问题是现在它到处都是,它让我疯了。 I hope this helps someone, because it took me some time to find this. 我希望这对某人有所帮助,因为我花了一些时间才找到这个。

Resharper 9位置

Change your settings in the Inspection Severity section. 在“检查严重性”部分中更改您的设置。 In the C# tab, there is a section called Redundancies in Code . 在C#选项卡中,代码中有一个名为Redundancies in Code的部分。 In there is a Redundant this.' qualifier 在这里有一个Redundant this.' qualifier Redundant this.' qualifier setting. Redundant this.' qualifier设置。 I put mine on "Do not show" (gray-colored). 我把它放在“不要显示”(灰色)上。

在此输入图像描述

在此输入图像描述

The following is taken from the comment by @user2864740, which the OP found to solve the problem: 以下内容来自@ user2864740的评论,OP发现它可以解决问题:

It should be possible to open up the ReSharper context menu - click on the pencil thing to the left when the warning is "in focus", or perhaps hit Alt+Enter (?) - and select "Change Inspection Severity..". 应该可以打开ReSharper上下文菜单 - 当警告“聚焦”时点击左侧的铅笔,或者点击Alt + Enter(?) - 并选择“Change Inspection Severity ..”。 It should provide several options from Ignore to Error. 它应该提供从忽略到错误的几个选项。 I believe there is also an inspection option to Require the this. 我相信还有一个检查选项要求这个。 explicitly, but I've never felt inclined to look for or enable it. 明确地说,但我从未感到倾向于寻找或启用它。 (Such an option would likely be within the main Code Inspection R# options.) (这样的选项可能在主要的代码检查R#选项中。)

If you don't have the ($$$) Resharper, you don't need it to remove the orange warning markers or the lightbulb suggestions. 如果您没有($$$)Resharper,则不需要它来删除橙色警告标记或灯泡建议。 You can do this within VS 2015: Follow exactly this set of instructions in the green-checked answer, but tick the "Qualify member access with 'this' " instead. 您可以在VS 2015中执行此操作:在绿色选中的答案中完全按照这组说明进行操作 ,但请勾选“使用'this'验证成员访问权限”。 Click OK, and you'll never see another this lightbulb again. 单击确定,您将再也看不到另一个this灯泡。

I don't know if this particular configuration is available in other VS versions, but at least you can check your version. 我不知道这个特定的配置是否在其他VS版本中可用,但至少你可以查看你的版本。

OR, apply the change globally (project-wide or solution-wide) with one click as demonstrated here: 或者,一键单击应用全局(项目范围或解决方案范围),如下所示:

项目范围内删除<code>此</ code>限定符

And you'll never see it again in your project. 你永远不会在你的项目中再次看到它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM