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

InvalidOperationException is thrown by .Single call when there's an aspect inheritance

Open hasanmanzak opened this issue 2 years ago • 2 comments

InvalidOperationException: Sequence contains no matching element exception is thrown when I create another inheritable class from OnMethodBoundaryAspect:

public abstract class MethodBoundaryAspect : OnMethodBoundaryAspect
{
   // some stuff
}

public class Log: MethodBoundaryAspect 
{
   // some other stuff
}

Offending lines:

https://github.com/vescon/MethodBoundaryAspect.Fody/blob/1c94babb56aedcede20b1616f527576bac5a0579/src/MethodBoundaryAspect.Fody/InstructionBlockChainCreator.cs#L116-L117

That approach forces the inheritance to have only single descendent. But through out the source that is solved with

https://github.com/vescon/MethodBoundaryAspect.Fody/blob/1c94babb56aedcede20b1616f527576bac5a0579/src/MethodBoundaryAspect.Fody/ReferenceFinder.cs#L22-L34

Yes, it can be done by mimicing that approach, but not importing the reference, in chain creator but using an already provided api is much cleaner, I suppose..

I'll be opening a PR for this, if that's ok.

hasanmanzak avatar Sep 03 '23 22:09 hasanmanzak

Nice catch ! Could you provide a unittest/repo to avoid future regression bugs?

Ralf1108 avatar Sep 04 '23 16:09 Ralf1108

Yes, of course! I'll be adding to my repo related to pr.

hasanmanzak avatar Sep 05 '23 08:09 hasanmanzak