开发者

How to add custom code analysis in ReSharper

I'm new to ReSharper. For those who uses Resharper, is there a way I can add custom cod开发者_StackOverflowe 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?


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.


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/


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜