PostSharp Conflicting Aspects warning
Asked Answered
K

1

5

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.

Keil answered 29/5, 2015 at 15:20 Comment(0)
M
7

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.

Multiplicand answered 4/6, 2015 at 8:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.