ArxOne / MrAdvice

.NET aspect weaver (build task under NuGet package)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IMethodInfoAdvice invocation clarification

wilhelmmedetz opened this issue · comments

Considering the following example:

public class Advice1Attribute: IMethodInfoAdvice, IMethodAdvice ...
public class Advice2Attribute: IMethodInfoAdvice, IMethodAdvice ...

[Advice1, Advice2]
public void Foo() ...

Are both IMethodInfoAdvice.Advise() methods always invoked before any IMethodAdvice.Advise() method is invoked?
Are IMethodInfoAdvice.Advise() methods always invoked once and only once?
Are these assumptions also true for multi-threaded scenarios?

Thanks

Wilhelm

Hi Wilhelm,

advices with the same priority are run in random order. If you want to ensure the're run in a specific order, you need to use the [Priority] attribute on them.
Let me know if this work (to me it works, but someone reported an issue, numbered #145 about it)

Hi Pascal,

thanks for your response.

As IMethodInfoAdvice.Advise() is always invoked before the static class constructor is invoked, the above assumptions always hold. This clarified my question.