Search code examples
c#deserializationyamldotnet

How do you deserialize static properties with YamlDotNet?


I'm having trouble deserializing yaml into static properties. When I try, I get the exception System.Runtime.Serialization.SerializationException: Property 'Test' not found on type 'Program+Config'. This seems weird to me because I was successfully doing this before with a static IEnumerable of my objects (I needed to reorganize my file so I can't do this any more). Has anyone successfully been able to do this?

A minimal example showing the problem:

    public static void Main()
    {
        var test = new Deserializer().Deserialize<Config>("Test: Value");
    }

    public class Config
    {
        public static string Test { get; set; }
    }

Solution

  • You can't do that. This is not somethig that YamlDotNet supports and there are no plans to support it.