How do I express a void method call as the result of DynamicMetaObject.BindInvokeMember?

This is similar to:

DLR return type

You do need to match the return type specified by the ReturnType property. For all of the standard binaries this is fixed to object for almost everything or void (for the deletion operations). If you know you’re making a void call I’d suggest wrapping it in:

Expression.Block(
    call,
    Expression.Default(typeof(object))
);

The DLR used to be quite lax about what it would allow and it would provide some minimal amount of coercion automatically. We got rid of that because we didn’t want to provide a set of convensions which may or may not have made sense for each language.

It sounds like you want to prevent:

dynamic x = obj.SomeMember();

There’s no way to do that, there’ll always be a value returned that the user can attempt to continue to interact with dynamically.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)