Reputation: 7589
I've seen that PostSharp has now introduced support for async methods on the the OnMethodBoundary aspect base class via the AllowStateMachine=true property.
I have two related questions:
Can this property be set on the OnExceptionAspect or should I change my aspect to extend OnMethodBoundaryAspect instead?
What is the difference between the OnExceptionAspect and the OnMethodBoundaryAspect? Should I just always use the OnMethodBoundary?
Upvotes: 2
Views: 428
Reputation: 5101
State machines are currently supported only with OnMethodBoundaryAspect, so you would need to derive from that class.
OnExceptionAspect is more convenient when you need to handle different types of exceptions in different ways. You can specify the exception type to catch in OnExceptionAspect.GetExceptionType() method or in OnExceptionAspectConfiguration.ExceptionType property.
OnMethodBoundaryAspect allows you to hook into other method boundaries like entry and exit, however it always catches the base Exception
type in the catch block.
Upvotes: 2