Fix naming by access modifiers
Answered
I would like to be able to just for example fix naming for private members
Please sign in to leave a comment.
Hello Philipmurdock,
Have you tried adjusting the settings for naming here: "ReSharper | Options | Code Editing | C# | Naming Style"? If I misunderstood the question, please describe it in more detail. Thanks in advance!
Hi Maria Pleskunina,
Suppose we have a class like this one :
class Test{
private int integer;
private string str;
public void Test1(){}
public void test2(){}
}
I wanna be able to fix naming by access modifier, let's say for this example only for private members (integer, str).
Philipmurdock thanks for the reply. You can configure the "instance fields (private)" option in "(Extensions |) ReSharper | Options | Code Editing | C# | Naming Style". Then you can press Alt+Enter and choose "Rename to ..." in the action list. Automatic correction of naming style violations can be performed in the current file, project or solution using the fix in scope feature.
Please let me know if I misunderstood the question again. It would help if you attach an example of the name you expect to see. Thank you!
Sorry but what I want is to correct naming style violations only for private members without modifying public/internal members names
Ah, now I get it! Sorry it took so long.
As far as I understand, there are no convenient ways to implement this behavior. I came up with an exotic method, I'm not sure if it will work for you.
You can create a .editorconfig file (ReSharper | Options | Code Editing | General Formatter Style | Write current style to .editorconfig) where naming inspections will be disabled for all members, except for private members. You can even create your own naming rule for it. Then you can apply the name fix to the entire file or project/solution.
If in the future you are interested in members with different access modifiers, you can disable reading .editorconfig file here: "ReSharper | Options | Code Editing | General Formatter Style | Read code style from .editorconfig files".
Also, I've submitted a new feature request to YouTrack: https://youtrack.jetbrains.com/issue/RSRP-481982. Please feel free to comment or vote for it to track its status changes.