I\'m trying to give a short example of IDynamicMetaObjectProvider for the second edition of C# in Depth, and I\'m running into issues.
I want to be able to express a voi
I don't like this, but it seems to work; the real problem seems to be the binder.ReturnType
coming in oddly (and not being dropped ("pop") automatically), but:
if (target.Type != binder.ReturnType) {
if (target.Type == typeof(void)) {
target = Expression.Block(target, Expression.Default(binder.ReturnType));
} else if (binder.ReturnType == typeof(void)) {
target = Expression.Block(target, Expression.Empty());
} else {
target = Expression.Convert(target, binder.ReturnType);
}
}
return new DynamicMetaObject(target, restrictions);