YamlDotNet icon indicating copy to clipboard operation
YamlDotNet copied to clipboard

Folded style adds extra newlines

Open lanwin opened this issue 11 months ago • 3 comments
trafficstars

Describe the bug I noticed that YamlDotNet 16.2.0 adds extra newlines when writing a foleded string.

To Reproduce

var yaml = new SerializerBuilder().WithDefaultScalarStyle(ScalarStyle.Folded).Build();
var result = yaml.Serialize(new {Test="""
                                         <section>test</section>
                                         <section>test</section>
                                         <section>test</section>
                                         """});

Current output

Test: >-
  <section>test</section>

  <section>test</section>

  <section>test</section>

Expected output

Test: >-
  <section>test</section>
  <section>test</section>
  <section>test</section>

lanwin avatar Dec 06 '24 14:12 lanwin

This may be the same issue as this (probably unresolved) issue: #246

As I understood it, its not. The older issue should be fixed by 12.0.0. But the above proplem still persists and I see not good reason for this behavior.

lanwin avatar May 22 '25 13:05 lanwin

Out of curiosity what operating system did you run it on? I’m wondering if it has to do with line ending differences between Linux and windows.

EdwardCooke avatar May 26 '25 21:05 EdwardCooke

I use this in Windows to create dumps from objects within unit tests.

lanwin avatar May 30 '25 17:05 lanwin