MethodBoundaryAspect.Fody icon indicating copy to clipboard operation
MethodBoundaryAspect.Fody copied to clipboard

Weaving fails with aspect inheritance

Open rualmar opened this issue 7 years ago • 1 comments

I have a situation where I want to implement 2 aspects: one to log exceptions and other to log and swallow them. Initially I had implemented them this way

public class LogExceptionAndThrowAttribute : OnMethodBoundaryAspect
{
        public override void OnException(MethodExecutionArgs arg)
        {
             //Log exception
        }
}

public class LogExceptionAndSwallowAttribute : LogExceptionAndThrowAttribute
{
        public override void OnException(MethodExecutionArgs arg)
        {
             base.OnExcpetion(arg); //log exception using base method

            //Set arg.returnvalue and FlowBehavior
        }
}

The problem is that when I build the project, I get this error:

Exception: Sequence contains no matching element at System.Linq.Enumerable.Single[TSource](IEnumerable1 source, Func2 predicate) at ModuleWeaver.WeaveRealmObjectHelper(TypeDefinition realmObjectType) at ModuleWeaver.Execute() at lambda_method(Closure , Object ) at InnerWeaver.ExecuteWeavers() at InnerWeaver.Execute()

I implemented both aspects separately and now it works. I wanted to know if that's the expected behavior or it's an unexpected error.

Thank you.

rualmar avatar Sep 04 '18 08:09 rualmar

seems like a bug

Ralf1108 avatar Sep 05 '18 11:09 Ralf1108