After the fixes from https://github.com/aaubry/YamlDotNet/pull/491, the SerializationTests.ExampleFromSpecificationIsHandledCorrectlyWithLateDefine() test should fail. Placement of anchors after aliases referring to them is not spec-compliant.
To Reproduce
Execute the SerializationTests.ExampleFromSpecificationIsHandledCorrectlyWithLateDefine() test.
Expected
Test should fail due to an AnchorNotFoundException or ForwardAnchorNotSupportedException (I'm not sure which). It's not clear whether forward references should always be disallowed or if the IList<> constraint is correct but over-zealous. If IList<> types should indeed be special cased, perhaps aliases must reference anchors defined in the same list or earlier in the document❔
My suspicion is special-casing IList<> is incorrect because ordering within a sequence node is semantically important. I haven't found when ForwardAnchorNotSupportedException or the IList<> constraint were introduced to get a sense of the reasoning. Nor have I found anything in the spec indicating a contextual relaxation of "first occurrence", "the most recent event in the serialization having the specified anchor", and similar wording.
Nits
References to AnchorNotFoundException in ForwardAnchorNotSupportedException constructor doc comments are incorrect.
Wording of the $"The anchor '{anchor}' does not exists" message should be $"The anchor '{anchor}' does not exist" (singular).
Describe the bug
After the fixes from https://github.com/aaubry/YamlDotNet/pull/491, the
SerializationTests.ExampleFromSpecificationIsHandledCorrectlyWithLateDefine()
test should fail. Placement of anchors after aliases referring to them is not spec-compliant.To Reproduce
Execute the
SerializationTests.ExampleFromSpecificationIsHandledCorrectlyWithLateDefine()
test.Expected
Test should fail due to an
AnchorNotFoundException
orForwardAnchorNotSupportedException
(I'm not sure which). It's not clear whether forward references should always be disallowed or if theIList<>
constraint is correct but over-zealous. IfIList<>
types should indeed be special cased, perhaps aliases must reference anchors defined in the same list or earlier in the document❔My suspicion is special-casing
IList<>
is incorrect because ordering within a sequence node is semantically important. I haven't found whenForwardAnchorNotSupportedException
or theIList<>
constraint were introduced to get a sense of the reasoning. Nor have I found anything in the spec indicating a contextual relaxation of "first occurrence", "the most recent event in the serialization having the specified anchor", and similar wording.Nits
AnchorNotFoundException
inForwardAnchorNotSupportedException
constructor doc comments are incorrect.$"The anchor '{anchor}' does not exists"
message should be$"The anchor '{anchor}' does not exist"
(singular).$"Anchor '{alias.Value}' not found"
whenAnchorNotFoundException
is thrown and useForwardAnchorNotSupportedException
at https://github.com/aaubry/YamlDotNet/blob/847230593e95750d4294ca72c98a4bd46bdcf265/YamlDotNet/Serialization/ValueDeserializers/AliasValueDeserializer.cs#L107