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

How to get rid of Naming rule violation messages in Visual Studio?(如何摆脱 Visual Studio 中的命名规则违规消息?)
本文介绍了如何摆脱 Visual Studio 中的命名规则违规消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了 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 中的命名规则违规消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)