I have implemented several "stock" Microsoft Code Analysis rules. However they were lacking in one area that they didn't have detection in a catch to see if logging was implemented.
So my test project has these two methods. I would expect to see one of them raise my custom error while the other passes.
public void CatchTestNoLogging()
{
try
{ string A = "adsf"; }
catch (Exception ex)
{ throw; }
}
public void CatchTestLogging()
{
try
{ string A = "adsf"; }
catch (Exception ex)
{
log.Error("Test Error");
throw;
}
}
My custom rule is able to detect if there is a catch but I can't see how I detect if the Logging is used?
This is a SNIP of the custom rule:
if (iList[i].OpCode == OpCode._Catch)
{
isCatchExists = true; //this gets hit as I want
//so the question is what can I do to detect if logging is implemented in the catch?
}
Just a quick pointer on how I access would be great. Thank You