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
The C# binder (in Microsoft.CSharp.dll) knows whether or not the result is used; as x0n (+1) says, it keeps track of it in a flag. Unfortunately, the flag is buried inside a CSharpInvokeMemberBinder
instance, which is a private type.
It looks like the C# binding mechanism uses ICSharpInvokeOrInvokeMemberBinder.ResultDiscarded
(a property on an internal interface) to read it out; CSharpInvokeMemberBinder
implements the interface (and property). The job appears to be done in Microsoft.CSharp.RuntimeBinder.BinderHelper.ConvertResult()
. That method has code that throws if the aforementioned ResultDiscarded
property doesn't return true if the type of the expression is void.
So it doesn't look to me like there's an easy way to tease out the fact that the result of the expression is dropped from the C# binder, in Beta 2 at least.