File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed
YamlDotNet.Test/Serialization Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change 2121
2222using System ;
2323using System . Collections . Generic ;
24+ using System . IO ;
2425using System . Linq ;
2526using FluentAssertions ;
2627using Xunit ;
@@ -331,6 +332,42 @@ public void DeserializeWithoutDuplicateKeyChecking_YamlWithDuplicateKeys_DoesNot
331332 act = ( ) => sut . Deserialize < Dictionary < string , Dictionary < string , string > > > ( parser ) ;
332333 act . ShouldNotThrow < YamlException > ( "Because duplicate key checking is not enabled" ) ;
333334 }
335+
336+ [ Fact ]
337+ public void MergingParserWithMergeObjectWithSequence_ShouldNotThrowException ( )
338+ {
339+ var yaml = @"
340+ base_level: &base
341+ tenant:
342+ - a1
343+ Level1: &Level1
344+ <<: [*base]
345+ Level2: &Level2
346+ <<: *Level1
347+ " ;
348+ var mergingParserFailed = new MergingParser ( new Parser ( new StringReader ( yaml ) ) ) ;
349+ var deserializer = new DeserializerBuilder ( ) . Build ( ) ;
350+ Action act = ( ) => deserializer . Deserialize ( mergingParserFailed ) ;
351+ act . ShouldNotThrow < Exception > ( ) ;
352+ }
353+
354+ [ Fact ]
355+ public void MergingParserWithNestedSequence_ShouldNotThrowException ( )
356+ {
357+ var yaml = @"
358+ base_level: &base {}
359+ Level1: &Level1
360+ <<: [*base]
361+ Level2: &Level2
362+ <<: [*Level1]
363+ Level3:
364+ <<: *Level2
365+ " ;
366+ var mergingParserFailed = new MergingParser ( new Parser ( new StringReader ( yaml ) ) ) ;
367+ var deserializer = new DeserializerBuilder ( ) . Build ( ) ;
368+ Action act = ( ) => deserializer . Deserialize ( mergingParserFailed ) ;
369+ act . ShouldNotThrow < Exception > ( ) ;
370+ }
334371
335372 public class Test
336373 {
Original file line number Diff line number Diff line change @@ -140,7 +140,8 @@ private bool HandleSequence(LinkedListNode<ParsingEvent> node)
140140 var current = node ;
141141 while ( current != null )
142142 {
143- if ( current . Value is SequenceEnd )
143+ if ( current . Value is SequenceEnd &&
144+ current . Value . Start . Line >= sequenceStart . Value . Start . Line )
144145 {
145146 events . MarkDeleted ( current ) ;
146147 return true ;
You can’t perform that action at this time.
0 commit comments