Ordering Aspects

In the documentation it states: 'Aspects must be ordered using the AspectOrderAttribute assembly-level custom attribute. The order of the aspect classes in the attribute corresponds to their order of execution. using Metalama.Framework.Aspects; [assembly: AspectOrder( typeof(Aspect1), typeof(Aspect2), typeof(Aspect3))] ' From that I read this as meaning that Aspect1 will be executed, after which Aspect 2 will be executed after which Aspect 3 will be executed. This is the Log output from a sample I have built, reversing the execution of the Aspects: The bit that is of interest is at the bottom of both logs, which, to me at least makes no sense if the statement in the docs is accurate.
5 Replies
domsinclair
domsinclair2y ago
[assembly: AspectOrder(typeof(TimedLogMethodAttribute), typeof(RetryAttribute))] 10:40:14.424 +01:00 [Information] Application Starting 10:40:14.565 +01:00 [Information] Entering Calculator.Subtract with these parameters: {"Type = double: Parameter Name = a": 3, "Type = double: Parameter Name = b": 2} 10:40:14.591 +01:00 [Information] Leaving Calculator.Subtract with the following result: 1 10:40:14.598 +01:00 [Information] Calculator.Subtract took 6 ms to complete. 10:40:14.601 +01:00 [Information] Entering Calculator.Multiply with these parameters: {"Type = double: Parameter Name = a": 3, "Type = double: Parameter Name = b": 2} 10:40:14.606 +01:00 [Information] Leaving Calculator.Multiply with the following result: 6 10:40:14.608 +01:00 [Information] Calculator.Multiply took 1 ms to complete. 10:40:14.626 +01:00 [Information] Entering Calculator.Add with these parameters: {"Type = double: Parameter Name = a": 3, "Type = double: Parameter Name = b": 2} 10:40:14.770 +01:00 [Error] An error thrown by retry attribute, Calculator.Add has failed withe the following error System.InvalidOperationException: Operation is not valid due to the current state of the object. at VtlSoftware.MultiAspects.ConsoleApp.Calculator.<>cDisplayClass2_0.<Add>gExecuteCore|0() in D:\source\repos\VtlSoftware.MultiAspectSolution\VtlSoftware.MultiAspects.ConsoleApp\Calculator.cs:line 28
domsinclair
domsinclair2y ago
Hopefully that has come through, turns ourt that a 2000 character limit can be a little limiting!
Gael Fraiteur
Gael Fraiteur2y ago
What seems illogical to you exactly? I checked your project and it seems to behave as designed.
domsinclair
domsinclair2y ago
What seemed illogical were the error messages. I guess I would have expected two in the first and just one in the second.
Gael Fraiteur
Gael Fraiteur2y ago
You can always debug the transformed code to understand the flow.
Want results from more Discord servers?
Add your server