开发者

C# + Resharper - Events method with underscore - Naming convention

开发者 https://www.devze.com 2023-01-06 06:45 出处:网络
I have VS 2010 with resharper (any versi开发者_运维问答on, now 5.1). The default naming convention coming with R# about public or protected method\'s name is: \"ThisIsMethodName\", and I think it\'s

I have VS 2010 with resharper (any versi开发者_运维问答on, 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?


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).


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.


You can change the callback of a form or any elements available in the UI so it matches the naming convention from resharper.

Example:

example on changing callbacks

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号