This project has moved and is read-only. For the latest updates, please go here.

.Net Default Property Recognition

Aug 14, 2014 at 11:02 PM
From my testing so far I've noticed that default properties are not being recognized as such when added to the script engine context via some object - take a look at Item property of Dictionary for example. Although it's not a major problem, it could lead to some unexpected errors during testing. Is there any way you could add a support for a default property recognition to the script engine?

P.S. Please ignore this post if this is already addressed in newer version of ClearScript library.
Coordinator
Aug 15, 2014 at 4:01 AM
Hi maxshakirov,

Is there any way you could add a support for a default property recognition to the script engine?

Could you please clarify your expectations for this feature? That is, how would you expect it to change the way default properties are exposed and/or consumed? What new capabilities would it enable, if any?

Thanks!
Aug 15, 2014 at 2:46 PM
Edited Aug 15, 2014 at 2:48 PM
The expectation is the same as it is in the .Net framework. Consider following example:
Using engine As New V8ScriptEngine(V8ScriptEngineFlags.DisableGlobalMembers, V8ScriptEngineFlags.EnableDebugging, 9222)
            engine.AddHostType("console", GetType(Console))
            engine.AddHostObject("testDict", New Dictionary(Of String, String) From {{"a", "1"}})
            engine.Evaluate("console.WriteLine('testElement = {0};', testDict.Item('a')); console.WriteLine('');")
End Using
In the code above I'm simply outputting a value of the dictionary item found by key, testDict.Item('a'). Note that .Item is a default property in case of dictionary, so I was expecting I can do the following (the only difference is how I'm trying to access the dictionary item):
...
engine.Evaluate("console.WriteLine('testElement = {0};', testDict('a')); console.WriteLine('');")
...
For me this is not a big deal in particular, it's just the observation of behavior vs. the expectation on my end.
Coordinator
Aug 17, 2014 at 7:49 PM
Hi maxshakirov,

Thanks for clarifying. Your feature request seems reasonable; we're tracking it here.

Cheers!
Aug 19, 2014 at 3:37 PM
Thank you as well.