anakic/Jot

Nested object

bcssov opened this issue · 3 comments

I'm not sure if this was supported or not but I had a nested object which was serialized and stored in my settings. An example

public class Settings
{
	[Track]
	public int Prop1 {get; set;]
	
	[Track]
	public NestedObject Prop2 {get; set;]
}

public class NestedObject
{
	public int Prop1 {get; set;]
	
	public int Prop12 {get; set;]
}

Up until 2.11.12 I was using it without any problems. But with this line change Convert.ChangeType(v, pi.PropertyType)

TrackedProperties[pi.Name] = new TrackedPropertyInfo(x => pi.GetValue(x), (x, v) => pi.SetValue(x, Convert.ChangeType(v, pi.PropertyType)));

I'm required to implement IConvertible?

@bcssov hm, I did add that Convert.ChangeType() call in that version, but I can't reproduce your error with the code sample you provide. If I change the type of Settings.Prop2 from NestedObject to object I can reproduce the error, though. Was this the case in your code (i.e. the property type was a base type of the value)?

@bcssov new version (2.1.13) pushed to github and nuget. Can you confirm if it solves this bug for you?

Works fine, closing.