Naming Rule for Event Handlers

Nathan Sokalski 4,106 Reputation points
2021-11-06T20:09:21.603+00:00

I want most methods in my code to start with a capital letter, and this is what Visual Studio 2019's Code Style Naming Rule currently does. However, most of my event handlers start with a lower case letter, such as the following:

private void btnRoundOneTab_Click(object sender, EventArgs e)

So based on the current naming rule, my event handlers give a Naming rule violation. This may not prevent my code from running, but seeing all those extra squiggly lines is very annoying. I know that I can disable the naming rule for individual methods or ranges of code, but doing this adds a lot of extra code (since I obviously have a lot of event handlers). Is there any way to make the Code Style recognize my event handlers (such as regular expressions or parameters) so that I can use a different style for my normal methods & event handlers?

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,137 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,945 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Karen Payne MVP 35,426 Reputation points
    2021-11-06T22:30:51.67+00:00

    See under Tools -> Options

    147045-figure1.png

    147046-figure2.png


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.