How to add custom code analysis in ReSharper

情到浓时终转凉″ 提交于 2019-12-12 10:37:17

问题


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?


回答1:


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.




回答2:


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/




回答3:


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.



来源:https://stackoverflow.com/questions/2264335/how-to-add-custom-code-analysis-in-resharper

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!