Best way to follow SA1300 with Visual Studio generated event handlers

Jun 17, 2011 at 12:49 PM


there are primarily two places where Visual Studio generates event handlers for you:

  • In the WinForms/WPF designer
  • In the code editor, after typing obj.Event +=

Unfortunately these event handlers always take the form of variableName_EventName. What is the best (and quickest) way to adhere to SA1300 (ElementMustBeginWithUpperCaseLetter) in these situations?

Jun 27, 2011 at 6:37 PM

One of the ways is to use StyleCop+ (StyleCop custom rules) which allows configuring separate naming pattern for private event handlers.
With that you could even control that private event handlers are named like buttonOk_Click, not button_Ok_Click or buttonOkClick

Best regards,
Oleg Shuruev