Skip to content

Commit

Permalink
Add remarks to overloads that accept indentationLevel
Browse files Browse the repository at this point in the history
  • Loading branch information
boukeversteegh committed Jul 15, 2022
1 parent 98a5774 commit 787395b
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions csharp/src/Google.Protobuf/JsonFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,26 @@ public JsonFormatter(Settings settings)
/// Formats the specified message as JSON.
/// </summary>
/// <param name="message">The message to format.</param>
/// <remarks>This method delegates to <c>Format(IMessage, int)</c> with <c>indentationLevel = 0</c>.</remarks>
/// <returns>The formatted message.</returns>
public string Format(IMessage message)
public string Format(IMessage message) => Format(message, indentationLevel: 0);

/// <summary>
/// Formats the specified message as JSON.
/// </summary>
/// <param name="message">The message to format.</param>
/// <param name="indentationLevel">Indentation level to start at.</param>
/// <remarks>To keep consistent indentation when embedding a message inside another JSON string, set <see cref="indentationLevel"/>. E.g:
/// <code>
/// var response = $@"{{
/// ""data"": { Format(message, indentationLevel: 1) }
/// }}"</code>
/// </remarks>
/// <returns>The formatted message.</returns>
public string Format(IMessage message, int indentationLevel)
{
var writer = new StringWriter();
Format(message, writer);
Format(message, writer, indentationLevel);
return writer.ToString();
}

Expand All @@ -168,6 +183,7 @@ public string Format(IMessage message)
/// <param name="message">The message to format.</param>
/// <param name="writer">The TextWriter to write the formatted message to.</param>
/// <param name="indentationLevel">Indentation level to start at.</param>
/// <remarks>To keep consistent indentation when embedding a message inside another JSON string, set <see cref="indentationLevel"/>.</remarks>
public void Format(IMessage message, TextWriter writer, int indentationLevel)
{
ProtoPreconditions.CheckNotNull(message, nameof(message));
Expand Down

0 comments on commit 787395b

Please sign in to comment.