Suppress custom inspection pattern when it occurs inside try-catch block

I want to write a pattern for a custom inspection that warns me if I use something like

   int.Parse(text)

in my C# code if it is not wrapped inside a try-catch block.

I.e. no warning should occur for

   try
   {
      ...
      int val = int.Parse(text);
      ...
   }
   catch (FormatException ex)
   {
       ...
   }

Is that possible using ReSharper?

Regards
- Frank

1 comment
Comment actions Permalink

Hello
     Such scenario is not possible with custom search and replace patterns. However, you can still write a small ReSharper plug-in that will have the necessary logic. Thank you!

Andrey Serebryansky

Software Developer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"

0

Please sign in to leave a comment.