Not getting error on changing the coding validation rule in stylecop.json

112 Views Asked by At

I made followinh changes to the stylecop.json file

"orderingRules": {"usingDirectivesPlacement": "insideNamespace"}

But i am only getting warning and not error in the cs files.

When i place the using directive outside the namespace i don't get any error.

1

There are 1 best solutions below

7
Node defender On BEST ANSWER

Please try the following steps:

  1. Create a new editorconfig File in your project

enter image description here

enter image description here

  1. Open the editorconfig File, find the perferred 'using' directive placemen in Code Style and adjust it to inside namespace

enter image description here

  1. Save the editorconfig File, and then you will put the using directive in the namespace when you create the class again.

enter image description here

Finally, you also need to refer to Should "using" directives be inside or outside a namespace in C#?. Because usually stylecop will not check the code outside the namespace