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

CLR Wrappers with ObjectInstances

Feb 10, 2012 at 11:20 AM
Edited Feb 10, 2012 at 2:21 PM

Hello all,

Let's say I have a WrapperObjectInstance : ObjectInstance.

This WrapperObjectInstance wraps a CLR Object and is a proxy called from scripts.

I'd like to do the following:

public override object GetProperty(string propertyName) {

    return wrappedObj[propertyName];


public override void SetProperty(string propertyName, object value) {

    wrappedObj[propertyName] = value;


Any chance to override the behaviour of ObjectInstance?



Edit: I think I found an overridable SetProperty (blind as a bat), but what about GetProperty? Is it the ObjectInstance.DefineProperty method, actually?

Edit 2: not quite sure about the SetProperty method as it has an index param (I expected a string with the parameter name).

Feb 11, 2012 at 4:05 AM
Edited Feb 11, 2012 at 4:05 AM

There's no supported way of doing this, unfortunately.  There are multiple places in which properties are read and multiple places in which they are created/modified.  Optimized code doesn't even always call a method to read a property.


If you know the list of properties on the target object you can create getters and setters to do what you want.

Strangely, I've been reading up on a feature in the upcoming version of JavaScript (proxies) that does exactly what you want.  Not sure when/if that'll get into Jurassic though.

Feb 11, 2012 at 12:01 PM

Hello Paul, thanks for your answer.


Best regards,