anakic / Jot

Jot is a library for persisting and applying .NET application state.
http://www.codeproject.com/Articles/475498/Easier-NET-settings
MIT License
633 stars 56 forks source link

Nested object #58

Closed bcssov closed 2 years ago

bcssov commented 2 years ago

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) https://github.com/anakic/Jot/blob/488b9e70493c060dca5b4e1fd75d561f7cceda27/Jot/Configuration/TrackingConfiguration.cs#L111

I'm required to implement IConvertible?

anakic commented 2 years ago

@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)?

anakic commented 2 years ago

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

bcssov commented 2 years ago

Works fine, closing.