Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Resharper rename variables to start with an underscore?

I've never understood this, and frankly, it pisses me off to see it in code: variable names that begin with an underscore.

What is the point of this?

I've just installed Resharper 5.1, trying it out and it seems nice, though this one thing is ruining it for me.

I haven't checked, but I'm hoping I can turn it off. But why is it done in the first place?

like image 889
KdgDev Avatar asked Jul 19 '10 14:07

KdgDev


1 Answers

It's a pretty common style for private fields, some use m_lowerCamelCase, others only _lowerCamelCase and still others lowerCamelCase. For variables inside a functions it's a lot more rare and reshaper by default use lowerCamelCase for them.

Note that the naming section of the design guidelines discourage the use of prefixes for public members but private members are not concerned (And public fields should be used only in really specific cases due to their dangers anyway).

In the reshaper options all of that could be changed in Languages > Common > Naming Style.

You could also save your parameters in the solution or in a file and import/export them. Using that you could set the parameters once and for all for everyone in your team.

like image 165
Julien Roncaglia Avatar answered Nov 15 '22 09:11

Julien Roncaglia