Sfoglia il codice sorgente

Fix for bug in limited input stream's Position, Introduced Position on output stream

csharptest 12 anni fa
parent
commit
0a0dd0333a

+ 1 - 1
src/ProtocolBuffers/CodedInputStream.cs

@@ -166,7 +166,7 @@ namespace Google.ProtocolBuffers
             get
             {
                 if (input != null)
-                    return input.Position - (bufferSize - bufferPos);
+                    return input.Position - ((bufferSize + bufferSizeAfterLimit) - bufferPos);
                 return bufferPos;
             }
         }

+ 14 - 1
src/ProtocolBuffers/CodedOutputStream.cs

@@ -125,7 +125,20 @@ namespace Google.ProtocolBuffers
         }
 
         #endregion
-        
+
+        /// <summary>
+        /// Returns the current position in the stream, or the position in the output buffer
+        /// </summary>
+        public long Position
+        {
+            get
+            {
+                if (output != null)
+                    return output.Position + position;
+                return position;
+            }
+        }
+
         void ICodedOutputStream.WriteMessageStart() { }
         void ICodedOutputStream.WriteMessageEnd() { Flush(); }