You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The DefaultBuildStrategyCompiler uses type on ExecuteOrderRules to identify the ordering of evaluation by property type. The DefaultExecuteStrategy uses the rules against the property type so this works as intended.
The expression extension methods however use the owning type of the property to register a rule. This work syntactically but is very broken when the rule is used by DefaultExecuteStrategy.
For example:
public static partial class Create
{
public static T Model<T>()
{
var compiler = ModelBuilder.Model.BuildStrategy.Clone();
compiler.AddExecuteOrderRule<Skill>(x => x.YearStarted, 4000);
compiler.AddExecuteOrderRule<Skill>(x => x.YearLastUsed, 3000);
compiler.AddValueGenerator<YearInPastValueGenerator>();
var builder = compiler.Compile();
return builder.Create<T>();
}
}
This should add order rules such that YearStarted is evaluated first and YearLastUsed is evaluated afterwards. The bug is that AddExecuteOrderRule creates an order rule against typeof(Skill) instead of typeof(int?) which is the property type determined from the expression.
Both scenarios are valid cases. There should be the option to target the ExecuteOrderRule against a property type as well as owning type of the property. This would cater for being able to run strings after enums for example, while also using expressions to target specific properties.
The text was updated successfully, but these errors were encountered:
roryprimrose
changed the title
AddExecuteOrderRule<T> registers order against T instead of expression property type
Interpretation of Type on ExecuteOrderRule is confusing and used in two different ways
Aug 8, 2017
* Updated ExecuteOrderRule internals to support an declaring type.
* Added overloads to ExecuteOrderRule to work with both declaringType and propertyType.
* Updated DefaultExecuteStrategy to provide declaring type as well as property type to ExecutionOrderRule.
* Updated BuildStrategyCompilerExtensions to correctly create ExecuteOrderRule from an expression.
Fixes#48
The DefaultBuildStrategyCompiler uses type on ExecuteOrderRules to identify the ordering of evaluation by property type. The DefaultExecuteStrategy uses the rules against the property type so this works as intended.
The expression extension methods however use the owning type of the property to register a rule. This work syntactically but is very broken when the rule is used by DefaultExecuteStrategy.
For example:
This should add order rules such that YearStarted is evaluated first and YearLastUsed is evaluated afterwards. The bug is that AddExecuteOrderRule creates an order rule against typeof(Skill) instead of typeof(int?) which is the property type determined from the expression.
Both scenarios are valid cases. There should be the option to target the ExecuteOrderRule against a property type as well as owning type of the property. This would cater for being able to run strings after enums for example, while also using expressions to target specific properties.
The text was updated successfully, but these errors were encountered: