From 0a0dd0333a4bec75451d549b88040d4fb598ad9f Mon Sep 17 00:00:00 2001 From: csharptest Date: Thu, 16 May 2013 13:59:34 -0500 Subject: Fix for bug in limited input stream's Position, Introduced Position on output stream --- src/ProtocolBuffers/CodedInputStream.cs | 2 +- src/ProtocolBuffers/CodedOutputStream.cs | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/ProtocolBuffers/CodedInputStream.cs b/src/ProtocolBuffers/CodedInputStream.cs index bc443839..a63ce174 100644 --- a/src/ProtocolBuffers/CodedInputStream.cs +++ b/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; } } diff --git a/src/ProtocolBuffers/CodedOutputStream.cs b/src/ProtocolBuffers/CodedOutputStream.cs index b767f705..9688d5cb 100644 --- a/src/ProtocolBuffers/CodedOutputStream.cs +++ b/src/ProtocolBuffers/CodedOutputStream.cs @@ -125,7 +125,20 @@ namespace Google.ProtocolBuffers } #endregion - + + /// + /// Returns the current position in the stream, or the position in the output buffer + /// + public long Position + { + get + { + if (output != null) + return output.Position + position; + return position; + } + } + void ICodedOutputStream.WriteMessageStart() { } void ICodedOutputStream.WriteMessageEnd() { Flush(); } -- cgit v1.2.3