YamlDocumentOptions struct

Provides the ability for the user to define custom behavior when parsing YAML to create a YamlDocument.

Namespace: System.Text.Yaml ยท Assembly: Styml.dll

public struct YamlDocumentOptions

Provides the ability for the user to define custom behavior when parsing YAML to create a YamlDocument.

PropertiesLink to this heading

AllowDuplicatePropertiesLink to this heading

Defines whether duplicate property names are allowed when deserializing YAML objects: a view of YamlDocumentOptions.DuplicateKeyHandling, true unless it is YamlDuplicateKeyHandling.Error.

public bool AllowDuplicateProperties { get; set; }

Setting it to true selects YamlDuplicateKeyHandling.LastWins and false selects YamlDuplicateKeyHandling.Error, which throws a YamlException when a duplicate property name is encountered. By default it is false (decision 1).

AllowTrailingCommasLink to this heading

Kept for source compatibility with System.Text.Json; it has no effect. YAML flow collections always allow (and ignore) one trailing comma before their closing bracket.

public bool AllowTrailingCommas { get; set; }

The JSON grammar that read this option was deleted in M7a (decision D8); setting it changes nothing.

CommentHandlingLink to this heading

Defines how the Utf8YamlReader should handle comments when reading through the YAML.

public YamlCommentHandling CommentHandling { get; set; }
Exception Condition
ArgumentOutOfRangeException Thrown when the comment handling enum is set to a value that is not supported (or not within the YamlCommentHandling enum range).

By default (YamlCommentHandling.Disallow) # comments are skipped and // and /* */ are not comments, as in standard YAML. With YamlCommentHandling.Skip the JSON comments of a JSON payload are skipped too, as System.Text.Json skips them; see YamlCommentHandling for where they are read. YamlCommentHandling.Allow is not supported here.

DuplicateKeyHandlingLink to this heading

Gets or sets what parsing does with a mapping key that appears twice in an object. By default, YamlDuplicateKeyHandling.Error. Under YamlDuplicateKeyHandling.LastWins and YamlDuplicateKeyHandling.FirstWins the document keeps every entry, and a property lookup returns the last or the first match.

public YamlDuplicateKeyHandling DuplicateKeyHandling { get; set; }
Exception Condition
ArgumentOutOfRangeException The value is not a defined YamlDuplicateKeyHandling.

MaxAliasExpansionLink to this heading

Gets or sets the most nodes that expanding aliases may add when a document's nodes are copied: a YamlNode made from the document, an element written or cloned apart from the anchor it refers to, or an element deserialized. Reading, enumerating and comparing the document copy nothing, so the limit does not apply to them.

public int MaxAliasExpansion { get; set; }
Exception Condition
ArgumentOutOfRangeException The value is negative.

The default (0) allows ten times the document's own node count, or 10,000 nodes, whichever is larger. Past the limit a YamlException is thrown. An alias inside the node it refers to is never expanded.

MaxDepthLink to this heading

Gets or sets the maximum depth allowed when reading YAML, with the default (i.e. 0) indicating a max depth of 64.

public int MaxDepth { get; set; }
Exception Condition
ArgumentOutOfRangeException Thrown when the max depth is set to a negative value.

Reading past this depth will throw a .

ResolveMergeKeysLink to this heading

Gets or sets whether a plain << key merges mappings into the mapping that holds it (the YAML 1.1 merge type, yaml.org/type/merge): its value is an alias, a mapping or a sequence of them; merged entries take the place of the << entry; the mapping's own keys win over merged ones, and an earlier merged mapping wins over a later one. Off by default, so << is an ordinary key.

public bool ResolveMergeKeys { get; set; }

A document with a merge key is read from its merged text, written in block style, so its raw text and positions are the merged text's, and a syntax error surfaces from the parse of the source. Copied entries count against YamlDocumentOptions.MaxAliasExpansion.

SchemaLink to this heading

Gets or sets the schema that resolves the document's plain scalars: YamlSchemaKind.Core (YAML 1.2, the default), YamlSchemaKind.Yaml11, YamlSchemaKind.Json or YamlSchemaKind.Failsafe. It decides the token types of yes, 017, 1_000 or foo, and the number forms the element's getters accept.

public YamlSchemaKind Schema { get; set; }

Generated from the XML documentation of the libraryBuilt with Douze

Esc to close