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

2

本文介绍了如何摆脱 Visual Studio 中的命名规则违规消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

限时送ChatGPT账号..

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

The End

相关推荐

C# 中的多播委托奇怪行为?
Multicast delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)...
2023-11-11 C#/.NET开发问题
6

参数计数与调用不匹配?
Parameter count mismatch with Invoke?(参数计数与调用不匹配?)...
2023-11-11 C#/.NET开发问题
26

如何将代表存储在列表中
How to store delegates in a List(如何将代表存储在列表中)...
2023-11-11 C#/.NET开发问题
6

代表如何工作(在后台)?
How delegates work (in the background)?(代表如何工作(在后台)?)...
2023-11-11 C#/.NET开发问题
5

没有 EndInvoke 的 C# 异步调用?
C# Asynchronous call without EndInvoke?(没有 EndInvoke 的 C# 异步调用?)...
2023-11-11 C#/.NET开发问题
2

Delegate.CreateDelegate() 和泛型:错误绑定到目标方法
Delegate.CreateDelegate() and generics: Error binding to target method(Delegate.CreateDelegate() 和泛型:错误绑定到目标方法)...
2023-11-11 C#/.NET开发问题
14