diff options
author | Jan Tattermusch <jtattermusch@users.noreply.github.com> | 2016-01-19 19:38:16 -0800 |
---|---|---|
committer | Jan Tattermusch <jtattermusch@users.noreply.github.com> | 2016-01-19 19:38:16 -0800 |
commit | 8c5260b21bb0e217e91375893d507a0ef6578d67 (patch) | |
tree | 1c72120a82fab876f5713a97f2fde16910fef05a /csharp/src/Google.Protobuf/JsonFormatter.cs | |
parent | 6794d17c948f1b36d8e77a91568a40456ec8ada3 (diff) | |
parent | 5dba7d7b4cac6f2f4250ceaca27fb6024f4aeb54 (diff) | |
download | protobuf-8c5260b21bb0e217e91375893d507a0ef6578d67.tar.gz protobuf-8c5260b21bb0e217e91375893d507a0ef6578d67.tar.bz2 protobuf-8c5260b21bb0e217e91375893d507a0ef6578d67.zip |
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.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 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 ? " }" : "}"); |