If you’re doing BDD-style specifications and using underscores within your variable names, the default Resharper settings will warn you about violating the naming style rules as shown below:
Fortunately, Machine.Specifications (MSpec) extends Resharper to allow for the creation of custom rules which affect only your MSpec types. To create a custom rule for MSpec, follow these steps:
Step 1: Open the Resharper Options Dialog.
Step 2: Navigate to Languages | Naming Style and under “User defined naming rules” click “Add”.
Step 3: This displays the “Edit Extended Naming Rule dialog. In the “Rule Definition:” text box, give your new rule a name such as “Machine.Specifications Rules”.
Step 4: Within the Affected entities list, un-check Class and scroll to the bottom to locate the entries starting with Machine.Specifications. Select all of these entries.
Step 5: Select all options under Access rights: and leave options under Static/non-static: selected.
Step 6: Add a new naming style to associate this rule to by clicking the Add icon and selecting the desired naming style (e.g. all_lower).
The following diagram shows the dialog after these steps:
Fortunately, Machine.Specifications (MSpec) extends Resharper to allow for the creation of custom rules which affect only your MSpec types. To create a custom rule for MSpec, follow these steps:
Step 1: Open the Resharper Options Dialog.
Step 2: Navigate to Languages | Naming Style and under “User defined naming rules” click “Add”.
Step 3: This displays the “Edit Extended Naming Rule dialog. In the “Rule Definition:” text box, give your new rule a name such as “Machine.Specifications Rules”.
Step 4: Within the Affected entities list, un-check Class and scroll to the bottom to locate the entries starting with Machine.Specifications. Select all of these entries.
Step 5: Select all options under Access rights: and leave options under Static/non-static: selected.
Step 6: Add a new naming style to associate this rule to by clicking the Add icon and selecting the desired naming style (e.g. all_lower).
The following diagram shows the dialog after these steps:
After selecting OK, Resharper now ignores the naming warnings for the MSpec types:



Thanks, it really helped.
I just had to add warning 169 to suppressed list in project’s properties so it does not complain about delegates not being used (context, of).
[...] As everything always is done by someone before, I’m only going to give you a link to the solution: http://www.aspiringcraftsman.com/2010/02/resharper-naming-style-for-machine-specifications/ [...]
I was elated to find your post.
But it’s not working for me. I have triple verified that I did it exactly as you show. I suspended/re-enabled ReSharper and even closed and reopened the solution. The custom rule is having no effect. The only difference I can see is that I’m using RS 5.1. Any ideas?
I figured out the problem. Under Naming Style for C#, I had “Override common settings” checked. I solved it by creating the customer rule under C# instead of common.
I apologize for just approving these today. For some reason your comments got flagged as spam.
Hi Derek,
This is just what I was looking for
I also had the same issue as Tim and had to add the rule into the C# section as well. I think this might be something to do with having StyleCop for Resharper installed but I’m not 100% sure.
Chris
No it’s nothing to do with the StyleCop for Resharper as I don’t have it on my computer.
What’s the VS style you are using called? Thanks.