We are using ClearScript in our application as a replacement for the MS Script Control (to enable users to run custom scripts interfacing with an application-provided object), and we've encountered an issue involving legacy behaviour with retrieving default property values, where those objects are .NET objects.
The situation we encountered involved VBScript accessing a DAO-like object:
Something = rs.Fields("something")
where rs.Fields is a method returning an IEnumerable object (a "Fields" object). The object returned by the Fields object (the "Field" object) has a default property as so:
[DispId(0)]
public object Value
{
get { .... }
set { .... }
}
The enumeration is working fine, but the default property would not be identified as such. The VBScript engine was actually looking for "[DISPID=0]", but ClearScript wasn't checking the DispId attribute. The attached patch adds support to check for the DispId attribute.
The attached patch fixes the getting; setting unfortunately still doesn't work with this fix, but we worked around that in our application. (If you have any idea how to fix it in ClearScript as well though, I'm sure that would be useful!)
Hope this is useful, and that my fix is correct!
Thanks, Owen.
Comments: Fixed in [Version 5.4.2](https://clearscript.codeplex.com/SourceControl/changeset/bfd06449d9e70818985d855319b7bc3a955313aa).
The situation we encountered involved VBScript accessing a DAO-like object:
Something = rs.Fields("something")
where rs.Fields is a method returning an IEnumerable object (a "Fields" object). The object returned by the Fields object (the "Field" object) has a default property as so:
[DispId(0)]
public object Value
{
get { .... }
set { .... }
}
The enumeration is working fine, but the default property would not be identified as such. The VBScript engine was actually looking for "[DISPID=0]", but ClearScript wasn't checking the DispId attribute. The attached patch adds support to check for the DispId attribute.
The attached patch fixes the getting; setting unfortunately still doesn't work with this fix, but we worked around that in our application. (If you have any idea how to fix it in ClearScript as well though, I'm sure that would be useful!)
Hope this is useful, and that my fix is correct!
Thanks, Owen.
Comments: Fixed in [Version 5.4.2](https://clearscript.codeplex.com/SourceControl/changeset/bfd06449d9e70818985d855319b7bc3a955313aa).