79303281

Date: 2024-12-23 13:56:16
Score: 0.5
Natty:
Report link

As stated in the comments by Progman. The WithBestIndent() method does not change the current settings object.

Here the adjusted code that gives the desired result:

string yaml;
 using (var writer = new StringWriter())
 {
     var _settings = new EmitterSettings();
     Console.WriteLine(_settings.BestIndent);
     _settings = _settings.WithBestIndent(4);
     var _emitter = new Emitter(writer, _settings);
     yamlSerializer.Serialize(_emitter, dictionary);
     yaml = writer.ToString();
 }

 Console.WriteLine(yaml);
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Thierry