开发者

C# 4: Determining parameter passing semantics in dynamic calls

开发者 https://www.devze.com 2022-12-20 18:26 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号