C# 强制运算符?
我得到了这个测试:
[Fact]
public void EverythingIsMappedJustFine(){
new AutoMapperTask().Execute();
Mapper.AssertConfigurationIsValid();
}
它抛出了一个有点奇怪的异常:
测试“Unit.Web.Bootstrap.AutoMapperFacts.EverythingIsMappedJustFine”失败:
System.InvalidOperationException:未定义强制运算符
类型“System.Void”和“System.Object”之间。
在System.Linq.Expressions.Expression.GetUserDefinedCoercionOrThrow(ExpressionType coercionType,表达式表达式,类型convertToType)
...
在 AutoMapper.DelegateFactory.CreateGet(MethodInfo 方法)
不幸的是 - 我无法以较小的规模重现这一点,并且无法弄清楚到底发生了什么。
什么是强制运算符?
这可能有用。但我未能提取和简化必要的信息位。
I got this test:
[Fact]
public void EverythingIsMappedJustFine(){
new AutoMapperTask().Execute();
Mapper.AssertConfigurationIsValid();
}
It throws a bit strange exception:
Test 'Unit.Web.Bootstrap.AutoMapperFacts.EverythingIsMappedJustFine' failed:
System.InvalidOperationException : No coercion operator is defined
between types 'System.Void' and 'System.Object'.
at System.Linq.Expressions.Expression.GetUserDefinedCoercionOrThrow(ExpressionType coercionType, Expression expression, Type convertToType)
...
at AutoMapper.DelegateFactory.CreateGet(MethodInfo method)
Unfortunately - I couldn't reproduce this on smaller scale and can't figure out what exactly is going on.
What is coercion operator?
This might be useful. But I'm failing to extract and dumb down necessary information bits.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我仍然不知道强制运算符到底是什么,但至少 -
我解决了我的问题找到了原因。经过一些自动映射器调试后,能够重现问题:
事实证明非常简单 - 源具有与目标属性一样命名的方法。
I still don't know what exactly is coercion operator, but at least -
I solved my problemfound reason.After some automapper debugging was able to reproduce problem:
Quite simple as it turns out - source has method which is named just like destination property.