Denis535
Denis535

Reputation: 3600

PostSharp: Why LogAttribute hasn't advices?

I use ILSpy to explore LogAttribute class. But I can't understand how does it work?

As I understand there are two way to create aspect:

1) High-level: OnMethodBoundaryAspect, OnExceptionAspect, MethodInterceptionAspect, LocationInterceptionAspect, EventInterceptionAspect.

2) Low-level: MethodLevelAspect with On***Advice attributes.

But LogAttribute doesn't use neither first nor second case. LogAttribute extends MethodLevelAspect but hasn't advices. So, how does it work?

Upvotes: 2

Views: 42

Answers (1)

AlexD
AlexD

Reputation: 5101

The two approaches to create an aspect described in the question are the ones that are supported and documented. However, on a lower level PostSharp SDK matches an interface implemented by an aspect class to a weaver class. The selected weaver then handles the IL-weaving of the target code element.

The base classes for aspects (e.g. OnMethodBoundaryAspect) and for advices (e.g. OnMethodEntryAdvice) are provided to make the implementation of the common aspects more convenient. The use case of creating a custom aspect weaver from scratch is currently not supported for end users as of PostSharp 6.1.

Upvotes: 1

Related Questions