Is there a naming style for VS's event handler naming convention?

The new naming styles are a marked improvement!

But I can't seem to find any way to tell RS to support Visual Studio's default naming convention for event handlers.

In other words, how do I specify that a name like "SomeObject_SomeEventHandler" is a valid name for a method? Is this even possible?

If this hasn't been added yet, I'd like to make a suggestion: Instead of duplicating the naming styles (so that you have another style like UpperCamelCase with underscores, etc.), add a check box for "Allow underscore as a word separator" so you can choose a naming style and choose to allow or disallow underscores in the name. For example, if you choose UpperCamelCase with underscores allowed, "SomeName" and "Some_Name" would both be valid, but "So_meName" would not be.

For an added bonus (long term feature request?), it would be nice to be able to specify this convention only for methods that have the standard signature for an event handler (e.g., with an object parameter and an XyzEventArgs parameter).




We thank you for raising the issue.

I’ve suppressed naming consistency checking for designer generated methods. Change is accessible in the last nightly build.

We are going to work out a more flexible solution for managing ‘special’ names but not for 4.5.


Great! I'll let you know how it goes when you publish the next nightly.


I will add my comment here rather than start another thread.  In addition to the styles
   UpperCamelCase          and
I would appreciate
   Upper_Camel_Case       and

Example use:

   int core_X_Location = 35;
   int core_Y_Location = 36;

IMO in this case the underscores around 'X' and 'Y' aid clarity.


   -- Mark


Sergey.Shkredov wrote:

I’ve suppressed naming consistency checking for designer generated methods.

Do I have to enable this as I'm still getting the following error on Visual Studio created methods

...does not match rule 'Methods, properties and events'.

I'm running EAP Build 5.1.1707.19


I can confirm this bug also in build 5.1.1727. Auto generated event handlers are not being ignored in terms of naming rules.

This is a real pain when developing winforms apps since we have loads of event handlers in almost every form.


Go To Resharper -> Options -> Languages -> Common -> Naming Style

Press "Advanced Settings"

On the dialog you will find "Event subscriptions on fields". Change the value to "$object$_$event$" and it should work.


That worked, Thanks. One adicional question. Is "$object$_On$event$" goint to the default from now on or will it go back to "$object$_$event$" in future versions?


Thanks for clearing this up.... I could not find a solution to this problem anywhere


Is it should work? I try on 5.1.3000.12 and it still generates event handler with default VS naming style.


I found that I also need to set this specifically on the C# language settings, and not just the common settings.


I guess it worked for me with the common settings because I have the option "use common settings for this language" activated on the c# naming style options page. :)


Please sign in to leave a comment.