ReSharper conventions for names of event handlers

Pavel Belousov picture Pavel Belousov · Jun 8, 2010 · Viewed 11.2k times · Source

When I add new event handler for any event, VS creates method like object_Click. But ReSharper underlines this method as Warning, because all methods should not have any delimeters such as "_".

How can I customize rules of ReSharper so that it doesn't underline such methods? Or may be I should rename such methods?

Thanks in advance.

Answer

David North picture David North · Jul 27, 2010

For C# (or VB), make the following change:

ReSharper | Options | Languages | C# | C# Naming Style, Advanced settings... Change 'Event subscriptions on fields' from $object$_On$event$ to $object$_$event$.

You may also want to add additional rules to entity kinds like 'Types and namespaces' to account for code-generated classes such as 'Default'. For example, add a new rule with a '' Name Prefix and a Name Style 'UpperCamelCase'.