Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostSharp Conflicting Aspects warning

I'm using PostSharp Express in VS2013 to create validation aspects which I can apply to my properties. I followed this PostSharp guide on location interception. They all work well but I am getting hundreds of warnings stating:

Conflicting aspects on "MyNamespace.get_MyProperty": transformations ".MyValidation1Attribute: Intercepted by advice OnGetValue, OnSetValue" and "MyNamespace.Validation2Attribute: Intercepted by advice OnGetValue, OnSetValue" are not commutative, but they are not strongly ordered. Their order of execution is undeterministic.

Which I think is a result of my placing multiple validation aspects on the same properties. First I tried to comma-separate the attributes, which I understand is supposed to order them: [Validation1,Validation2] but the warnings still remained.

Since my aspects are commutative (it doesn't matter which order they are executed), the PostSharp docs advise to mark them as such using AspectTypeDependency as follows:

[AspectTypeDependency(AspectDependencyAction.Commute, typeof(ILocationValidationAspect))]

However, it appears that the PostSharp.Aspects.Dependencies namespace is not included under the Express license. Is there any possible solution to resolving these warnings using only the Express license? Or does this mean I can't ever use more than one aspect without buying pro or ultimate? I would be willing to try to implement my own dependency controller if I could remove these warnings this way.

like image 283
08Dc91wk Avatar asked May 29 '15 15:05

08Dc91wk


1 Answers

AspectTypeDependency requires Professional edition. But the AspectTypeDependency type should be included even in Express edition - there should be using non-licensed feature build time error then.

You can use AspectPriority:

[Validation1(AspectPriority = 1), Validation2(AspectPriority = 2)]

Alternatively you can assign the priority in aspect constructor. It is much less flexible than aspect ordering but at least it resolves the warning.

like image 55
Jakub Linhart Avatar answered Sep 23 '22 01:09

Jakub Linhart