YamlScalarStylePreferences Class

Provides high-level preferences for scalar style emission.

public sealed class YamlScalarStylePreferences

Constructors

NameDescription
YamlScalarStylePreferences()

YamlScalarStylePreferences()

YamlScalarStylePreferences.cs
public YamlScalarStylePreferences()

No documentation is available.

Properties

NameDescription
PreferPlainStyleGets or sets a value indicating whether plain style should be preferred when possible.
PreferQuotedForAmbiguousScalarsGets or sets a value indicating whether quoted style should be preferred for ambiguous scalars.
StringStyleGets or sets the style used to emit string values.

Gets or sets a value indicating whether plain style should be preferred when possible.

public bool PreferPlainStyle { get; init; }

Property value

bool

PreferQuotedForAmbiguousScalars

YamlScalarStylePreferences.cs

Gets or sets a value indicating whether quoted style should be preferred for ambiguous scalars.

public bool PreferQuotedForAmbiguousScalars { get; init; }

Property value

bool

Gets or sets the style used to emit string values.

public ScalarStyle StringStyle { get; init; }

Property value

ScalarStyle

Exceptions

ArgumentOutOfRangeException
Value is not a defined ScalarStyle.

Remarks

The default is ScalarStyle.Any, which lets the writer pick between the plain and the double-quoted style. Any other value asks for that style, for example ScalarStyle.Literal to emit a block scalar (|):

script: |-
  echo one
  echo two

The requested style is used only when the value round-trips through it. A literal or folded scalar cannot represent an empty value, a carriage return, a control character, or a line that ends with a blank, and no block scalar can be written inside a flow collection. When the style does not fit, the value is written using the automatic style instead.

This applies to string values. Mapping keys and non-string scalars such as numbers, booleans, and dates keep their own representation.