Class
YamlSerializerContext
OfficeIMO.Yaml
The base of generated serialization metadata. Declare a partial class that derives from it and lists its root types with YamlSerializableAttribute; the source generator fills in metadata for those types and every type they reach, so serialization needs no reflection and works with trimming and NativeAOT.
Inheritance
- object
- YamlSerializerContext
Usage
Explore 4 API references to this type
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Accepted by parameters 4
- Method YamlSerializer.Deserialize
- Method YamlSerializer.Serialize
- Method YamlSerializer.SerializeToNode
- Method YamlSerializer.SerializeToUtf8Bytes
Examples
[YamlSerializable(typeof(AppConfig))]
internal partial class AppYamlContext : YamlSerializerContext { }
string yaml = YamlSerializer.Serialize(config, AppYamlContext.Default.AppConfig);
AppConfig? copy = YamlSerializer.Deserialize(yaml, AppYamlContext.Default.AppConfig);Methods
public YamlTypeInfo? GetTypeInfo(Type type) #Returns the metadata for type bound to YamlSerializerContext.Options, or null when the context does not include it.
Parameters
- type System.Type
Returns
YamlTypeInfo?Inherited Methods
Properties
public YamlSerializerOptions Options { get; } #Gets the options the context's metadata is bound to.