diff options
author | Jon Skeet <jonskeet@google.com> | 2016-01-06 11:12:56 +0000 |
---|---|---|
committer | Jon Skeet <jonskeet@google.com> | 2016-01-13 10:58:49 +0000 |
commit | 5dba7d7b4cac6f2f4250ceaca27fb6024f4aeb54 (patch) | |
tree | 4f84548fb0fa879746030e56395d4e87bb6bffa0 /csharp/src/Google.Protobuf/JsonFormatter.cs | |
parent | 73c003c309235485c0e53f2075242567c88a72bc (diff) | |
download | protobuf-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.cs | 9 |
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 ? " }" : "}"); |