Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Usage of AspectPriority

I'm using PostSharp 2.1.5.1 and had a warning today:

Aspect dependencies (defined on "MyNamespace.MyAspect.MyVerificationAttribute") will be disabled from the Starter Edition in future versions. Use the AspectPriority property instead.

Seems to me that following line is causing that warning:

[AspectRoleDependency(AspectDependencyAction.Order, AspectDependencyPosition.After, StandardRoles.Tracing)]

Could someone point me to a correct example of how to use AspectPriority? Are the following examples up to date?

  • http://www.sharpcrafters.com/blog/post/introducing-postsharp-2-0-3-aspect-dependencies.aspx (section "Old Good Aspect Priority")

  • http://www.sharpcrafters.com/blog/post/Day-3-Applying-Aspects-with-Multicasting-Part-2.aspx (section "Aspect Priority")

Thanks.

like image 216
Akim Avatar asked Oct 10 '22 14:10

Akim


1 Answers

The correct usage is AttributePriority. Lower values are higher priority, or aspects that get applied first.

[Trace(AttributePriority = 2)]
[HandleError(AttributePriority = 1)]
public void MyMethod()
{

}

Aspect Priority hasn't been valid for a while. AspectDependencyAction determines the "priority" between two aspects. Meaning, if Aspect1 depends on Aspect2 then and the AspectDependencyAction.Order = After then Aspect1 gets applied after Aspect2 has been applied. but that isn't what you are looking for (I think). Just use AttributePriority instead.

like image 96
Dustin Davis Avatar answered Oct 13 '22 11:10

Dustin Davis