Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# 4: Determining parameter passing semantics in dynamic calls

Tags:

c#

dynamic

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.

like image 640
Fake Jim Avatar asked Nov 06 '22 16:11

Fake Jim


1 Answers

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.

like image 102
Alexandra Rusina Avatar answered Nov 12 '22 19:11

Alexandra Rusina