PostSharp冲突方面警告 [英] PostSharp Conflicting Aspects warning

查看:118
本文介绍了PostSharp冲突方面警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在VS2013中使用PostSharp Express创建可应用于我的属性的验证方面.我遵循了此有关位置拦截的PostSharp指南.它们都工作良好,但我收到数百条警告,指出:

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:

"MyNamespace.get_MyProperty"上相互矛盾的方面:转换 ".MyValidation1Attribute:被通知OnGetValue拦截, OnSetValue"和"MyNamespace.Validation2Attribute:被以下对象拦截" 通知OnGetValue,OnSetValue"不是可交换的,但它们不是 强烈下令.他们的执行顺序不确定.

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.

我认为这是由于我在同一属性上放置了多个验证方面的结果.首先,我尝试用逗号分隔属性,据我了解应该按顺序对这些属性进行排序:[Validation1,Validation2],但警告仍然存在.

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))]

但是,PostSharp.Aspects.Dependencies名称空间似乎没有包含在Express许可证下.是否有任何可能的解决方案,仅使用Express许可证即可解决这些警告?还是这意味着我不购买专业版或旗舰版就不能使用多个方面?如果我可以通过这种方式删除这些警告,我将愿意尝试实现自己的依赖项控制器.

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.

推荐答案

AspectTypeDependency需要专业版.但是,即使在Express版本中也应包括AspectTypeDependency类型-然后应该使用非许可功能构建时间错误.

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.

您可以使用AspectPriority:

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.

这篇关于PostSharp冲突方面警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆