pamidur / aspect-injector

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

NullReferenceException during compilation #171

Closed Janek91 closed 2 years ago

Janek91 commented 2 years ago

That kind of exception is randomly thrown during compilation when I try to debug application. When I run only build - it compiles successfully. I need to make an irrelevant change in any .cs file and then it runs fine for a while. AspectInjector|2.6.1 : error AI_ERR0: Processing failure: System.NullReferenceException: Object reference not set to an instance of an object. [PATH_TO_CSPROJ_FILE] at Mono.Cecil.Cil.InstructionCollection.ResolveInstructionOffset(InstructionOffset inputOffset, InstructionOffsetCache& cache) at Mono.Cecil.Cil.InstructionCollection.UpdateLocalScope(ScopeDebugInformation scope, Instruction removedInstruction, Instruction existingInstruction, InstructionOffsetCache& cache) at Mono.Cecil.Cil.InstructionCollection.UpdateLocalScopes(Instruction removedInstruction, Instruction existingInstruction) at Mono.Cecil.Cil.InstructionCollection.OnRemove(Instruction item, Int32 index) at Mono.Collections.Generic.Collection`1.Remove(T item) at AspectInjector.Core.Advice.Weavers.Processes.AdviceAroundProcess.MoveBody(MethodDefinition from, MethodDefinition to) at AspectInjector.Core.Advice.Weavers.Processes.AdviceAroundProcess.WrapEntryPoint(MethodDefinition unwrapper) at AspectInjector.Core.Advice.Weavers.Processes.AdviceAroundProcess.GetOrCreateUnwrapper() at AspectInjector.Core.Advice.Weavers.Processes.AdviceAroundProcess.GetNextWrapper() at AspectInjector.Core.Advice.Weavers.Processes.AdviceAroundProcess.Execute() at AspectInjector.Core.Advice.Weavers.AdviceAroundWeaver.WeaveMethod(MethodDefinition method, InjectionDefinition injection) at AspectInjector.Core.Advice.Weavers.AdviceInlineWeaver.Weave(InjectionDefinition injection) at AspectInjector.Core.Processor.PatchAssembly(AssemblyDefinition assembly, Boolean optimize, Boolean verbose) at FluentIL.PatcherBase.Process(String assemblyFile, IAssemblyResolver resolver, Boolean optimize, Boolean verbose) at FluentIL.PatcherBase.Process(String assemblyFile, IReadOnlyList`1 references, Boolean optimize, Boolean verbose) at AspectInjector.Compiler.Execute(String filename, IReadOnlyList`1 references, Boolean optimize, Boolean verbose). Please submit an issue to https://github.com/pamidur/aspect-injector AspectInjector : error AI_FAIL: Aspect Injector processing has failed. See other errors. [PATH_TO_CSPROJ_FILE]

pamidur commented 2 years ago

hi @Janek91 , thank you for the report. Any chance we can have a snippet of code that causing this? Should be somewhere where you use Kind.Around aspect. Also could you please give us the following info:

Janek91 commented 2 years ago

MobileAppAspect.cs.zip

pamidur commented 2 years ago

It looks like Xamarin has some fake methods that have to body. I could fix it fast, if you could provide more complete example. It will take some time other wise

pamidur commented 2 years ago

Hey @Janek91 , i was trying reproduce this issue without success, could you please give me more complete example?

pamidur commented 2 years ago

Hey @Janek91 , please check latest versions and see if it fixes the issue. If it is no the case, please reopen this ticket!