KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have just downloaded the trial of Resharper 7.1. My goal is to enforce a rule where our custom logger must be used on all catch blocks within our c# code-base. Example; try{ // Any amount of code } catch(Exception e){ } should be illegal, however: try{ // Any amount of code } catch(Exception e){ Logger.LogException(e.Message, e); } is perfectly acceptable. To this end, I have the following pattern set up to detect and re-factor. Search pattern: try{ $anystatements$ } catch($exceptiontype$ $exceptionarg$){ $anycatchstatements$ } Replace pattern: try{ $anystatements$ } catch($exceptiontype$ $exceptionarg$){ Logger.LogException($exceptionarg$.Message, $exceptionarg$) $anycatchstatements$ } Resharper is detecting the smells fine, but is treating the replace pattern as a smell in itself as the added line for Logging is being matched by $anycatchstatement$ placeholder. How can I define a placeholder to describe "match any number of statements in the catch block which are NOT calls to custom logger, and simply append a call to the logger"?
Tags (comma-separated)
Save Edits
Cancel