C# 4: Determining parameter passing semantics in dynamic calls
In C# 4, when deriving from DynamicObject and overridding TryInvokeMember, how can one determine whether any parameters supplied at the call site have been passed with out or ref semantics? I can see some private fields in the supplied binder that contain this information (namely the Microsoft.CSharp.RuntimeBinder.ICSharpInvokeOrInvokeMemberBinder.ArgumentInfo property) bu开发者_如何学Got it appears to be inaccessible. I assume this information must be available somewhere otherwise it would limit one's knowledge of supplied input pretty severely.
I talked to the DLR team about that. Unfortunately, the answer is no, this information is not available for DynamicObject.
The reason is that ref/out parameters are very C# specific. And dynamic objects can be shared between many languages and not all langauges have these notations. DynamicObject is "call-by-value", so your objects can be consumed by different APIs.
精彩评论