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 21
21
22
22
using System ;
23
23
using System . Collections . Generic ;
24
+ using System . IO ;
24
25
using System . Linq ;
25
26
using FluentAssertions ;
26
27
using Xunit ;
@@ -331,6 +332,42 @@ public void DeserializeWithoutDuplicateKeyChecking_YamlWithDuplicateKeys_DoesNot
331
332
act = ( ) => sut . Deserialize < Dictionary < string , Dictionary < string , string > > > ( parser ) ;
332
333
act . ShouldNotThrow < YamlException > ( "Because duplicate key checking is not enabled" ) ;
333
334
}
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
+ }
334
371
335
372
public class Test
336
373
{
Original file line number Diff line number Diff line change @@ -140,7 +140,8 @@ private bool HandleSequence(LinkedListNode<ParsingEvent> node)
140
140
var current = node ;
141
141
while ( current != null )
142
142
{
143
- if ( current . Value is SequenceEnd )
143
+ if ( current . Value is SequenceEnd &&
144
+ current . Value . Start . Line >= sequenceStart . Value . Start . Line )
144
145
{
145
146
events . MarkDeleted ( current ) ;
146
147
return true ;
You can’t perform that action at this time.
0 commit comments