pamidur / aspect-injector

AOP framework for .NET (c#, vb, etc)
Apache License 2.0
772 stars 115 forks source link

Unsupported language/version ? #214

Open manson opened 1 year ago

manson commented 1 year ago

Environment:

I have an ASP.NET big application with multiple sub projects (libraries). I have implemented a separate library Tracing with all aspects and attributes implementation. Next I have added reference to this project from main app and started testing, It worked well until I have finished the needed logic and applied attributes to all the classes I need to intercept behavior with AspectInjector. And after spending the whole day doing this, I got next error on building my app.

7>AspectInjector|2.8.1 : error AI_ERR0: Processing failure: System.InvalidOperationException: Expected sequence is not found even once. Unsupported language/version ?
7>     at FluentIL.MethodEditor.OnEveryOccasionOf(MethodBody body, Func`2 predicate, PointCut pc, Instruction startingFrom)
7>     at FluentIL.MethodEditor.OnCall(MethodBody body, MethodReference method, PointCut pc, Instruction startingFrom)
7>     at AspectInjector.Core.Advice.Weavers.Processes.AfterAsyncWeaveProcess.FindOrCreateAfterStateMachineMethod()
7>     at AspectInjector.Core.Advice.Weavers.Processes.AfterStateMachineWeaveProcessBase.Execute()
7>     at AspectInjector.Core.Advice.Weavers.AdviceStateMachineWeaver.WeaveMethod(MethodDefinition method, InjectionDefinition injection)
7>     at AspectInjector.Core.Advice.Weavers.AdviceInlineWeaver.Weave(InjectionDefinition injection)
7>     at AspectInjector.Core.Processor.PatchAssembly(AssemblyDefinition assembly, Boolean optimize, Boolean verbose)
7>     at FluentIL.PatcherBase.Process(String assemblyFile, IAssemblyResolver resolver, Boolean optimize, Boolean verbose)
7>     at FluentIL.PatcherBase.Process(String assemblyFile, IReadOnlyList`1 references, Boolean optimize, Boolean verbose)
7>     at AspectInjector.Compiler.Execute(String filename, IReadOnlyList`1 references, Boolean optimize, Boolean verbose). Please submit an issue to https://github.com/pamidur/aspect-injector
7>AspectInjector : error AI_FAIL: Aspect Injector processing has failed. See other errors.

The same for 2.8.2

7>AspectInjector|2.8.2 : error AI_ERR0: Processing failure: System.InvalidOperationException: Expected sequence is not found even once. Unsupported language/version ?
7>     at FluentIL.MethodEditor.OnEveryOccasionOf(MethodBody body, Func`2 predicate, PointCut pc, Instruction startingFrom)
7>     at FluentIL.MethodEditor.OnCall(MethodBody body, MethodReference method, PointCut pc, Instruction startingFrom)
7>     at AspectInjector.Core.Advice.Weavers.Processes.AfterAsyncWeaveProcess.FindOrCreateAfterStateMachineMethod()
7>     at AspectInjector.Core.Advice.Weavers.Processes.AfterStateMachineWeaveProcessBase.Execute()
7>     at AspectInjector.Core.Advice.Weavers.AdviceStateMachineWeaver.WeaveMethod(MethodDefinition method, InjectionDefinition injection)
7>     at AspectInjector.Core.Advice.Weavers.AdviceInlineWeaver.Weave(InjectionDefinition injection)
7>     at AspectInjector.Core.Processor.PatchAssembly(AssemblyDefinition assembly, Boolean optimize, Boolean verbose)
7>     at FluentIL.PatcherBase.Process(String assemblyFile, IAssemblyResolver resolver, Boolean optimize, Boolean verbose)
7>     at FluentIL.PatcherBase.Process(String assemblyFile, IReadOnlyList`1 references, Boolean optimize, Boolean verbose)
7>     at AspectInjector.Compiler.Execute(String filename, IReadOnlyList`1 references, Boolean optimize, Boolean verbose). Please submit an issue to https://github.com/pamidur/aspect-injector
7>AspectInjector : error AI_FAIL: Aspect Injector processing has failed. See other errors.

Don't know even what to think.

UPD. I don't know what happened (I spent a day finding error reason) but everything has fixed after I have added the new subproject (class library) into the solution for testing, applied attributes to it, built. It built ok, but after I checked the main project and it built as well! Now everything works well - I cleanup solution, rebuild and it works... Don't know what to think. Hope later it wont face the same issue...

UPD No, it do not work. It just reference to aspect library in this project dropped and hence was not doing any injection and so build without errors....

UPD Figured out where this happened, but not why. This is an ordinary class where putting attributes on it raising that error. I have about 30 classes with this aspect attributes and similar classes and only on this class it breaks. Cannot get how it differ from others. Temporarilly removed attributes from this class, let it be unwachable for a while. If you have any ideas whould be greatfull...

pamidur commented 1 year ago

Hey @manson , thatnk you for the report and sorry for the delay. Would it be possible to share the code of the affected classs?