That !
is the 非特定标签.
The YAML 规范 1.2 http://www.yaml.org/spec/1.2/spec.html#id2784064(以及之前的1.1 http://yaml.org/spec/1.1/#id900262)说:
通过明确指定“!”非特定标签属性,节点
然后将被解析为“普通”序列、映射或字符串,
随其类。
看一看here http://yaml.org/refcard.html到标签“语法”:
none : Unspecified tag (automatically resolved by application).
'!' : Non-specific tag (by default, "!!map"/"!!seq"/"!!str").
'!foo' : Primary (by convention, means a local "!foo" tag).
'!!foo' : Secondary (by convention, means "tag:yaml.org,2002:foo").
'!h!foo': Requires "%TAG !h! <prefix>" (and then means "<prefix>foo").
'!<foo>': Verbatim tag (always means "foo").
为什么 YamlDotNet 会抛出错误?我不能 100% 确定,但我认为您发现了一个错误。
YamlDotNet 是一个端口LibYAML http://pyyaml.org/wiki/LibYAML,因此很容易比较来源。
Scanner.c (LibYAML) 的第 2635 行:
/* Check if the tag is non-empty. */
if (!length) {
Scanner.cs (YamlDotNet) 的第 2146 行:
// Check if the tag is non-empty.
if (tag.Length == 0)
我知道,两者看起来非常相似,但在这一点上length
是 1 并且tag.Length
是 0。原始 C 代码负责处理最初的“!” (整个长度)但 C# 不这样做(只是标签“name”长度)。
向项目提交问题。