Эх сурвалжийг харах

Added comments for private fields
Renamed StartMessage(name) to WriteMessageStart(name) on XmlFormatWriter as this
was intended to be an overload that did not get renamed.

csharptest 14 жил өмнө
parent
commit
f67c83365f

+ 1 - 0
src/ProtocolBuffers.Serialization/JsonFormatReader.cs

@@ -11,6 +11,7 @@ namespace Google.ProtocolBuffers.Serialization
     public class JsonFormatReader : AbstractTextReader
     {
         private readonly JsonCursor _input;
+        // The expected token that ends the current item, either ']' or '}'
         private readonly Stack<int> _stopChar;
 
         private enum ReaderState

+ 2 - 0
src/ProtocolBuffers.Serialization/JsonFormatWriter.cs

@@ -168,7 +168,9 @@ namespace Google.ProtocolBuffers.Serialization
 
         #endregion
 
+        //Tracks the writer depth and the array element count at that depth.
         private readonly List<int> _counter;
+        //True if the top-level of the writer is an array as opposed to a single message.
         private bool _isArray;
 
         /// <summary>

+ 4 - 0
src/ProtocolBuffers.Serialization/XmlFormatReader.cs

@@ -2,6 +2,7 @@ using System;
 using System.Collections.Generic;
 using System.IO;
 using System.Xml;
+using System.Diagnostics;
 
 namespace Google.ProtocolBuffers.Serialization
 {
@@ -14,7 +15,9 @@ namespace Google.ProtocolBuffers.Serialization
     {
         public const string DefaultRootElementName = XmlFormatWriter.DefaultRootElementName;
         private readonly XmlReader _input;
+        // Tracks the message element for each nested message read
         private readonly Stack<ElementStackEntry> _elements;
+        // The default element name for ReadMessageStart
         private string _rootElementName;
 
         private struct ElementStackEntry
@@ -118,6 +121,7 @@ namespace Google.ProtocolBuffers.Serialization
             }
         }
 
+        [DebuggerNonUserCode]
         private static void Assert(bool cond)
         {
             if (!cond)

+ 6 - 4
src/ProtocolBuffers.Serialization/XmlFormatWriter.cs

@@ -16,9 +16,11 @@ namespace Google.ProtocolBuffers.Serialization
     {
         private static readonly Encoding DefaultEncoding = new UTF8Encoding(false);
         public const string DefaultRootElementName = "root";
-        private const int NestedArrayFlag = 0x0001;
+
         private readonly XmlWriter _output;
+        // The default element name used for WriteMessageStart
         private string _rootElementName;
+        // Used to assert matching WriteMessageStart/WriteMessageEnd calls
         private int _messageOpenCount;
 
         private static XmlWriterSettings DefaultSettings(Encoding encoding)
@@ -119,7 +121,7 @@ namespace Google.ProtocolBuffers.Serialization
         /// </summary>
         public override void WriteMessageStart()
         {
-            StartMessage(_rootElementName);
+            WriteMessageStart(_rootElementName);
         }
 
         /// <summary>
@@ -127,7 +129,7 @@ namespace Google.ProtocolBuffers.Serialization
         /// After this call you can call IMessageLite.MergeTo(...) and  complete the message with 
         /// a call to WriteMessageEnd().
         /// </summary>
-        public void StartMessage(string elementName)
+        public void WriteMessageStart(string elementName)
         {
             if (TestOption(XmlWriterOptions.OutputJsonTypes))
             {
@@ -169,7 +171,7 @@ namespace Google.ProtocolBuffers.Serialization
         /// </summary>
         public void WriteMessage(string elementName, IMessageLite message)
         {
-            StartMessage(elementName);
+            WriteMessageStart(elementName);
             message.WriteTo(this);
             WriteMessageEnd();
         }