From 787395b916657034159ea620b0b1beac161f7790 Mon Sep 17 00:00:00 2001 From: Bouke Versteegh Date: Fri, 15 Jul 2022 20:57:12 +0200 Subject: [PATCH] Add remarks to overloads that accept indentationLevel --- csharp/src/Google.Protobuf/JsonFormatter.cs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/csharp/src/Google.Protobuf/JsonFormatter.cs b/csharp/src/Google.Protobuf/JsonFormatter.cs index 93bf51e251bf0..5f7ef94297fbc 100644 --- a/csharp/src/Google.Protobuf/JsonFormatter.cs +++ b/csharp/src/Google.Protobuf/JsonFormatter.cs @@ -145,11 +145,26 @@ public JsonFormatter(Settings settings) /// Formats the specified message as JSON. /// /// The message to format. + /// This method delegates to Format(IMessage, int) with indentationLevel = 0. /// The formatted message. - public string Format(IMessage message) + public string Format(IMessage message) => Format(message, indentationLevel: 0); + + /// + /// Formats the specified message as JSON. + /// + /// The message to format. + /// Indentation level to start at. + /// To keep consistent indentation when embedding a message inside another JSON string, set . E.g: + /// + /// var response = $@"{{ + /// ""data"": { Format(message, indentationLevel: 1) } + /// }}" + /// + /// The formatted message. + public string Format(IMessage message, int indentationLevel) { var writer = new StringWriter(); - Format(message, writer); + Format(message, writer, indentationLevel); return writer.ToString(); } @@ -168,6 +183,7 @@ public string Format(IMessage message) /// The message to format. /// The TextWriter to write the formatted message to. /// Indentation level to start at. + /// To keep consistent indentation when embedding a message inside another JSON string, set . public void Format(IMessage message, TextWriter writer, int indentationLevel) { ProtoPreconditions.CheckNotNull(message, nameof(message));