GetDynamicMemberNames() doesn't provide much info

Nov 4, 2009 at 10:27 PM

I was reading a draft of a book covering C# 4.0 and it gives an example of using GetDynamicMemberNames to return the list of XElement names for a DynamicObject implementation that wraps an XML file.  The idea was that REPL environments like Python can query the member names to provide Intellisense.  I get this feature all the time in PowerShell where, if I have created the object, PoweShell can reflect upon the instance and provide Intellisense.  If these environments encounter a DynamicObject instance then clearly the data return via reflection isn't very useful.  I thought GetDynamicMemberNames() was the way I could write my object to interact better in these other REPL environments. 

BTW the Intellisense capability *could* be made available in C# - in theory.  The C# compiler,while doing a background compile, would need to create an instance of the object - or better yet - create an instance of a metaobject ie an object that *just* describes the runtime type info for the dynamic object.  This metaobject should have no destructive side effects but it probably would need some extra info.  Like the XML wrapper would need the path to the XML file.  Plus to get a really good Intellisense experience the DynamicObject (or metaobject) needs to be able to return much richer info: member description, parameter information, parameter description, return type, etc.

Thoughts?

Coordinator
Nov 5, 2009 at 1:04 AM

You’re absolutely correct about what this method is for.  IronPython also uses it for the dir() function for displaying what members are available and I believe the VS debugger also uses it for displaying members.

I think the biggest problem w/ intellisense is that C# doesn’t know either type of the normal object or the type of the meta object.  If you solve knowing the type of the normal object it also still doesn’t give you the meta object because the object could be doing something wacky in its IDMOP implementation (e.g. conditionally returning different kinds of meta objects).  And even if you could somehow make a meta objects for a lot of meta objects this would be insufficient because the members are determined at runtime – ExpandoObject is a good example of this.

So it’s tough problem that probably needs different solutions for different types of objects/meta objects and cooperation between them and whatever language is doing intellisense.

From: r_keith_hill [mailto:notifications@codeplex.com]
Sent: Wednesday, November 04, 2009 2:28 PM
To: Dino Viehland
Subject: GetDynamicMemberNames() doesn't provide much info [dlr:74111]

From: r_keith_hill

I was reading a draft of a book covering C# 4.0 and it gives an example of using GetDynamicMemberNames to return the list of XElement names for a DynamicObject implementation that wraps an XML file. The idea was that REPL environments like Python can query the member names to provide Intellisense. I get this feature all the time in PowerShell where, if I have created the object, PoweShell can reflect upon the instance and provide Intellisense. If these environments encounter a DynamicObject instance then clearly the data return via reflection isn't very useful. I thought GetDynamicMemberNames() was the way I could write my object to interact better in these other REPL environments.

BTW the Intellisense capability *could* be made available in C# - in theory. The C# compiler,while doing a background compile, would need to create an instance of the object - or better yet - create an instance of a metaobject ie an object that *just* describes the runtime type info for the dynamic object. This metaobject should have no destructive side effects but it probably would need some extra info. Like the XML wrapper would need the path to the XML file. Plus to get a really good Intellisense experience the DynamicObject (or metaobject) needs to be able to return much richer info: member description, parameter information, parameter description, return type, etc.

Thoughts?

Read the full discussion online.

To add a post to this discussion, reply to this email (dlr@discussions.codeplex.com)

To start a new discussion for this project, email dlr@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Nov 5, 2009 at 5:20 AM

Yeah I get the issue with expando objects.  It will be interesting to see how the C# team can narrow the gap between the current edit-compile-debug environment and REPL environments that are much better suited to using dynamic types.

Coordinator
Nov 6, 2009 at 4:34 PM

I think you're right, and when C# gets a REPL, certainly looking at doing some live intellisense (from objects in the execution environment) would make that experience better.

Bill

From: r_keith_hill [mailto:notifications@codeplex.com]
Sent: Wednesday, November 04, 2009 9:20 PM
To: Bill Chiles
Subject: Re: GetDynamicMemberNames() doesn't provide much info [dlr:74111]

From: r_keith_hill

Yeah I get the issue with expando objects. It will be interesting to see how the C# team can narrow the gap between the current edit-compile-debug environment and REPL environments that are much better suited to using dynamic types.

Read the full discussion online.

To add a post to this discussion, reply to this email (dlr@discussions.codeplex.com)

To start a new discussion for this project, email dlr@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com