Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame^] | 1 | #region Copyright notice and license |
| 2 | // Protocol Buffers - Google's data interchange format |
| 3 | // Copyright 2016 Google Inc. All rights reserved. |
| 4 | // https://developers.google.com/protocol-buffers/ |
| 5 | // |
| 6 | // Redistribution and use in source and binary forms, with or without |
| 7 | // modification, are permitted provided that the following conditions are |
| 8 | // met: |
| 9 | // |
| 10 | // * Redistributions of source code must retain the above copyright |
| 11 | // notice, this list of conditions and the following disclaimer. |
| 12 | // * Redistributions in binary form must reproduce the above |
| 13 | // copyright notice, this list of conditions and the following disclaimer |
| 14 | // in the documentation and/or other materials provided with the |
| 15 | // distribution. |
| 16 | // * Neither the name of Google Inc. nor the names of its |
| 17 | // contributors may be used to endorse or promote products derived from |
| 18 | // this software without specific prior written permission. |
| 19 | // |
| 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | #endregion |
| 32 | |
| 33 | namespace Google.Protobuf |
| 34 | { |
| 35 | /// <summary> |
| 36 | /// A message type that has a custom string format for diagnostic purposes. |
| 37 | /// </summary> |
| 38 | /// <remarks> |
| 39 | /// <para> |
| 40 | /// Calling <see cref="object.ToString"/> on a generated message type normally |
| 41 | /// returns the JSON representation. If a message type implements this interface, |
| 42 | /// then the <see cref="ToDiagnosticString"/> method will be called instead of the regular |
| 43 | /// JSON formatting code, but only when <c>ToString()</c> is called either on the message itself |
| 44 | /// or on another message which contains it. This does not affect the normal JSON formatting of |
| 45 | /// the message. |
| 46 | /// </para> |
| 47 | /// <para> |
| 48 | /// For example, if you create a proto message representing a GUID, the internal |
| 49 | /// representation may be a <c>bytes</c> field or four <c>fixed32</c> fields. However, when debugging |
| 50 | /// it may be more convenient to see a result in the same format as <see cref="System.Guid"/> provides. |
| 51 | /// </para> |
| 52 | /// <para>This interface extends <see cref="IMessage"/> to avoid it accidentally being implemented |
| 53 | /// on types other than messages, where it would not be used by anything in the framework.</para> |
| 54 | /// </remarks> |
| 55 | public interface ICustomDiagnosticMessage : IMessage |
| 56 | { |
| 57 | /// <summary> |
| 58 | /// Returns a string representation of this object, for diagnostic purposes. |
| 59 | /// </summary> |
| 60 | /// <remarks> |
| 61 | /// This method is called when a message is formatted as part of a <see cref="object.ToString"/> |
| 62 | /// call. It does not affect the JSON representation used by <see cref="JsonFormatter"/> other than |
| 63 | /// in calls to <see cref="JsonFormatter.ToDiagnosticString(IMessage)"/>. While it is recommended |
| 64 | /// that the result is valid JSON, this is never assumed by the Protobuf library. |
| 65 | /// </remarks> |
| 66 | /// <returns>A string representation of this object, for diagnostic purposes.</returns> |
| 67 | string ToDiagnosticString(); |
| 68 | } |
| 69 | } |