|
@@ -121,7 +121,7 @@ namespace Google.Protobuf
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Creates a new CodedInputStream reading data from the given byte array.
|
|
/// Creates a new CodedInputStream reading data from the given byte array.
|
|
/// </summary>
|
|
/// </summary>
|
|
- public CodedInputStream(byte[] buffer) : this(null, ProtoPreconditions.CheckNotNull(buffer, "buffer"), 0, buffer.Length)
|
|
|
|
|
|
+ public CodedInputStream(byte[] buffer) : this(null, ProtoPreconditions.CheckNotNull(buffer, "buffer"), 0, buffer.Length, true)
|
|
{
|
|
{
|
|
}
|
|
}
|
|
|
|
|
|
@@ -129,7 +129,7 @@ namespace Google.Protobuf
|
|
/// Creates a new <see cref="CodedInputStream"/> that reads from the given byte array slice.
|
|
/// Creates a new <see cref="CodedInputStream"/> that reads from the given byte array slice.
|
|
/// </summary>
|
|
/// </summary>
|
|
public CodedInputStream(byte[] buffer, int offset, int length)
|
|
public CodedInputStream(byte[] buffer, int offset, int length)
|
|
- : this(null, ProtoPreconditions.CheckNotNull(buffer, "buffer"), offset, offset + length)
|
|
|
|
|
|
+ : this(null, ProtoPreconditions.CheckNotNull(buffer, "buffer"), offset, offset + length, true)
|
|
{
|
|
{
|
|
if (offset < 0 || offset > buffer.Length)
|
|
if (offset < 0 || offset > buffer.Length)
|
|
{
|
|
{
|
|
@@ -158,16 +158,15 @@ namespace Google.Protobuf
|
|
/// <c cref="CodedInputStream"/> is disposed; <c>false</c> to dispose of the given stream when the
|
|
/// <c cref="CodedInputStream"/> is disposed; <c>false</c> to dispose of the given stream when the
|
|
/// returned object is disposed.</param>
|
|
/// returned object is disposed.</param>
|
|
public CodedInputStream(Stream input, bool leaveOpen)
|
|
public CodedInputStream(Stream input, bool leaveOpen)
|
|
- : this(ProtoPreconditions.CheckNotNull(input, "input"), new byte[BufferSize], 0, 0)
|
|
|
|
|
|
+ : this(ProtoPreconditions.CheckNotNull(input, "input"), new byte[BufferSize], 0, 0, leaveOpen)
|
|
{
|
|
{
|
|
- this.leaveOpen = leaveOpen;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Creates a new CodedInputStream reading data from the given
|
|
/// Creates a new CodedInputStream reading data from the given
|
|
/// stream and buffer, using the default limits.
|
|
/// stream and buffer, using the default limits.
|
|
/// </summary>
|
|
/// </summary>
|
|
- internal CodedInputStream(Stream input, byte[] buffer, int bufferPos, int bufferSize)
|
|
|
|
|
|
+ internal CodedInputStream(Stream input, byte[] buffer, int bufferPos, int bufferSize, bool leaveOpen)
|
|
{
|
|
{
|
|
this.input = input;
|
|
this.input = input;
|
|
this.buffer = buffer;
|
|
this.buffer = buffer;
|
|
@@ -175,6 +174,7 @@ namespace Google.Protobuf
|
|
this.bufferSize = bufferSize;
|
|
this.bufferSize = bufferSize;
|
|
this.sizeLimit = DefaultSizeLimit;
|
|
this.sizeLimit = DefaultSizeLimit;
|
|
this.recursionLimit = DefaultRecursionLimit;
|
|
this.recursionLimit = DefaultRecursionLimit;
|
|
|
|
+ this.leaveOpen = leaveOpen;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -185,8 +185,8 @@ namespace Google.Protobuf
|
|
/// This chains to the version with the default limits instead of vice versa to avoid
|
|
/// This chains to the version with the default limits instead of vice versa to avoid
|
|
/// having to check that the default values are valid every time.
|
|
/// having to check that the default values are valid every time.
|
|
/// </remarks>
|
|
/// </remarks>
|
|
- internal CodedInputStream(Stream input, byte[] buffer, int bufferPos, int bufferSize, int sizeLimit, int recursionLimit)
|
|
|
|
- : this(input, buffer, bufferPos, bufferSize)
|
|
|
|
|
|
+ internal CodedInputStream(Stream input, byte[] buffer, int bufferPos, int bufferSize, int sizeLimit, int recursionLimit, bool leaveOpen)
|
|
|
|
+ : this(input, buffer, bufferPos, bufferSize, leaveOpen)
|
|
{
|
|
{
|
|
if (sizeLimit <= 0)
|
|
if (sizeLimit <= 0)
|
|
{
|
|
{
|
|
@@ -217,7 +217,8 @@ namespace Google.Protobuf
|
|
/// and recursion limits.</returns>
|
|
/// and recursion limits.</returns>
|
|
public static CodedInputStream CreateWithLimits(Stream input, int sizeLimit, int recursionLimit)
|
|
public static CodedInputStream CreateWithLimits(Stream input, int sizeLimit, int recursionLimit)
|
|
{
|
|
{
|
|
- return new CodedInputStream(input, new byte[BufferSize], 0, 0, sizeLimit, recursionLimit);
|
|
|
|
|
|
+ // Note: we may want an overload accepting leaveOpen
|
|
|
|
+ return new CodedInputStream(input, new byte[BufferSize], 0, 0, sizeLimit, recursionLimit, false);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|