-
Notifications
You must be signed in to change notification settings - Fork 78
Description
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:
MethodBoundaryAspect.Fody/src/MethodBoundaryAspect.Fody/InstructionBlockChainCreator.cs
Lines 116 to 117 in 1c94bab
| var onEntryMethodTypeRef = | |
| anyAspectTypeDefinition.Resolve().BaseType.Resolve().Methods.Single(AspectMethodCriteria.IsOnEntryMethod); |
That approach forces the inheritance to have only single descendent. But through out the source that is solved with
MethodBoundaryAspect.Fody/src/MethodBoundaryAspect.Fody/ReferenceFinder.cs
Lines 22 to 34 in 1c94bab
| public MethodReference GetMethodReference(TypeReference typeReference, Func<MethodDefinition, bool> predicate) | |
| { | |
| var typeDefinition = typeReference.Resolve(); | |
| MethodDefinition methodDefinition; | |
| do | |
| { | |
| methodDefinition = typeDefinition.Methods.FirstOrDefault(predicate); | |
| typeDefinition = typeDefinition.BaseType?.Resolve(); | |
| } while (methodDefinition == null && typeDefinition != null); | |
| return _moduleDefinition.ImportReference(methodDefinition); | |
| } |
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.