[英]How can i find all empty catch with resharper?
I know that there is the possibility to use search pattern but I don't know how to implement this feature我知道可以使用搜索模式,但我不知道如何实现此功能
You can mark any code in Visual Studio and then click, for example the empty try-catch, then go您可以在 Visual Studio 中标记任何代码,然后单击,例如空的 try-catch,然后单击 go
Now resharper created a pattern for you matching that code:现在 resharper 为您创建了一个匹配该代码的模式:
try
{
$statement$
}
catch ($Exception$ $e$)
{
}
You can edit it or add new placeholders and save it, then click Find.您可以编辑它或添加新的占位符并保存它,然后单击“查找”。
In this case it might be a good idea to add another pattern that matches also empty catch blocks that have no Exception
parameter:在这种情况下,添加另一个匹配没有Exception
参数的空 catch 块的模式可能是个好主意:
try
{
$statement$
}
catch
{
}
By the way, this matches also if the catch contains comments like顺便说一下,如果 catch 包含类似的评论,这也会匹配
// don't do anything
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.