YamlSerializableAttribute Class

Declares a root type for a source-generated YamlSerializerContext.

[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
public sealed class YamlSerializableAttribute : YamlAttribute

Remarks

Apply this attribute to a YamlSerializerContext-derived partial class once per root type that should have generated YAML metadata.

Inheritance
YamlAttribute YamlSerializableAttribute

Constructors

NameDescription
YamlSerializableAttribute(Type)Initializes a new instance of the YamlSerializableAttribute class.

YamlSerializableAttribute(Type)

YamlSerializableAttribute.cs

Initializes a new instance of the YamlSerializableAttribute class.

public YamlSerializableAttribute(Type type)

Parameters

type Type
The root type that should have generated YAML metadata.

Exceptions

ArgumentNullException
type is null.

Properties

NameDescription
TypeGets the root type that should have generated YAML metadata.
TypeInfoPropertyNameGets or sets the generated YamlTypeInfo property name exposed on the context.

Gets the root type that should have generated YAML metadata.

public Type Type { get; }

Property value

Type

TypeInfoPropertyName

YamlSerializableAttribute.cs

Gets or sets the generated YamlTypeInfo property name exposed on the context.

public string? TypeInfoPropertyName { get; set; }

Property value

string?