Skip to content

hozuki/YamlDotNet.DataContract

Repository files navigation

YamlDotNet.DataContract

An inspector for YamlDotNet that processes DataMemberAttribute/IgnoreDataMemberAttribute instead of YamlMemberAttribute/YamlIgnoreAttribute.

Usage

var builder = new DeserializerBuilder();
var deserializer = builder
    .WithTypeInspector(inspector => new DataContractTypeInspector(inspector) {
        DataMemberSerialization = DataMemberSerialization.OptIn,
        // Since custom type inspectors are added after the built-in ones, they cannot pass their results
        // to the built-in ones, e.g. NamingConventionTypeInspector (responsible for the WithNamingConvention
        // method).
        // The naming convention must be assigned here if there is one, not using WithNamingConvention().
        NamingConvention = new UnderscoredNamingConvention(),
        CacheResults = true, // default
        IncludeNonPublicMembers = false // default
    })
    .IgnoreUnmatchedProperties()
    .Build();

Limitations

  • IsRequired, EmitDefaultValue and Order of DataMemberAttribute are ignored.

License

MIT

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages