9

I'm new to ReSharper. For those who uses Resharper, is there a way I can add custom code analysis rules?

For example I might have a rule say All private variables should start with letter "m". How can I add this to Resharper so if I violate this, it can shows as a warning or an error?

2
  • 3
    Which source language, and which version of R#? In 4.5, for example, this kind of thing can be done in R# | Options | Languages | Naming Style
    – AakashM
    Commented Feb 15, 2010 at 12:12
  • Sorry, should have explained this a bit more :) It is R# 5.0 Beta. I guess R# 5.0 should do the same thing what you explained in 4.5. I'll check this out - Thanks
    – Rajithakba
    Commented Feb 16, 2010 at 3:05

3 Answers 3

5

I know the question is old, but for all folks coming from google like me:

Resharper -> Options -> Code inspections -> Custom Patterns

There you can create your own rules for highlighting patterns or offering substitutions. This is for ReSharper 8. I'm not sure from which version this option is there.

4

Just to expand on what @AakashM notes above: this can be specified in ReSharper Options | Languages | (either Common or C# or whatever) | Naming Style.

If you click on Advanced Settings, and then double-click on one of the "entity descriptions", there is a far larger selection of possible entities (including events, namespaces etc) , together with access rights (private, protected, etc) and so on, for which you can define prefix, suffix and casing rules.

4

You can write your own plugins for ReSharper. Take a look at here:

http://stylecopforresharper.codeplex.com/

This is similar to what you're asking for. It might even do what you want. Not sure since I'm not a big StyleCop user.

Also take a look at the first in my series of blog posts coming on ReSharper plugins:

http://hadihariri.com/2010/01/12/writing-plug-ins-for-resharper-part-1-of-undefined/

Not the answer you're looking for? Browse other questions tagged or ask your own question.