gpt4 book ai didi

c# - 如何摆脱 Visual Studio 中的命名规则违规消息?

转载 作者:IT王子 更新时间:2023-10-29 03:42:43 29 4
gpt4 key购买 nike

我刚刚安装了 Visual Studio 2017。当我打开一个现有网站时,我收到各种警告消息,例如:

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 的示例:

IDE1006 Naming rule violation: These words must begin with upper case characters: ddlMonth_SelectedIndexChanged

如何在 Visual Studio 下消除这些类型的警告?

最佳答案

这是一个新的可配置功能,如果你去

Tools → Options → Text Editor → Your language (I did C#) → Code Style → Naming

在那里我去管理样式添加驼峰大小写(它在那里,但你需要将它添加到你的可选):转到“+”号,然后相应地添加你的规则。

重要:关闭您的解决方案并重新打开它以使更改生效。

例如,我只对私有(private)方法使用驼峰式大小写。所以我选择 Private Method 并要求 Style 我创建的新方法“camel Case”并将其设置为 Severity Suggestion(我也将其提升到顶部)。

内置的都是“建议”,因此您也可以关闭消息。

关于c# - 如何摆脱 Visual Studio 中的命名规则违规消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40856186/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com