From a7b75819528040443835aab7bce1a7934b0d026c Mon Sep 17 00:00:00 2001 From: "Victor M. Alvarez" Date: Thu, 21 May 2026 16:23:51 +0200 Subject: [PATCH 1/3] feat: use YAML literal blocks for multi-line strings Serialize string values containing newline characters using YAML's literal block style ('|'). This significantly improves the readability of generated YAML output for such strings. --- ...f6a0e3152020fc7964243fc845cad499d11f9ab.out | 4 +++- proto-yaml/src/lib.rs | 18 +++++++++++++----- proto-yaml/src/tests/testdata/1.out | 8 ++++++-- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/lib/src/modules/dotnet/tests/testdata/0224ad9739f5fa64a2a63e23ef6a0e3152020fc7964243fc845cad499d11f9ab.out b/lib/src/modules/dotnet/tests/testdata/0224ad9739f5fa64a2a63e23ef6a0e3152020fc7964243fc845cad499d11f9ab.out index e7dfa181a..62e96fdfc 100644 --- a/lib/src/modules/dotnet/tests/testdata/0224ad9739f5fa64a2a63e23ef6a0e3152020fc7964243fc845cad499d11f9ab.out +++ b/lib/src/modules/dotnet/tests/testdata/0224ad9739f5fa64a2a63e23ef6a0e3152020fc7964243fc845cad499d11f9ab.out @@ -70,7 +70,9 @@ assembly_refs: build_number: 0 revision_number: 0 resources: - - name: "\r\n" + - name: | + +  classes: - fullname: "OctopusRPA.Csv.CsvHelper" name: "CsvHelper" diff --git a/proto-yaml/src/lib.rs b/proto-yaml/src/lib.rs index 1a8829564..d46967cc6 100644 --- a/proto-yaml/src/lib.rs +++ b/proto-yaml/src/lib.rs @@ -337,11 +337,19 @@ impl Serializer { ReflectValueRef::F64(v) => write!(self.output, "{v:.1}")?, ReflectValueRef::Bool(v) => write!(self.output, "{v}")?, ReflectValueRef::String(v) => { - write!( - self.output, - "\"{}\"", - Self::escape(v).paint(self.colors.string) - )?; + if v.contains('\n') { + write!(self.output, "{}", "|".paint(self.colors.string))?; + for line in v.split('\n') { + self.newline()?; + write!(self.output, "{}", line.paint(self.colors.string))?; + } + } else { + write!( + self.output, + "\"{}\"", + Self::escape(v).paint(self.colors.string) + )?; + } } ReflectValueRef::Bytes(v) => { write!( diff --git a/proto-yaml/src/tests/testdata/1.out b/proto-yaml/src/tests/testdata/1.out index 1ea436dfe..89c648ced 100644 --- a/proto-yaml/src/tests/testdata/1.out +++ b/proto-yaml/src/tests/testdata/1.out @@ -4,14 +4,18 @@ int32_dec: 123 str: "foo" repeated_msg: - int32_dec: 456 - str: "bar\nbar" + str: | + bar + bar - int32_dec: 789 str: "foo\\bar" map_string_string: "foo\nbar": "bar" nested_msg: int32_dec: 1234 - str: "qux\nfoo" + str: | + qux + foo map_string_string: "bar": "baz" "foo": "bar" \ No newline at end of file From effc0caf0de7665b3a4cbfbbffa0a316c7099658 Mon Sep 17 00:00:00 2001 From: "Victor M. Alvarez" Date: Thu, 21 May 2026 16:26:55 +0200 Subject: [PATCH 2/3] style: run `cargo fmt`. --- proto-yaml/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/proto-yaml/src/lib.rs b/proto-yaml/src/lib.rs index d46967cc6..e9d89aaef 100644 --- a/proto-yaml/src/lib.rs +++ b/proto-yaml/src/lib.rs @@ -341,7 +341,11 @@ impl Serializer { write!(self.output, "{}", "|".paint(self.colors.string))?; for line in v.split('\n') { self.newline()?; - write!(self.output, "{}", line.paint(self.colors.string))?; + write!( + self.output, + "{}", + line.paint(self.colors.string) + )?; } } else { write!( From 72d3df2569819728b12831efa081aadd4040e606 Mon Sep 17 00:00:00 2001 From: "Victor M. Alvarez" Date: Thu, 21 May 2026 17:20:29 +0200 Subject: [PATCH 3/3] tests: fix broken test case. --- ...39f5fa64a2a63e23ef6a0e3152020fc7964243fc845cad499d11f9ab.out | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/modules/dotnet/tests/testdata/0224ad9739f5fa64a2a63e23ef6a0e3152020fc7964243fc845cad499d11f9ab.out b/lib/src/modules/dotnet/tests/testdata/0224ad9739f5fa64a2a63e23ef6a0e3152020fc7964243fc845cad499d11f9ab.out index 62e96fdfc..0dea9ecee 100644 --- a/lib/src/modules/dotnet/tests/testdata/0224ad9739f5fa64a2a63e23ef6a0e3152020fc7964243fc845cad499d11f9ab.out +++ b/lib/src/modules/dotnet/tests/testdata/0224ad9739f5fa64a2a63e23ef6a0e3152020fc7964243fc845cad499d11f9ab.out @@ -72,7 +72,7 @@ assembly_refs: resources: - name: | -  +  classes: - fullname: "OctopusRPA.Csv.CsvHelper" name: "CsvHelper"