How do I specify Method_Names_Like_This as allowed?

I mainly use UpperCamelCase for my method names but for auto-generated methods that implement UI events I want to allow method names like Page_Load

or even something like TimeObjectPictureSubmitButton_Click. My default name style options in resharper for "Method, properties and events" Rule Settings are UpperCamelCase, lowerCamelCase, ALL_UPPER, all_lower, and First_upper. Is it easy to add new ones to cover the styles I mentioned? Is there anywhere people share the style definitins they've defined in resharper? Thanks in advance for any help.

2 comments
Comment actions Permalink

Hello,

Go to the Naming Style >> Advanced settings >> Add >> Provide a name for the new rule in "Rules Description" >> Select "Method" in the "Affected entities" section >> Select "Protected" in the "Access rights" section >> Select "Instance members and locals" in the "Static/non-static" section >> Customise the the "Naming style" to the convention you want it to match.

0
Comment actions Permalink

If your scenario is that you want unit test method names look like e.g.

  MyMethod_Must<do this and that>_When<these are the prerequisites>()

then it is possible to set up ReSharper to allow that, but only for public unit test methods - which is exactly what I want, since I do not like underscores in any other place.

-----------------------------------------------------------------------------------------------------------------

In the Naming Style | Advanced settings ... | Add a user defined naming style.

In Affected entities select Method and Test method (property).

In Access rights select Public.

In Static/non-static select Instance members and locals.

Ensure that Enable inspections is not checked.

-----------------------------------------------------------------------------------------------------------------

This makes ReSharper check exactly the rules around underscores that I prefer. It is pretty flexible, so it can probably be set up for almost any taste.

/Brian

0

Please sign in to leave a comment.