How to get rid of Naming rule violation messages in Visual Studio?

SteveFerg picture SteveFerg · Nov 29, 2016 · Viewed 76.3k times · Source

I just installed Visual Studio 2017. When I open an existing website, I get all sorts of warning messages such as this one:

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

In the code it is defined as:

[System.Runtime.InteropServices.DllImport("swedll32.dll")]
public static extern Int32 swe_calc(double tjd, int ipl, Int32 iflag, IntPtr xx, IntPtr serr);

This also occurs with my ASP.Net controls. As an example of a DropDownList:

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

How can I eliminate these type of warnings under Visual Studio?

Answer

Jason Gabel picture Jason Gabel · Dec 13, 2016

Its a new configurable feature, if you go to

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.

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.