Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

YamlSerializerOptions

OfficeIMO.Yaml

Namespace
OfficeIMO.Yaml
Assembly
OfficeIMO.Yaml
Source revision
0eef6a5756b9 with working tree changes
Modifiers
sealed

Settings for YamlSerializer. An instance caches the metadata it creates, so reuse one per configuration. It becomes read-only when first used; changing it afterwards throws.

Inheritance

  • object
  • YamlSerializerOptions

Usage

Explore 21 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 16

Constructors

YamlSerializerOptions 2 overloads
public YamlSerializerOptions() #

Creates options with the defaults.

public YamlSerializerOptions(YamlSerializerOptions options) #

Creates a writable copy of options, including its resolver.

Parameters

options OfficeIMO.Yaml.YamlSerializerOptions required

Methods

public YamlTypeInfo GetTypeInfo(Type type) #

Returns the metadata for type from the built-in types or YamlSerializerOptions.TypeInfoResolver, creating it once. It does not fall back to reflection.

Parameters

type System.Type required

Exceptions

  • NotSupportedException – No metadata source knows the type.

Properties

public static YamlSerializerOptions Default { get; } #

Gets the shared default options, which are read-only. Serializer overloads without options use them.

public OfficeNamingPolicy? PropertyNamingPolicy { get; set; } #

Gets or sets the policy that turns property names into mapping keys, or null (the default) to use the names as declared. OfficePropertyNameAttribute wins over it.

public OfficeIgnoreCondition DefaultIgnoreCondition { get; set; } #

Gets or sets when properties are left out of written YAML: OfficeIgnoreCondition.Never (the default), OfficeIgnoreCondition.WhenWritingNull or OfficeIgnoreCondition.WhenWritingDefault.

public YamlReferenceHandling ReferenceHandling { get; set; } #

Gets or sets how shared references and cycles are written and how aliases are read. Defaults to YamlReferenceHandling.None.

public bool CopyAliases { get; set; } #

Gets or sets whether every alias read as object gets its own copy of its anchored node. Off by default: an alias read as object returns the dictionary, list or scalar already read for its anchor, as PyYAML does, so changing one changes every place that shares it. Typed values (properties, collections and dictionaries of a declared type) are read again from the anchored node for each alias either way; use YamlReferenceHandling.Preserve to map those aliases to one instance too. A shared value still counts every node it stands for against YamlReaderOptions.MaxAliasExpansion, because writing or walking it later visits them all.

public YamlReaderOptions? ReaderOptions { get; set; } #

Gets or sets the reader settings for overloads that read text, streams or text readers: the schema, strictness and the limits, including YamlReaderOptions.MaxAliasExpansion for aliases. Null uses the defaults; use YamlReaderOptions.UntrustedDefaults for input from outside. Overloads that take a YamlReader use that reader's settings.

public YamlWriterOptions? WriterOptions { get; set; } #

Gets or sets the layout of written YAML, or null for the YamlWriter defaults.

public IYamlTypeInfoResolver? TypeInfoResolver { get; set; } #

Gets or sets where metadata comes from: a generated YamlSerializerContext, or null. With null, YamlSerializer overloads that allow reflection create metadata by reflection.

public bool IsReadOnly { get; } #

Gets whether the options are read-only, which they become on first use.