I've started using the .Net Complier Platform (Roslyn) to assist with enforcing coding standards.
One issue I'm struggling with is discovering and catching useless try...catch
blocks.
For example:
// Would like to have this detected and offer to remove the try...catch
try
{
// Do some work
}
catch(Exception ex)
{
throw ex;
}
It would be good to also detect the fact that the code is using throw ex;
rather than just throw;
such as:
try
{
// So some work
}
catch(Exception ex)
{
// Log the error or anything to manage the exception
throw ex; // <-- how to detect and offer a fix for this
}