Skip to content

v1.1.0

Choose a tag to compare

@github-actions github-actions released this 17 Oct 08:14
· 58 commits to main since this release

Changed

  • Get<object> and GetValue<object> read collections. Asking a node for object, through YamlDocument.Get<object>, TryGet, YamlNode.GetValue<object> or TryGetValue, now gives what YamlSerializer.Deserialize<object> gives: a Dictionary<string, object?> for a mapping and a List<object?> for a sequence. It used to fail with "The node is not a scalar".
  • A reader that was copied and left behind says so. A Utf8YamlReader shares its scanner with its copies. When a copy read past the end of its value, the original used to fail with a syntax error that blamed the input. It now throws InvalidOperationException that names the misuse; the same holds for a copy used after the original read on. Looking ahead on a copy inside the current value still works. The failure is reported when the reader hits the damaged position, so a copy that damaged a reader without causing an error stays undetected: do not copy the reader.
  • Faster write-back of an unedited document. YamlDocument.ToUtf8Bytes no longer clears the output array before copying into it.
  • Error messages. A refused alias expansion reads the same from a document and from the serializer, and names a position. A key discriminator that is missing points at the mapping, not at its first key. The SharpYaml adapter's messages state the position once.

Fixed

  • An explicit key beats a merged one inside a merge source. With MergeKeys on, a mapping used as the source of a << key could hold its own << and then an explicit key, as in {<<: {a: 1}, a: 2}. Reached through the outer merge, a typed load into a class, record or dictionary gave a the merged value 1. It now gives 2, as when that mapping is read directly and as generic load does. The first source still wins among several, and a repeated key inside one source is still an error.
  • A repeated key inside a merge source is an error. With MergeKeys on, a mapping used as the source of a << key could repeat a key that binds to a member or a dictionary entry, and the second value was dropped without a word. It now fails with DuplicateKey at the repeated key, as a repeated key does anywhere else. The same key in two different sources is still fine; the first source wins.
  • The YamlDotNet adapter's Serializer bounds a graph that shares its parts. With DisableAliases() or JsonCompatible(), a graph in which objects are reachable many times over was written out in full without limit. The nodes written for repeated objects are now held to the alias budget of the limits and the writer throws MaximumRecursionLevelReachedException beyond it. SerializerBuilder.WithLimits sets the limits; the default is YamlLimits.Default.
  • The documentation of MaxDepth in the SharpYaml adapter now matches what it does: the property reads back the value set, and the lower of it and Limits.MaxDepth applies.