Bug/101
@@ -1083,6 +1083,21 @@ namespace Jint.Tests.Runtime
assert(x === null);
");
}
+
+ [Fact]
+ public void ShouldSetPropertyToNull()
+ {
+ var p = new Person { Name = "Mickey" };
+ _engine.SetValue("p", p);
+ RunTest(@"
+ assert(p.Name != null);
+ p.Name = null;
+ assert(p.Name == null);
+ ");
+ Assert.True(p.Name == null);
+ }
@@ -38,7 +38,7 @@ namespace Jint.Runtime.Descriptors.Specialized
{
// attempt to convert the JsValue to the target type
obj = currentValue.ToObject();
- if (obj.GetType() != _propertyInfo.PropertyType)
+ if (obj != null && obj.GetType() != _propertyInfo.PropertyType)
obj = _engine.ClrTypeConverter.Convert(obj, _propertyInfo.PropertyType, CultureInfo.InvariantCulture);