visual studio 2017 15.9.13 如何避免Add this or me 资格问题

How to avoid Add this or me qualification issue in visual studio 2017 15.9.13

我们如何解决以下错误。相同的代码在以前的 visual studio 版本中没有任何错误。只有在升级后我才会收到此错误。不可能将 'this' 添加到大型解决方案中的所有属性。因此,有什么简单的方法可以避免这个错误。

对编辑器配置文件进行了更改,它开始工作了。

# Remove the line below if you want to inherit .editorconfig settings from higher 
directories
root = true

# C# files
[*.cs]

# this. and Me. preferences
dotnet_style_qualification_for_field = false:silent
dotnet_style_qualification_for_property = false:silent
dotnet_style_qualification_for_method = false:silent
dotnet_style_qualification_for_event = false:silent

我正在使用 Resharper,发现 Visual Studio (2019) 在代码完成时添加了 this 限定符,然后会触发 resharper 的 Remove redundant 'this' qualifier 建议。

出于某种原因,通过图形用户界面更新这些设置(Reshaper 或 Visual Studio 设置)没有任何效果。然而,更新 .editorconfig 立即对我有用。谢谢@Deepak!

  • 禁用建议和代码完成添加 this 限定符。
# "This." and "Me." qualifiers
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion
  • 强制设置为 true 和 select 所需的严重性。 true:warningtrue:error.

Language conventions