Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weaving Exception on Async WinForm Event handlers #72

Open
kampilan opened this issue Feb 18, 2020 · 3 comments
Open

Weaving Exception on Async WinForm Event handlers #72

kampilan opened this issue Feb 18, 2020 · 3 comments
Labels
async for async issues bug

Comments

@kampilan
Copy link

I am wanting to use this addin to support automatic logging using my logging framework. So far it works great except for this edge case.

Async WinForm event handlers have the signature of private async void SomeEvent( object sender )

This is an odd signature, notice they don't return Task, and I assume this is being treated as invalid.

These methods throw an InvalidOperationException during build as follows

Error Fody: An unhandled exception occurred:
Exception:
Failed to execute weaver F:\repositories\fabrica-script\packages\MethodBoundaryAspect.Fody.2.0.118\build..\weaver\MethodBoundaryAspect.Fody.dll
Type:
System.Exception
StackTrace:
at InnerWeaver.ExecuteWeavers() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 206
at InnerWeaver.Execute() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 111
Source:
FodyIsolated
TargetSite:
Void ExecuteWeavers()
Async state machine for System.Void Fabrica.Script.MainView::WhenRunCommandClicked(System.Object,DevExpress.XtraBars.ItemClickEventArgs) did not catch exceptions in the expected way.
Type:
System.InvalidOperationException
StackTrace:
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)
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 178
Source:
MethodBoundaryAspect.Fody
TargetSite:
Void WeaveOnException(System.Collections.Generic.IList`1[MethodBoundaryAspect.Fody.AspectData], Mono.Cecil.Cil.Instruction, Mono.Cecil.Cil.Instruction, Mono.Cecil.Cil.Instruction, MethodBoundaryAspect.Fody.IPersistable) Fabrica.Script

@Ralf1108
Copy link
Collaborator

Support for async was implemented by @keith-anders and we are not experienced enough to implement the IL Code for the async state machine.
It seems that method with signature "async void" are not supported.
I don't see a corresponding test in AsyncClass.cs.

@kampilan
Copy link
Author

Thanks for the response. I have seen you mention on other issues that @keith-anders is the person that did all the async stuff. I can't say I remember him chiming in on any of those issues. Is he still actively involved in the project?

@Ralf1108 Ralf1108 added bug async for async issues labels Sep 30, 2020
@Ksdmg
Copy link

Ksdmg commented Nov 18, 2021

I'm facing the same issue. Would be awesome if someone could provide a solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
async for async issues bug
Projects
None yet
Development

No branches or pull requests

3 participants