R# naming style is really primitive, how about changing it?

Hello,

I've always wondered why did you choose this kind of configuration approach to your naming style, I mean, couldn't you let the user write code and let R# copycat or deduce the conventions based on the actual code the user provided? it's much easier to express how you want the code to look like rather than going through detailed configuration about it.

This feature can replace both the Formatting Style configuration and the Type Members Layout of R#.

This is obviously a suggestion but I think that it's much more intuitive than the current configuration that grows and grows with each new version of R#, this will ease some of the pain that we have to go through when we're configurating R#.

4 comments

Hello Eyal,

Thanks for the suggestion.
Basically, the idea of some kind of "Check my code and adjust ReSharper formatting and naming style based on it" feature is really common. However, we cannot implement it now, since there are lots of difficulties (for example, different naming styles for one type of symbol used in the same file/project/solution). These kinds of conflicts can be hardly avoided, as well as it is not clear now how to implement it to be efficient as well as user-friendly. If in this 'conflict' scenario, this feature will provide a list of different naming styles detected in file, it won't be very useful.

As soon as we find out a 'golden middle' implementation for this, we will provide this functionality in ReSharper.

Currently, all formatting and naming styles should be adjusted manually (thankfully we have dosens of settings, so everything is configurable).
Thanks for the suggestion anyways!

0

Alex, I think you misunderstood me.

What I was thinking about is an actual option that is a text editor similar to the one you have in "Type Members Layout" where you type in some code and R# deduce the conventions from it, basing the convention on the current code is not such a great idea and as you said there are a lot of difficulties with it but if the developer provides the conventions then it should work like the configuration but instead configurating things the developer provides some code like the following.

// Some class
public class PublicClassConvention
{
     // Some const
     private const string PRIVATE_CONST_CONVENTION = "";
     
     // Some readonly variable
     private readonly string _privateReadonlyFieldConvention = "";
     
     // Public methods shoulds be first in order
     public void PublicMethodConvention()
     {
     }
     
     // Protected methods should be second in order
     protected void ProtectedMethodConvention()
     {
     }
     
     // Private methods should be third in order
     private void PrivateMethodConvention()
     {
     }
}

// Some test class
[ReSharperTestClassDecoration]
public class TestClassConvention
{
     [Fact]
     public void this_is_a_test_method_convention()
     {
     }
}


Now, you can add all kind of special attributes there to tell ReSharper it needs to behave differently when it deals with these kind of types like I did in the test class.

The nice thing about it is that the developer will know exactly how ReSharper is going to format the code just by looking at it.

Currently, all formatting and naming styles should be adjusted manually (thankfully we have dosens of settings, so everything is configurable).

Alex, the point is to make the configuration a lot easier and the experinece a lot faster by allowing the user to provide the convention rather than going through painful configuration.

dozens of settings that takes some practice to figure them out and I can imagine how hard it is for new comers.

Also, with this option available you may do something like this and R# will only format variables that are readonly.

public class PublicClassConvention
{
     // Some readonly variable
     private readonly string _privateReadonlyFieldConvention = "";
}


The benefit of this approach is that you can define the convention as you go instead of getting them all at once.

0

Hi Eyal,

Thanks for the detailed description. This makes sence; I forwarded your suggestion to the correspoinding developer.
Hopefully, we can do something about it.

Thanks!

0

Thank you! I really hope that at some point this is going to be implemented. :)

0

Please sign in to leave a comment.