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

Support for AsyncVoidMethodBuilder, AsyncValueTaskMethodBuilder and AsyncIteratorMethodBuilder #122

Open igitur opened 11 months ago

igitur commented 11 months ago

Hi,

I noticed that in https://github.com/vescon/MethodBoundaryAspect.Fody/blob/1c94babb56aedcede20b1616f527576bac5a0579/src/MethodBoundaryAspect.Fody/AsyncMethodWeaver.cs#L223 only AsyncTaskMethodBuilder is supported. This causes MethodBoundaryAspect.Fody to choke on some other async methods.

e.g. if I have a class:

[MyAspect]
public class AsyncClass
{
    public async void MyVoidMethod()
    {
        await Task.Delay(10);
    }

    public async ValueTask<int> MyValueTask()
    {
        await Task.Delay(10);
        return 10;
    }    
}

TODO: I still have to add an example for Async iterators, but I think you'll get the idea.

I can try my hand at a PR, but just want to check whether support for these are deliberately omitted or any pitfulls that I should be aware of.

Ralf1108 commented 11 months ago

Hi @igitur, we would welcome PR if they improve the MBA. The support for async methods where done by @keith-anders and unfortunatly he is not active anymore. So I am not aware of any reasons why it was not included. Maybe there wasn't a need for it. Please feel free to improve the support for async methods.