Conflicting aspects - not commutative, not strongly ordered

remi+sharpcrafters's Avatar

remi+sharpcrafters

04 Dec, 2017 01:13 PM

Paid licence, using version 5.0.39.

I'm applying the provided NotNullAttribute to two method parameters, as well as my own aspect on the method itself. When I build, I get the "Conflicting aspects on [method]: transformations "PostSharp.Patterns.Contracts.NotNullAttirbute: Validates the value passed to parameter 'repoFactory'" and [MyAttribute][: Wrapped by advice(s) OnEntry" are not commutative, but they are not strongly ordered. Their order of execution is undeterministic."

I've tried using an ordering aspect on the attibute, without success. (I may have done it wrong.)

I've also tried assigning an AttributePriority in my aspect class's constructor, but I'm still getting the same warning.

A little help?

  1. Support Staff 1 Posted by PostSharp Techn... on 05 Dec, 2017 06:56 PM

    PostSharp Technologies's Avatar

    Hello,

    In such cases the best approach usually is to decorate your aspect with one of the dependency attributes:

    • AspectTypeDependencyAttribute
    • AspectRoleDependencyAttribute
    • AspectEffectDependencyAttribute

    In your case you can apply the following attribute to order your aspect after any code contract aspect:

    
    [AspectRoleDependency( AspectDependencyAction.Order, AspectDependencyPosition.After, StandardRoles.Validation )]
    public class MyAspectAttribute : OnMethodBoundaryAspect
    {
       // ...
    }
    

    You can find more information in our documentation: http://doc.postsharp.net/aspect-dependencies

    -alex

  2. 2 Posted by remi+sharpcraft... on 07 Dec, 2017 01:06 PM

    remi+sharpcrafters's Avatar

    Thank you.

  3. PostSharp Technologies closed this discussion on 07 Dec, 2017 01:41 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac