This project has moved. For the latest updates, please go here.

TypeConverter.ToObject method cannot handle CLR type


--- Steps to reproduce
  1. Setup ObjectInstance with a property pointing to a CLR type.
  2. Prepare JS which tries to use the CLR type.
--- Observed behavior:

The execution fails with error:

Cannot convert object of type '...' to an object. Parameter name: value
at Jurassic.TypeConverter.ToObject(ScriptEngine engine, Object value, Int32 lineNumber, String sourcePath, String functionName)

--- Expected behavior

The execution should succeed.

I believe the TypeConverter.ToObject method is incomplete. When the passed value is CLR type it fails. I think the method should be extended with the following code to be able to handle CLR types:
if (!(value is ObjectInstance))
   return new ClrInstanceWrapper(engine, value);