Here is what to include in your request to make sure we implement a solution as quickly as possible.
1. Description
DynamicClass throws exception when serializing to Json.
2. Exception
NullReferenceException
3. Fiddle or Project
using Newtonsoft.Json;
using System.Linq.Dynamic.Core;
using System.Text.Json.Serialization;
DynamicProperty[] props = new DynamicProperty[] { new DynamicProperty("Name", typeof(string)), new DynamicProperty("Birthday", typeof(DateTime)) };
Type type = DynamicClassFactory.CreateType(props);
DynamicClass dynamicClass = Activator.CreateInstance(type) as DynamicClass;
dynamicClass.SetDynamicPropertyValue("Name", "Albert");
dynamicClass.SetDynamicPropertyValue("Birthday", new DateTime(1879, 3, 14));
Console.WriteLine(dynamicClass);
JsonConvert.SerializeObject(dynamicClass);
Console.ReadLine();
4. Any further technical details
It seems the issue has been fixed in this commit.
This commit has been done a few minutes before creating release 1.2.20 but it is actually not part of that release.
Not sure if this was on purpose but it would be really nice if a new release could be made that includes the bugfix.
Here is what to include in your request to make sure we implement a solution as quickly as possible.
1. Description
DynamicClass throws exception when serializing to Json.
2. Exception
NullReferenceException
3. Fiddle or Project
4. Any further technical details
It seems the issue has been fixed in this commit.
This commit has been done a few minutes before creating release 1.2.20 but it is actually not part of that release.
Not sure if this was on purpose but it would be really nice if a new release could be made that includes the bugfix.