我刚刚安装了 Visual Studio 2017.当我打开现有网站时,我会收到各种警告消息,例如:
I just installed Visual Studio 2017. When I open an existing website, I get all sorts of warning messages such as this one:
IDE1006 命名规则违规:这些单词必须以大写开头字符:swe_calc
IDE1006 Naming rule violation: These words must begin with upper case characters: swe_calc
在代码中定义为:
[System.Runtime.InteropServices.DllImport("swedll32.dll")]
public static extern Int32 swe_calc(double tjd, int ipl, Int32 iflag, IntPtr xx, IntPtr serr);
这也发生在我的 ASP.Net 控件中.以 DropDownList 为例:
This also occurs with my ASP.Net controls. As an example of a DropDownList:
IDE1006 命名规则违规:这些单词必须以大写开头字符:ddlMonth_SelectedIndexChanged
IDE1006 Naming rule violation: These words must begin with upper case characters: ddlMonth_SelectedIndexChanged
如何在 Visual Studio 下消除这些类型的警告?
How can I eliminate these type of warnings under Visual Studio?
这是一个新的可配置功能,如果你去
Its a new configurable feature, if you go to
工具 → 选项 → 文本编辑器 → 您的语言(我用的是 C#)→ 代码样式 → 命名
Tools → Options → Text Editor → Your language (I did C#) → Code Style → Naming
在那里我去管理样式添加骆驼案例(它在那里,但你需要将它添加到你的选择中):转到+"签名,然后相应地添加您的规则.
In there I went to Manage Styles add camel Case (its in there but you need to add it to your selectable): go to the "+" sign, then add your rule accordingly.
重要提示:关闭您的解决方案并重新打开以使更改生效.
Important: Close your solution and re-open it for changes to take effect.
例如,我只将骆驼案例用于私有方法.所以我选择 Private Method 并要求 Style 我创建的新方法camel Case";并将其设置为严重性建议(我也将其提升到顶部).
For example, I only use camel Case for private methods. So I choose Private Method and required Style the new one I created "camel Case" and set it to Severity Suggestion (I also promoted it to the top).
内置的都是建议";也可以关闭消息.
The built in are all "Suggestions" too so you can also just turn off Messages.
这篇关于如何摆脱 Visual Studio 中的命名规则违规消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!