c# - Custom inspection pattern for catch block logging -
i have downloaded trial of resharper 7.1. goal enforce rule our custom logger must used on catch blocks within our c# code-base. example;
try{ // amount of code } catch(exception e){ } should illegal, however:
try{ // amount of code } catch(exception e){ logger.logexception(e.message, e); } is acceptable. end, have following pattern set detect , re-factor.
search pattern:
try{ $anystatements$ } catch($exceptiontype$ $exceptionarg$){ $anycatchstatements$ } replace pattern:
try{ $anystatements$ } catch($exceptiontype$ $exceptionarg$){ logger.logexception($exceptionarg$.message, $exceptionarg$) $anycatchstatements$ } resharper detecting smells fine, treating replace pattern smell in added line logging being matched $anycatchstatement$ placeholder.
how can define placeholder describe "match number of statements in catch block not calls custom logger, , append call logger"?
unfortunatley no, i'm using resharper 8 eap (http://confluence.jetbrains.com/display/resharper/resharper+8+eap) , still don't has such option.
provably should take on code contracts, or http://www.postsharp.net/ or similar.
also vladimir reshetnikov right - team can lot. can easy contact them trough email or web form. have devs, , company allows direct communications customers. russia :)
Comments
Post a Comment