添加自定义编译错误,在Visual Studio中
问题描述:
我试图找到一种方式来定制的代码错误添加到Visual Studio添加自定义编译错误,在Visual Studio中
例如
我想,以防止对字符串使用==
操作的参数 和执行使用字符串的equals方法,而不是
所以,如果一个程序员会写下面的代码
string myString = ....
if(myString == "the string") - this line will have a compilation error
有什么想法?
答
我找到了这样做的一个很好的方式,使用ReSharper的 与自定义模式
https://blog.jetbrains.com/dotnet/2010/08/19/highlighting-custom-patterns-with-resharper/
定制罗斯林代码分析器_probably_可能会有帮助,但它不是一项容易的任务来实现:https://开头msdn.microsoft.com/en-us/magazine/dn879356.aspx –