Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

YamlLoadOptions

OfficeIMO.Yaml

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

Settings for loading a YamlDocument. The defaults read YAML 1.2 as real files use it (see YamlLoadOptions.Strict) and bound resource use for untrusted input. An instance can be shared by loads on several threads as long as it is not modified while they run.

Inheritance

  • object
  • YamlLoadOptions

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.

Returned or exposed by 1

Accepted by parameters 3

Constructors

public YamlLoadOptions() #

Properties

public static YamlLoadOptions UntrustedDefaults { get; } #

Gets new options for files from outside: input up to 16 MiB, nesting up to 64, 200,000 nodes per document, alias expansion up to 10,000 nodes and scalars up to 1 MiB of characters. Each call returns a new instance.

public YamlSchema? Schema { get; set; } #

Gets or sets the schema for typed reads. When null (the default), each document uses YamlSchema.Core, or YamlSchema.Yaml11 when it declares %YAML 1.1. Set it to force one schema for ecosystems that assume YAML 1.1 without declaring it.

public bool Strict { get; set; } #

Gets or sets whether loading follows the YAML 1.2.2 specification exactly. Off by default, loading accepts what real files rely on and libyaml and SharpYaml accept: flow-collection lines (such as a closing ] under its key) and quoted-scalar continuation lines indented no deeper than the enclosing block collection, and << merge keys under the YAML 1.2 core schema as under YAML 1.1, so repeated << keys (common in docker-compose and GitLab CI files) are one merge list rather than duplicate keys, and duplicate keys unless YamlLoadOptions.DuplicateKeys says otherwise (the last one wins). Each accepted indentation and each document part that uses merge keys without a %YAML 1.1 directive is reported in YamlDocument.Diagnostics. When on, both indentation forms are syntax errors, << is an ordinary key unless the YAML 1.1 schema applies, and a duplicate key fails the load unless YamlLoadOptions.DuplicateKeys is set. Saving never writes the accepted indentation for new or edited text.

public YamlDuplicateKeyPolicy? DuplicateKeys { get; set; } #

Gets or sets how a mapping with equal keys loads. When null (the default), the last key wins and each repeat is a OfficeDiagnosticCodes.YamlDuplicateKey warning in YamlDocument.Diagnostics, or, with YamlLoadOptions.Strict, the load fails with YamlErrorCodes.DuplicateKey as the specification requires. Either way the document keeps every entry, so saving reproduces the file.

public int MaxDepth { get; set; } #

Gets or sets the maximum nesting of collections. Block and flow collections count the same, so a: {b: 1} and a block mapping inside a block mapping both nest two deep. Defaults to 256.

public int MaxNodes { get; set; } #

Gets or sets the maximum number of nodes (scalars, collections and aliases) in one document of the stream. Defaults to 10,000,000; YamlLoadOptions.UntrustedDefaults lowers it to 200,000. A multi-document stream such as a large Kubernetes manifest list is bounded per document; bound the whole input with YamlLoadOptions.MaxInputBytes.

public int MaxAliasExpansion { get; set; } #

Gets or sets the maximum number of nodes one document's aliases stand for when resolved, counting nested aliases at every use. Defaults to 100,000. The load measures it without expanding anything, so a "billion laughs" input fails in time proportional to its size, and every resolved view of a loaded document stays within the bound.

public int MaxScalarLength { get; set; } #

Gets or sets the maximum length of one scalar's source text in UTF-16 code units, including quotes and block scalar indentation. Defaults to 16 MiB of characters.

public long? MaxInputBytes { get; set; } #

Gets or sets the maximum input size, or null (the default) for no limit. File and stream input counts bytes; YamlDocument.Parse counts UTF-16 code units.