C# 4: Determining parameter passing semantics in dynamic calls

谁说我不能喝 提交于 2019-12-10 14:33:48

问题


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) but 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.


回答1:


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.



来源:https://stackoverflow.com/questions/2268857/c-sharp-4-determining-parameter-passing-semantics-in-dynamic-calls

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!