aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/Google.Protobuf/JsonFormatter.cs
diff options
context:
space:
mode:
authorJon Skeet <jonskeet@google.com>2016-01-06 11:12:56 +0000
committerJon Skeet <jonskeet@google.com>2016-01-13 10:58:49 +0000
commit5dba7d7b4cac6f2f4250ceaca27fb6024f4aeb54 (patch)
tree4f84548fb0fa879746030e56395d4e87bb6bffa0 /csharp/src/Google.Protobuf/JsonFormatter.cs
parent73c003c309235485c0e53f2075242567c88a72bc (diff)
downloadprotobuf-5dba7d7b4cac6f2f4250ceaca27fb6024f4aeb54.tar.gz
protobuf-5dba7d7b4cac6f2f4250ceaca27fb6024f4aeb54.tar.bz2
protobuf-5dba7d7b4cac6f2f4250ceaca27fb6024f4aeb54.zip
Introduce ICustomDiagnosticMessage to allow for custom string formatting
This fixes issue #933, effectively.
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 bde17903..e89154b4 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 ? " }" : "}");