You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using Serializer.Serialize(TextWriter writer, object graph) and passing an IndentedTextWriter to that method for custom indentation.
That single line seems removing configured indentation in IndentedTextWriter object.
setting EmitterSettings.NewLine to TextWriter.NewLine instead of replacing WriteLine with Write seems a better solution and it works fine
I have a PR for the fix of the issue, It also contains a unit test to explain my issue. But I dont have permissions to push my branch. May I ask for push access as well?
adding the test code which creates the issue below
[Fact]
public void SerializeWithTabs()
{
var tabString = " ";
using var writer = new StringWriter();
using var indentedTextWriter = new IndentedTextWriter(writer, tabString) { Indent = 2 };
//create a dictionary with a list of strings to test the tabbed serialization
var items = new List<string> { "item 1", "item 2" };
var list = new Dictionary<string, List<string>> { { "key", items } };
SerializerBuilder
.Build()
.Serialize(indentedTextWriter, list);
//split serialized output into lines
var lines = indentedTextWriter.InnerWriter.ToString().Split(new[] { Environment.NewLine }, StringSplitOptions.None);
//expected indentation
var indent = string.Join(string.Empty, Enumerable.Repeat(tabString, indentedTextWriter.Indent).ToList());
//check that the serialized lines (excluding the first and last) start with the expected indentation
lines.Skip(1).Take(lines.Length - 2).Where(element => element.StartsWith(indent)).Should().HaveCount(items.Count);
}
The text was updated successfully, but these errors were encountered:
To create a pr you fork this repository to your own use. Push your branch up to your fork. Then create a pull request from there. You don’t actually create a branch in this repository. I’ll take a closer look at your issue in a little bit and if you can create that or with above mentioned directions I’ll review it.
Describe the bug
my project was using
12.0.2
version of YamlDotNet package. While upgrading to a newer version I realized an issue introduced in release12.1.0
via this change https://github.com/aaubry/YamlDotNet/pull/747/files#diff-7df2919371fb7e178ae78e207ac6010f930dae71acf2e99769c373c472ce575bR1922I am using
Serializer.Serialize(TextWriter writer, object graph)
and passing anIndentedTextWriter
to that method for custom indentation.That single line seems removing configured indentation in
IndentedTextWriter
object.setting
EmitterSettings.NewLine
toTextWriter.NewLine
instead of replacingWriteLine
withWrite
seems a better solution and it works fineI have a PR for the fix of the issue, It also contains a unit test to explain my issue. But I dont have permissions to push my branch. May I ask for push access as well?
adding the test code which creates the issue below
The text was updated successfully, but these errors were encountered: