visual-studio 让 Resharper 在字段上强制使用此关键字
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4087361/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Let Resharper force this keyword on fields
提问by Sorskoot
Does anyone know if it is possible to have resharper force the use of the this keyword when it can be used? For fields and such...
有谁知道是否可以在可以使用 this 关键字时让 resharper 强制使用它?对于字段等...
Resharper is capable of showing where it can be removed, but our coding standard tells us to use the this keyword.
Resharper 能够显示可以删除的位置,但是我们的编码标准告诉我们使用 this 关键字。
回答by bdukes
In ReSharper Options, under Code Editing -> C# -> Code Stylethere is an option for Use "this." qualifier forthat you can set for fields, properties, events, and methods.
在 ReSharper 选项中,在代码编辑 -> C# -> 代码样式下有一个使用“this”的选项。您可以为字段、属性、事件和方法设置限定符。
回答by Brett Veenstra
Checkout the StyleCop for Resharper plugin (part of the StyleCop project).
查看 StyleCop for Resharper 插件(StyleCop 项目的一部分)。
You can then set the "default" severity for StyleCop to Error (or just this particular rule) and it will appear in the R# "files with errors" area inside Visual Studio.
然后,您可以将 StyleCop 的“默认”严重性设置为“错误”(或仅此特定规则),它会出现在 Visual Studio 内的 R#“有错误的文件”区域中。

