-
-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AutoMapper tests are failing when using FEC #196
Comments
I found the issue here. Here's a failing expression: var expression = Lambda<Func<Source, Dest, ResolutionContext, Dest>>(
Block(
Condition(
Equal(srcParam, Constant(null)),
Default(typeof(Dest)),
Block(typeof(Dest), new[] {typeMapDestParam},
Assign(typeMapDestParam, Coalesce(destParam, New(typeof(Dest).GetConstructors()[0]))),
TryCatch(
/* Assign src.Value */
Block(resolvedValueParam,
Block(
Assign(resolvedValueParam,
Condition(Or(Equal(srcParam, Constant(null)), Constant(false)),
Default(typeof(int)),
Property(srcParam, "Value"))
),
Assign(Property(typeMapDestParam, "Value"), resolvedValueParam)
)
),
Catch(exceptionParameter, Block(
Throw(New(constructorInfo,
Constant("Error mapping types."),
exceptionParameter,
Constant(typeMap.Types),
Constant(typeMap),
Constant(memberMap)
)
),
Default(typeof(int))
))
),
typeMapDestParam
)
)
),
srcParam,
destParam,
Parameter(typeof(ResolutionContext), "ctxt")
); Note that my The fix is to make the var expression = Lambda<Func<Source, Dest, ResolutionContext, Dest>>(
Block(
Condition(
Equal(srcParam, Constant(null)),
Default(typeof(Dest)),
Block(typeof(Dest), new[] {typeMapDestParam},
Assign(typeMapDestParam, Coalesce(destParam, New(typeof(Dest).GetConstructors()[0]))),
TryCatch(
/* Assign src.Value */
Block(typeof(void), new[] {resolvedValueParam},
Block(
Assign(resolvedValueParam,
Condition(Or(Equal(srcParam, Constant(null)), Constant(false)),
Default(typeof(int)),
Property(srcParam, "Value"))
),
Assign(Property(typeMapDestParam, "Value"), resolvedValueParam)
)
),
Catch(exceptionParameter,
Throw(New(constructorInfo,
Constant("Error mapping types."),
exceptionParameter,
Constant(typeMap.Types),
Constant(typeMap),
Constant(memberMap)
)
)
)
),
typeMapDestParam
)
)
),
srcParam,
destParam,
Parameter(typeof(ResolutionContext), "ctxt")
); Which makes more sense, but the C# expression compiler handled this scenario fine. Relevant StackOverflow question: https://stackoverflow.com/questions/14365122/expression-convert-within-expression-trycatch |
… and true constants singletons; TBD: look to try catch upped language to 7.3
@jbogard Thanks for pointing it out! I am slowly moving towards the fix optimizing some things on the way. |
fixed. at least this case. |
There is still a lot to fix in #222 |
closing, the remaining work is in #222 |
AutoMapper issue AutoMapper/AutoMapper#3103 (comment)
The text was updated successfully, but these errors were encountered: