If multiple attributes are applied to a member, e.g.
[Foo]
[Bar]
void Baz() { ... }
Then are any guarantees made by the CLR/.NET specifications as to what order they will be retrieved in when retrieved by reflection (e.g. Attribute.GetCustomAttributes
)? The documentation for these methods does not make it explicit, and while it does seem to be the case that they are returned in the order they are applied, I don't want to rely on undocumented behaviour as that's just asking for trouble.
As for why this might be important, imagine the attributes are used to indicate that the method should have a series of interceptors, which should run in a specific order.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…