Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fix all 'Naming rule violation' shown in VS2017 for all opened files at once

Is there any tool witch allows to apply fix for all VS2017 messages like "IDE1006 Naming rule violation: These words must begin with upper case characters"?

In VS2017 it has to be done manually one by one, it shouldn't be hard to add such feature in IDE since all elements are listed. I tried to find solution in Resharper but despite of its vast functionallity in matter of naming styles I didn't find what I was looking for.

like image 961
HardyHard Avatar asked Mar 15 '17 21:03

HardyHard


People also ask

Can a solution or a project override a Visual Studio Rule?

But a solution or a project can override these rules, so that everyone who works on the solution/project is using the same rules, no matter what they have configured in Visual Studio. To configure these rules, you use an .editorconfig file.

How do I change the default rules in Visual Studio?

In your Visual Studio instance, you can configure the default rules in the options. But a solution or a project can override these rules, so that everyone who works on the solution/project is using the same rules, no matter what they have configured in Visual Studio. To configure these rules, you use an .editorconfig file.

How do I change the name of my code in Visual Studio?

In Visual Studio, go to Tools->Options, and in the Options Window navigate to Text Editor – C# – Code Style – Naming as you see it in the screenshot below: There you can see a few rules of Visual Studio. Click on the Manage naming styles button.

How to add a new naming style in Visual Studio?

There you can see a few rules of Visual Studio. Click on the Manage naming styles button. This opens up this little Window: There you click on the green plus to add a new naming style.


1 Answers

Here is the solution. Resharper allows you to create custom naming rules in Options/CodeEditing/C#/NamingStyle go to Advenced Settings and add your custom rule. In my case I wanted to fix lowercase event names to Uppercase. I failed before because even though i selected UpperCamelCase_UndescoreTollerant for events Resharper didn't find any naming violations after CleanUp Code.

To make CleanUp Code find it one more thing is needed to be done.

The field Event subscriptions on fields is by default $object$$event$, but it has to be changed to *$:Luobject$$event$* (:Lu - Regex First Character Uppercase)

Resharper after CleanUp Code allows you to fix naming by select event, click the light bulb and apply for a document/project/solution.

Screen

like image 104
HardyHard Avatar answered Oct 13 '22 09:10

HardyHard