I have inherited some legacy code that has every single method flanked with a:
Method()
{
Log("Entering");
...
Log("Exiting");
}
sort of thing. It’s ugly and Does indeed Repeat Myself about a thousand times. Is there a way to add a global “around_filter” like the one found in Rails?
This can be done via Aspect Oriented Programming via an aspect weaving tool like PostSharp. In the case of PostSharp, the OnMethodBoundaryAspect provides this type of functionality.