aboutsummaryrefslogtreecommitdiffhomepage
path: root/csharp/src/Google.Protobuf/JsonFormatter.cs
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@users.noreply.github.com>2016-01-19 19:38:16 -0800
committerGravatar Jan Tattermusch <jtattermusch@users.noreply.github.com>2016-01-19 19:38:16 -0800
commit8c5260b21bb0e217e91375893d507a0ef6578d67 (patch)
tree1c72120a82fab876f5713a97f2fde16910fef05a /csharp/src/Google.Protobuf/JsonFormatter.cs
parent6794d17c948f1b36d8e77a91568a40456ec8ada3 (diff)
parent5dba7d7b4cac6f2f4250ceaca27fb6024f4aeb54 (diff)
Merge pull request #1096 from jskeet/custom-to-string
Introduce ICustomDiagnosticMessage to allow for custom string formatting
Diffstat (limited to 'csharp/src/Google.Protobuf/JsonFormatter.cs')
-rw-r--r--csharp/src/Google.Protobuf/JsonFormatter.cs9
1 files changed, 9 insertions, 0 deletions
diff --git a/csharp/src/Google.Protobuf/JsonFormatter.cs b/csharp/src/Google.Protobuf/JsonFormatter.cs
index 61961c4c..21239cf2 100644
--- a/csharp/src/Google.Protobuf/JsonFormatter.cs
+++ b/csharp/src/Google.Protobuf/JsonFormatter.cs
@@ -181,6 +181,15 @@ namespace Google.Protobuf
WriteNull(builder);
return;
}
+ if (ReferenceEquals(this, diagnosticFormatter))
+ {
+ ICustomDiagnosticMessage customDiagnosticMessage = message as ICustomDiagnosticMessage;
+ if (customDiagnosticMessage != null)
+ {
+ builder.Append(customDiagnosticMessage.ToDiagnosticString());
+ return;
+ }
+ }
builder.Append("{ ");
bool writtenFields = WriteMessageFields(builder, message, false);
builder.Append(writtenFields ? " }" : "}");