C#: Find all empty catch blocks

前端 未结 9 1291
逝去的感伤
逝去的感伤 2020-12-23 22:08

I am reviewing some code.

I have notice some empty catch blocks. Not a good idea since somethings do not work and you cannot see why.

Is there an easy way to

相关标签:
9条回答
  • 2020-12-23 23:05

    Press Ctrl + Shift + F. Expand Find options. Check Use Regular Expressions Paste this regex.

    catch\s*(\(\s*Exception(\s*\w+)?\))?\s*\{\s*\}
    
    0 讨论(0)
  • 2020-12-23 23:07

    Do you have ReSharper? This should hilight the issues found in code.

    0 讨论(0)
  • 2020-12-23 23:11

    FxCop will find them along with many other potential issues.

    0 讨论(0)
提交回复
热议问题