vescon / MethodBoundaryAspect.Fody

A Fody weaver which allows to decorate methods and hook into method start, method end and method exceptions.
MIT License
243 stars 75 forks source link

Some enhancement ideas #82

Open jmartschinke opened 3 years ago

jmartschinke commented 3 years ago

It seems to me that many of the currently active issues arise because of the cloning of the original method. There is also still some missing debug information in certain circumstances, which I will report later. I tried to change it locally so that instead of weaving like this:

OnEntry();
try
{
    $_executor_Foo();
}
catch (Exception ex)
{
    OnException();
}
OnExit();

this would be woven:

OnEntry();
try
{
    // content of foo directly here instead of a call
}
catch (Exception ex)
{
    OnException();
}
OnExit();

I could only partially get that to work. The OnEntry() and the content of the Method get called, but OnExit() is not and i cannot get the decompiled sources.

Perhaps we could work together to look into this solution?

Ralf1108 commented 3 years ago

The original design choice was to move the original method into another method and just call it. As we are no MSIL expert we didn't want to complicate the weaving process. But you are right, this messes up the debug informations.

If you need help can you specify what exact problem you encounter?