tags:

views:

76

answers:

2

I have VS 2010 with resharper (any version, now 5.1).

The default naming convention coming with R# about public or protected method's name is: "ThisIsMethodName", and I think it's fine. But, sometimes, the default naming of .NET methods, is not like I'm expecting, for example Page_Load, or (with a button click in webform designer panel) Button1_Click. As you can see, we have the underscore between words.

Why we have this and how (if it is possible) I can remove all underscores from my solution?

+2  A: 

These underscores are created by the default Visual Studio WinForm designer (when you double click on the event name in properties panel VS creates a method with this name). I am not sure what is the convention in WCF. This doesn't have anything to do with resharper - you will observe the same behaviour if you disable it. I don't think it is configurable.

You can always rename these methods after they are created (in the usual way - using Resharper).

Grzenio
They are also automatically added in code-view when you press "tab" after typing the "+=" when attaching an event handler to an event.
iobrien
Of course I can rename button clicks method (as I can write 3 lines of code myself and not using the auto-generated one), but I can't rename the Page_Load method. If I rename it using the usual way (reshaper just helps me), the renamed method "PageLoad" won't be called.
netrace
+1  A: 

I think I would live with the way dotnet creates the events because you will be renaming every single time you create some control that requires an event.

You can change the defaults in ReSharper if you want to allow for this format. In VS2008, it is in ReSharper -> Options -> Languages -> Common -> Naming Styles.

RJ
:) Cool solution, but i want to keep the default naming style comes with resharper. This is also the same naming convention used by .net framework (you can see using intellisense navigating some objects you want). But in methods like "Page_Load" the naming convention is not used, I think there's something about compatibility with older stuff.
netrace