2

I prepend an underscore to the names of my local methods, for example:

private bool _DoSomething() {..}

VS 2019 gives me an IDE1006 (Name Violation) for this construct. Is there a way to suppress the name violation ONLY for this particular naming convention? I don't want to suppress all name violation warnings, just this particular construct.

Bob.at.Indigo.Health
  • 11,023
  • 13
  • 64
  • 111
  • First question is why are you ignoring the IDE's warning? – Andrew Williamson Sep 09 '19 at 23:49
  • Have you tried using a #pragma statement? https://visualstudiomagazine.com/articles/2017/09/01/hide-compiler-warnings.aspx – quaabaam Sep 09 '19 at 23:56
  • duplicate... I believe the third answer down in this link has your solution... https://stackoverflow.com/questions/40856186/how-to-get-rid-of-naming-rule-violation-messages-in-visual-studio – quaabaam Sep 10 '19 at 00:07

1 Answers1

2

You can set your customized Naming type by the following steps.

Tools → Options → Text Editor → C# → Code Style → Naming

Click "Manage naming styles" to create a new naming style as shown below. enter image description here

Then create the custom naming

enter image description here

After this, click "manage specifications" → modify "Method" → select the accessibilities you need.

enter image description here

Last but not least, close Visual Studio and re-open it.

Community
  • 1
  • 1
大陸北方網友
  • 3,696
  • 3
  • 12
  • 37