vescon / MethodBoundaryAspect.Fody

A Fody weaver which allows to decorate methods and hook into method start, method end and method exceptions.
MIT License
243 stars 75 forks source link

Throwing "Failed to execute weaver" exception on 1 (out of 19) VB project #119

Open BRR-LASERS opened 1 year ago

BRR-LASERS commented 1 year ago

The project that is failing is the one where I implement the Attribute(s) that inherit from MethodBoundaryAspect. All of the projects are VB, Framework 4.8. When I do a rebuild solution (Visual Studio 2022), I get this exception:

Error: Fody: An unhandled exception occurred: Exception: Failed to execute weaver E:\LASERS\SOLARIS\Dev\SOLARIS\packages\MethodBoundaryAspect.Fody.2.0.149\build..\weaver\MethodBoundaryAspect.Fody.dll Type: System.Exception StackTrace: at InnerWeaver.ExecuteWeavers() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 222 at InnerWeaver.Execute() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 112 Source: FodyIsolated TargetSite: Void ExecuteWeavers() Object reference not set to an instance of an object. Type: System.NullReferenceException StackTrace: at MethodBoundaryAspect.Fody.ModuleWeaver.IsMethodBoundaryAspect(TypeDefinition attributeTypeDefinition) at MethodBoundaryAspect.Fody.ModuleWeaver.IsMethodBoundaryAspect(CustomAttribute customAttribute) at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext() at System.Collections.Generic.List1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at MethodBoundaryAspect.Fody.ModuleWeaver.WeaveType(ModuleDefinition module, TypeDefinition type, Collection1 assemblyMethodBoundaryAspects) at MethodBoundaryAspect.Fody.ModuleWeaver.WeaveTypeAndNestedTypes(ModuleDefinition module, TypeDefinition type, Collection`1 assemblyMethodBoundaryAspects) at MethodBoundaryAspect.Fody.ModuleWeaver.Execute(ModuleDefinition module) at MethodBoundaryAspect.Fody.ModuleWeaver.Execute() at InnerWeaver.ExecuteWeavers() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 186 Source: MethodBoundaryAspect.Fody TargetSite: Boolean IsMethodBoundaryAspect(Mono.Cecil.TypeDefinition)

I immediately do a build and the project succeeds. I also have MethodTimer installed in that same project and it seems to be fine. I have insured that the FodyWeavers.xml has the proper entries and that the (old style) project file has the vb references.

What am I missing?

BRR-LASERS commented 1 year ago

After refactoring and moving the Attribute definitions to their own project AND giving that project an empty FodyWeavers.xml for that project AND correcting some obvious issues in the old format VBPROJ file for the one that's failing, now I'm getting the following:

Error: Fody: An unhandled exception occurred: Exception: Failed to execute weaver E:\LASERS\SOLARIS\Dev\SOLARIS\packages\MethodBoundaryAspect.Fody.2.0.149\build..\weaver\MethodBoundaryAspect.Fody.dll Type: System.Exception StackTrace: at InnerWeaver.ExecuteWeavers() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 222 at InnerWeaver.Execute() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 112 Source: FodyIsolated TargetSite: Void ExecuteWeavers() Unable to find variable reference for storage. Type: System.InvalidOperationException StackTrace: at MethodBoundaryAspect.Fody.CecilExtensions.GetLocalStoredByInstruction(Instruction i, Collection1 locals) at MethodBoundaryAspect.Fody.AsyncMethodWeaver.WeaveOnException(IList1 allAspects, Instruction instructionCallStart, Instruction instructionCallEnd, Instruction instructionAfterCall, IPersistable returnValue) at MethodBoundaryAspect.Fody.MethodWeaver.Weave() at MethodBoundaryAspect.Fody.ModuleWeaver.WeaveMethod(ModuleDefinition module, MethodDefinition method, List1 aspectInfos, MethodInfoCompileTimeWeaver methodInfoCompileTimeWeaver) at MethodBoundaryAspect.Fody.ModuleWeaver.WeaveType(ModuleDefinition module, TypeDefinition type, Collection1 assemblyMethodBoundaryAspects) at MethodBoundaryAspect.Fody.ModuleWeaver.WeaveTypeAndNestedTypes(ModuleDefinition module, TypeDefinition type, Collection1 assemblyMethodBoundaryAspects) at MethodBoundaryAspect.Fody.ModuleWeaver.Execute(ModuleDefinition module) at MethodBoundaryAspect.Fody.ModuleWeaver.Execute() at InnerWeaver.ExecuteWeavers() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 186 Source: MethodBoundaryAspect.Fody TargetSite: Mono.Cecil.Cil.VariableDefinition GetLocalStoredByInstruction(Mono.Cecil.Cil.Instruction, Mono.Collections.Generic.Collection1[Mono.Cecil.Cil.VariableDefinition])

Same line numbers, but the message now says: Unable to find variable reference for storage.

I'm kind of at wits end....