Proposal: Typed dynamics #1678
Replies: 6 comments
-
Beta Was this translation helpful? Give feedback.
-
Thanks for links. #969 and #284 looks like mine but lacking of motivation/explanation. |
Beta Was this translation helpful? Give feedback.
-
.NET Core has |
Beta Was this translation helpful? Give feedback.
-
Thanks for suggestion @BhaaLseN! It looks like |
Beta Was this translation helpful? Give feedback.
-
Would this apply to a Thus far I've had to rely on |
Beta Was this translation helpful? Give feedback.
-
If you mean open generic type like void Foo<T1,T2>()
{
dynamic<MyGenericType<T1,T2>> x = ... ;
x.Bar();
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Brief
Allow to specify expected type for
dynamic
types to IDE support (suggestions, syntax highlight) and improve performance in some cases.Motivation
After RIP'ing remoting infrastructure in .NET Core DLR and
dynamic
remained the only mechanism for implementing transparent proxies to objects. CurrentDynamicObject
features are enough to replace theRealProxy
in the field, but lacking of suggestions from IDE during development somehow frustrating.Suggestion
Allow to specify expected type for 'dynamic' types like this
dynamic<T>
. This will not change how dynamic is treated by compiler/runtime and would produce same IL as before except new metadata (DynamicTypeAttribute or so...).Also when some member is invoked
InvokeMemberBinder
should provide suggestedMemberInfo
which member is invoked on expected type. This is only hint for some one who implementingIDynamicMetaObjectProvider
but potentially could lead to performance boost if right type is hit (by omitting whole "binding" part). Same for other binders.Type of
dynamic
should be propagated after invocations:And erased where ambiguity is involved.
Generics should be supported too, because creating a proxy almost always involve a generic method:
Breaking changes
None as I see.
Alternatives
a) Custom post-processing IL or source code for "proxy" types:
b) Dynamic proxies with overridden members like NHIbernate proxies.
Beta Was this translation helpful? Give feedback.
All reactions