-Fixed dynamic property getter type information

This commit is contained in:
James Newton-King
2016-05-01 17:23:48 +12:00
parent b71ca75905
commit e31200aead
2 changed files with 19 additions and 1 deletions
@@ -175,6 +175,24 @@ namespace Newtonsoft.Json.Tests.Utilities
JsonSerializerTest.DictionaryKey key = (JsonSerializerTest.DictionaryKey)result;
Assert.AreEqual("First!", key.Value);
}
[Test]
public void CreatePropertyGetter()
{
PropertyInfo namePropertyInfo = typeof(Person).GetProperty(nameof(Person.Name));
Assert.IsNotNull(namePropertyInfo);
var call = DynamicReflectionDelegateFactory.Instance.CreateGet<Person>(namePropertyInfo);
Person p = new Person();
p.Name = "Name!";
object result = call(p);
Assert.IsNotNull(result);
Assert.AreEqual("Name!", (string)result);
}
}
}