Imported Upstream version 5.16.0.100

Former-commit-id: 38faa55fb9669e35e7d8448b15c25dc447f25767
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-08-07 15:19:03 +00:00
parent 0a9828183b
commit 7d7f676260
4419 changed files with 170950 additions and 90273 deletions

View File

@@ -2,22 +2,22 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.IO.Compression.Tests", "tests\System.IO.Compression.Tests.csproj", "{BC2E1649-291D-412E-9529-EDDA94FA7AD6}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.IO.Compression.Tests", "tests\System.IO.Compression.Tests.csproj", "{17DA7FB5-4370-4385-9A02-FFEF9F482903}"
ProjectSection(ProjectDependencies) = postProject
{5471BFE8-8071-466F-838E-5ADAA779E742} = {5471BFE8-8071-466F-838E-5ADAA779E742}
{E9ED0A04-23A8-4F8B-82C1-2B18AF74C870} = {E9ED0A04-23A8-4F8B-82C1-2B18AF74C870}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.IO.Compression.Performance.Tests", "tests\Performance\System.IO.Compression.Performance.Tests.csproj", "{1341F8C8-637A-49A1-BE0F-13867A634929}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.IO.Compression.Performance.Tests", "tests\Performance\System.IO.Compression.Performance.Tests.csproj", "{13C0F956-FB7B-4882-A411-39B8E22463D2}"
ProjectSection(ProjectDependencies) = postProject
{5471BFE8-8071-466F-838E-5ADAA779E742} = {5471BFE8-8071-466F-838E-5ADAA779E742}
{E9ED0A04-23A8-4F8B-82C1-2B18AF74C870} = {E9ED0A04-23A8-4F8B-82C1-2B18AF74C870}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.IO.Compression", "src\System.IO.Compression.csproj", "{5471BFE8-8071-466F-838E-5ADAA779E742}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.IO.Compression", "src\System.IO.Compression.csproj", "{E9ED0A04-23A8-4F8B-82C1-2B18AF74C870}"
ProjectSection(ProjectDependencies) = postProject
{4ADD9456-A929-4254-B8A2-16FC628ABFDA} = {4ADD9456-A929-4254-B8A2-16FC628ABFDA}
{7CBACE0E-E07C-4ADB-A413-ADEC0CACBD43} = {7CBACE0E-E07C-4ADB-A413-ADEC0CACBD43}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.IO.Compression", "ref\System.IO.Compression.csproj", "{4ADD9456-A929-4254-B8A2-16FC628ABFDA}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.IO.Compression", "ref\System.IO.Compression.csproj", "{7CBACE0E-E07C-4ADB-A413-ADEC0CACBD43}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{1A2F9F4A-A032-433E-B914-ADD5992BB178}"
EndProject
@@ -31,30 +31,30 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BC2E1649-291D-412E-9529-EDDA94FA7AD6}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
{BC2E1649-291D-412E-9529-EDDA94FA7AD6}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
{BC2E1649-291D-412E-9529-EDDA94FA7AD6}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
{BC2E1649-291D-412E-9529-EDDA94FA7AD6}.Release|Any CPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
{1341F8C8-637A-49A1-BE0F-13867A634929}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU
{1341F8C8-637A-49A1-BE0F-13867A634929}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU
{1341F8C8-637A-49A1-BE0F-13867A634929}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU
{1341F8C8-637A-49A1-BE0F-13867A634929}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU
{5471BFE8-8071-466F-838E-5ADAA779E742}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
{5471BFE8-8071-466F-838E-5ADAA779E742}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
{5471BFE8-8071-466F-838E-5ADAA779E742}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
{5471BFE8-8071-466F-838E-5ADAA779E742}.Release|Any CPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
{4ADD9456-A929-4254-B8A2-16FC628ABFDA}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU
{4ADD9456-A929-4254-B8A2-16FC628ABFDA}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU
{4ADD9456-A929-4254-B8A2-16FC628ABFDA}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU
{4ADD9456-A929-4254-B8A2-16FC628ABFDA}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU
{17DA7FB5-4370-4385-9A02-FFEF9F482903}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
{17DA7FB5-4370-4385-9A02-FFEF9F482903}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
{17DA7FB5-4370-4385-9A02-FFEF9F482903}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
{17DA7FB5-4370-4385-9A02-FFEF9F482903}.Release|Any CPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
{13C0F956-FB7B-4882-A411-39B8E22463D2}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU
{13C0F956-FB7B-4882-A411-39B8E22463D2}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU
{13C0F956-FB7B-4882-A411-39B8E22463D2}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU
{13C0F956-FB7B-4882-A411-39B8E22463D2}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU
{E9ED0A04-23A8-4F8B-82C1-2B18AF74C870}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
{E9ED0A04-23A8-4F8B-82C1-2B18AF74C870}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
{E9ED0A04-23A8-4F8B-82C1-2B18AF74C870}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
{E9ED0A04-23A8-4F8B-82C1-2B18AF74C870}.Release|Any CPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
{7CBACE0E-E07C-4ADB-A413-ADEC0CACBD43}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU
{7CBACE0E-E07C-4ADB-A413-ADEC0CACBD43}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU
{7CBACE0E-E07C-4ADB-A413-ADEC0CACBD43}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU
{7CBACE0E-E07C-4ADB-A413-ADEC0CACBD43}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{BC2E1649-291D-412E-9529-EDDA94FA7AD6} = {1A2F9F4A-A032-433E-B914-ADD5992BB178}
{1341F8C8-637A-49A1-BE0F-13867A634929} = {1A2F9F4A-A032-433E-B914-ADD5992BB178}
{5471BFE8-8071-466F-838E-5ADAA779E742} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD}
{4ADD9456-A929-4254-B8A2-16FC628ABFDA} = {2E666815-2EDB-464B-9DF6-380BF4789AD4}
{17DA7FB5-4370-4385-9A02-FFEF9F482903} = {1A2F9F4A-A032-433E-B914-ADD5992BB178}
{13C0F956-FB7B-4882-A411-39B8E22463D2} = {1A2F9F4A-A032-433E-B914-ADD5992BB178}
{E9ED0A04-23A8-4F8B-82C1-2B18AF74C870} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD}
{7CBACE0E-E07C-4ADB-A413-ADEC0CACBD43} = {2E666815-2EDB-464B-9DF6-380BF4789AD4}
EndGlobalSection
EndGlobal

View File

@@ -2,7 +2,7 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<ProjectGuid>{4ADD9456-A929-4254-B8A2-16FC628ABFDA}</ProjectGuid>
<ProjectGuid>{7CBACE0E-E07C-4ADB-A413-ADEC0CACBD43}</ProjectGuid>
<IsPartialFacadeAssembly Condition="'$(TargetGroup)' == 'netfx'">true</IsPartialFacadeAssembly>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Debug|AnyCPU'" />

View File

@@ -0,0 +1,2 @@
# Exposed publicly only in implementation for serialization compat
TypesMustExist : Type 'System.IO.Compression.ZLibException' does not exist in the implementation but it does exist in the contract.

View File

@@ -4,7 +4,7 @@
<PropertyGroup>
<AssemblyName>System.IO.Compression</AssemblyName>
<OutputType>Library</OutputType>
<ProjectGuid>{5471BFE8-8071-466F-838E-5ADAA779E742}</ProjectGuid>
<ProjectGuid>{E9ED0A04-23A8-4F8B-82C1-2B18AF74C870}</ProjectGuid>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPartialFacadeAssembly Condition="'$(TargetGroup)' == 'netfx'">true</IsPartialFacadeAssembly>
</PropertyGroup>
@@ -58,9 +58,6 @@
<Compile Include="System\IO\Compression\ZipArchiveEntry.netcoreapp.cs" />
<Compile Include="System\IO\Compression\ZipCustomStreams.netcoreapp.cs" />
<Compile Include="System\IO\Compression\PositionPreservingWriteOnlyStreamWrapper.netcoreapp.cs" />
<Compile Include="$(CommonPath)\System\IO\PathInternal.cs">
<Link>Common\System\IO\PathInternal.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\IO\StreamHelpers.CopyValidation.cs">
<Link>Common\System\IO\StreamHelpers.CopyValidation.cs</Link>
</Compile>

View File

@@ -199,7 +199,7 @@ namespace System.IO.Compression
flushSuccessful = _deflater.Flush(_buffer, out compressedBytes);
if (flushSuccessful)
{
await _stream.WriteAsync(_buffer, 0, compressedBytes, cancellationToken).ConfigureAwait(false);
await _stream.WriteAsync(new ReadOnlyMemory<byte>(_buffer, 0, compressedBytes), cancellationToken).ConfigureAwait(false);
}
Debug.Assert(flushSuccessful == (compressedBytes > 0));
} while (flushSuccessful);
@@ -237,22 +237,22 @@ namespace System.IO.Compression
return ReadCore(new Span<byte>(array, offset, count));
}
public override int Read(Span<byte> destination)
public override int Read(Span<byte> buffer)
{
if (GetType() != typeof(DeflateStream))
{
// DeflateStream is not sealed, and a derived type may have overridden Read(byte[], int, int) prior
// to this Read(Span<byte>) overload being introduced. In that case, this Read(Span<byte>) overload
// should use the behavior of Read(byte[],int,int) overload.
return base.Read(destination);
return base.Read(buffer);
}
else
{
return ReadCore(destination);
return ReadCore(buffer);
}
}
internal int ReadCore(Span<byte> destination)
internal int ReadCore(Span<byte> buffer)
{
EnsureDecompressionMode();
EnsureNotDisposed();
@@ -262,9 +262,9 @@ namespace System.IO.Compression
while (true)
{
int bytesRead = _inflater.Inflate(destination.Slice(totalRead));
int bytesRead = _inflater.Inflate(buffer.Slice(totalRead));
totalRead += bytesRead;
if (totalRead == destination.Length)
if (totalRead == buffer.Length)
{
break;
}
@@ -355,21 +355,21 @@ namespace System.IO.Compression
return ReadAsyncMemory(new Memory<byte>(array, offset, count), cancellationToken).AsTask();
}
public override ValueTask<int> ReadAsync(Memory<byte> destination, CancellationToken cancellationToken = default(CancellationToken))
public override ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken = default(CancellationToken))
{
if (GetType() != typeof(DeflateStream))
{
// Ensure that existing streams derived from DeflateStream and that override ReadAsync(byte[],...)
// get their existing behaviors when the newer Memory-based overload is used.
return base.ReadAsync(destination, cancellationToken);
return base.ReadAsync(buffer, cancellationToken);
}
else
{
return ReadAsyncMemory(destination, cancellationToken);
return ReadAsyncMemory(buffer, cancellationToken);
}
}
internal ValueTask<int> ReadAsyncMemory(Memory<byte> destination, CancellationToken cancellationToken)
internal ValueTask<int> ReadAsyncMemory(Memory<byte> buffer, CancellationToken cancellationToken)
{
EnsureDecompressionMode();
EnsureNoActiveAsyncOperation();
@@ -387,7 +387,7 @@ namespace System.IO.Compression
try
{
// Try to read decompressed data in output buffer
int bytesRead = _inflater.Inflate(destination.Span);
int bytesRead = _inflater.Inflate(buffer.Span);
if (bytesRead != 0)
{
// If decompression output buffer is not empty, return immediately.
@@ -404,7 +404,7 @@ namespace System.IO.Compression
// the end of the stream, we need to get more data from the base stream
ValueTask<int> readTask = _stream.ReadAsync(_buffer, cancellationToken);
cleanup = false;
return FinishReadAsyncMemory(readTask, destination, cancellationToken);
return FinishReadAsyncMemory(readTask, buffer, cancellationToken);
}
finally
{
@@ -417,7 +417,7 @@ namespace System.IO.Compression
}
private async ValueTask<int> FinishReadAsyncMemory(
ValueTask<int> readTask, Memory<byte> destination, CancellationToken cancellationToken)
ValueTask<int> readTask, Memory<byte> buffer, CancellationToken cancellationToken)
{
try
{
@@ -442,7 +442,7 @@ namespace System.IO.Compression
// Feed the data from base stream into decompression engine
_inflater.SetInput(_buffer, 0, bytesRead);
bytesRead = _inflater.Inflate(destination.Span);
bytesRead = _inflater.Inflate(buffer.Span);
if (bytesRead == 0 && !_inflater.Finished())
{
@@ -468,22 +468,22 @@ namespace System.IO.Compression
WriteCore(new ReadOnlySpan<byte>(array, offset, count));
}
public override void Write(ReadOnlySpan<byte> source)
public override void Write(ReadOnlySpan<byte> buffer)
{
if (GetType() != typeof(DeflateStream))
{
// DeflateStream is not sealed, and a derived type may have overridden Write(byte[], int, int) prior
// to this Write(ReadOnlySpan<byte>) overload being introduced. In that case, this Write(ReadOnlySpan<byte>) overload
// should use the behavior of Write(byte[],int,int) overload.
base.Write(source);
base.Write(buffer);
}
else
{
WriteCore(source);
WriteCore(buffer);
}
}
internal void WriteCore(ReadOnlySpan<byte> source)
internal void WriteCore(ReadOnlySpan<byte> buffer)
{
EnsureCompressionMode();
EnsureNotDisposed();
@@ -494,9 +494,9 @@ namespace System.IO.Compression
unsafe
{
// Pass new bytes through deflater and write them too:
fixed (byte* bufferPtr = &MemoryMarshal.GetReference(source))
fixed (byte* bufferPtr = &MemoryMarshal.GetReference(buffer))
{
_deflater.SetInput(bufferPtr, source.Length);
_deflater.SetInput(bufferPtr, buffer.Length);
WriteDeflaterOutput();
_wroteBytes = true;
}
@@ -643,35 +643,35 @@ namespace System.IO.Compression
public override Task WriteAsync(byte[] array, int offset, int count, CancellationToken cancellationToken)
{
ValidateParameters(array, offset, count);
return WriteAsyncMemory(new ReadOnlyMemory<byte>(array, offset, count), cancellationToken);
return WriteAsyncMemory(new ReadOnlyMemory<byte>(array, offset, count), cancellationToken).AsTask();
}
public override Task WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken)
public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken)
{
if (GetType() != typeof(DeflateStream))
{
// Ensure that existing streams derived from DeflateStream and that override WriteAsync(byte[],...)
// get their existing behaviors when the newer Memory-based overload is used.
return base.WriteAsync(source, cancellationToken);
return base.WriteAsync(buffer, cancellationToken);
}
else
{
return WriteAsyncMemory(source, cancellationToken);
return WriteAsyncMemory(buffer, cancellationToken);
}
}
internal Task WriteAsyncMemory(ReadOnlyMemory<byte> source, CancellationToken cancellationToken)
internal ValueTask WriteAsyncMemory(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken)
{
EnsureCompressionMode();
EnsureNoActiveAsyncOperation();
EnsureNotDisposed();
return cancellationToken.IsCancellationRequested ?
return new ValueTask(cancellationToken.IsCancellationRequested ?
Task.FromCanceled<int>(cancellationToken) :
WriteAsyncMemoryCore(source, cancellationToken);
WriteAsyncMemoryCore(buffer, cancellationToken));
}
private async Task WriteAsyncMemoryCore(ReadOnlyMemory<byte> source, CancellationToken cancellationToken)
private async Task WriteAsyncMemoryCore(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken)
{
AsyncOperationStarting();
try
@@ -679,7 +679,7 @@ namespace System.IO.Compression
await WriteDeflaterOutputAsync(cancellationToken).ConfigureAwait(false);
// Pass new bytes through deflater
_deflater.SetInput(source);
_deflater.SetInput(buffer);
await WriteDeflaterOutputAsync(cancellationToken).ConfigureAwait(false);
@@ -701,7 +701,7 @@ namespace System.IO.Compression
int compressedBytes = _deflater.GetDeflateOutput(_buffer);
if (compressedBytes > 0)
{
await _stream.WriteAsync(_buffer, 0, compressedBytes, cancellationToken).ConfigureAwait(false);
await _stream.WriteAsync(new ReadOnlyMemory<byte>(_buffer, 0, compressedBytes), cancellationToken).ConfigureAwait(false);
}
}
}
@@ -732,7 +732,6 @@ namespace System.IO.Compression
private readonly Stream _destination;
private readonly CancellationToken _cancellationToken;
private byte[] _arrayPoolBuffer;
private int _arrayPoolBufferHighWaterMark;
public CopyToAsyncStream(DeflateStream deflateStream, Stream destination, int bufferSize, CancellationToken cancellationToken)
{
@@ -757,8 +756,7 @@ namespace System.IO.Compression
int bytesRead = _deflateStream._inflater.Inflate(_arrayPoolBuffer, 0, _arrayPoolBuffer.Length);
if (bytesRead > 0)
{
if (bytesRead > _arrayPoolBufferHighWaterMark) _arrayPoolBufferHighWaterMark = bytesRead;
await _destination.WriteAsync(_arrayPoolBuffer, 0, bytesRead, _cancellationToken).ConfigureAwait(false);
await _destination.WriteAsync(new ReadOnlyMemory<byte>(_arrayPoolBuffer, 0, bytesRead), _cancellationToken).ConfigureAwait(false);
}
else break;
}
@@ -770,8 +768,7 @@ namespace System.IO.Compression
{
_deflateStream.AsyncOperationCompleting();
Array.Clear(_arrayPoolBuffer, 0, _arrayPoolBufferHighWaterMark); // clear only the most we used
ArrayPool<byte>.Shared.Return(_arrayPoolBuffer, clearArray: false);
ArrayPool<byte>.Shared.Return(_arrayPoolBuffer);
_arrayPoolBuffer = null;
}
}
@@ -787,7 +784,7 @@ namespace System.IO.Compression
}
else if (count > buffer.Length - offset)
{
// The source stream is either malicious or poorly implemented and returned a number of
// The buffer stream is either malicious or poorly implemented and returned a number of
// bytes larger than the buffer supplied to it.
throw new InvalidDataException(SR.GenericInvalidData);
}
@@ -795,14 +792,13 @@ namespace System.IO.Compression
// Feed the data from base stream into the decompression engine.
_deflateStream._inflater.SetInput(buffer, offset, count);
// While there's more decompressed data available, forward it to the destination stream.
// While there's more decompressed data available, forward it to the buffer stream.
while (true)
{
int bytesRead = _deflateStream._inflater.Inflate(_arrayPoolBuffer, 0, _arrayPoolBuffer.Length);
int bytesRead = _deflateStream._inflater.Inflate(new Span<byte>(_arrayPoolBuffer));
if (bytesRead > 0)
{
if (bytesRead > _arrayPoolBufferHighWaterMark) _arrayPoolBufferHighWaterMark = bytesRead;
await _destination.WriteAsync(_arrayPoolBuffer, 0, bytesRead, cancellationToken).ConfigureAwait(false);
await _destination.WriteAsync(new ReadOnlyMemory<byte>(_arrayPoolBuffer, 0, bytesRead), cancellationToken).ConfigureAwait(false);
}
else break;
}

View File

@@ -91,8 +91,6 @@ namespace System.IO.Compression
internal unsafe void SetInput(ReadOnlyMemory<byte> inputBuffer)
{
Debug.Assert(NeedsInput(), "We have something left in previous input!");
Debug.Assert(!_inputBufferHandle.HasPointer);
if (0 == inputBuffer.Length)
{
return;
@@ -100,7 +98,7 @@ namespace System.IO.Compression
lock (SyncLock)
{
_inputBufferHandle = inputBuffer.Retain(pin: true);
_inputBufferHandle = inputBuffer.Pin();
_zlibStream.NextIn = (IntPtr)_inputBufferHandle.Pointer;
_zlibStream.AvailIn = (uint)inputBuffer.Length;
@@ -111,7 +109,6 @@ namespace System.IO.Compression
{
Debug.Assert(NeedsInput(), "We have something left in previous input!");
Debug.Assert(inputBufferPtr != null);
Debug.Assert(!_inputBufferHandle.HasPointer);
if (count == 0)
{
@@ -182,7 +179,6 @@ namespace System.IO.Compression
Debug.Assert(null != outputBuffer, "Can't pass in a null output buffer!");
Debug.Assert(outputBuffer.Length > 0, "Can't pass in an empty output buffer!");
Debug.Assert(NeedsInput(), "We have something left in previous input!");
Debug.Assert(!_inputBufferHandle.HasPointer);
// Note: we require that NeedsInput() == true, i.e. that 0 == _zlibStream.AvailIn.

View File

@@ -84,19 +84,19 @@ namespace System.IO.Compression
return _deflateStream.Read(array, offset, count);
}
public override int Read(Span<byte> destination)
public override int Read(Span<byte> buffer)
{
if (GetType() != typeof(GZipStream))
{
// GZipStream is not sealed, and a derived type may have overridden Read(byte[], int, int) prior
// to this Read(Span<byte>) overload being introduced. In that case, this Read(Span<byte>) overload
// should use the behavior of Read(byte[],int,int) overload.
return base.Read(destination);
return base.Read(buffer);
}
else
{
CheckDeflateStream();
return _deflateStream.ReadCore(destination);
return _deflateStream.ReadCore(buffer);
}
}
@@ -112,19 +112,19 @@ namespace System.IO.Compression
_deflateStream.Write(array, offset, count);
}
public override void Write(ReadOnlySpan<byte> source)
public override void Write(ReadOnlySpan<byte> buffer)
{
if (GetType() != typeof(GZipStream))
{
// GZipStream is not sealed, and a derived type may have overridden Write(byte[], int, int) prior
// to this Write(ReadOnlySpan<byte>) overload being introduced. In that case, this Write(ReadOnlySpan<byte>) overload
// should use the behavior of Write(byte[],int,int) overload.
base.Write(source);
base.Write(buffer);
}
else
{
CheckDeflateStream();
_deflateStream.WriteCore(source);
_deflateStream.WriteCore(buffer);
}
}
@@ -158,19 +158,19 @@ namespace System.IO.Compression
return _deflateStream.ReadAsync(array, offset, count, cancellationToken);
}
public override ValueTask<int> ReadAsync(Memory<byte> destination, CancellationToken cancellationToken = default(CancellationToken))
public override ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken = default(CancellationToken))
{
if (GetType() != typeof(GZipStream))
{
// GZipStream is not sealed, and a derived type may have overridden ReadAsync(byte[], int, int) prior
// to this ReadAsync(Memory<byte>) overload being introduced. In that case, this ReadAsync(Memory<byte>) overload
// should use the behavior of ReadAsync(byte[],int,int) overload.
return base.ReadAsync(destination, cancellationToken);
return base.ReadAsync(buffer, cancellationToken);
}
else
{
CheckDeflateStream();
return _deflateStream.ReadAsyncMemory(destination, cancellationToken);
return _deflateStream.ReadAsyncMemory(buffer, cancellationToken);
}
}
@@ -180,19 +180,19 @@ namespace System.IO.Compression
return _deflateStream.WriteAsync(array, offset, count, cancellationToken);
}
public override Task WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken = default(CancellationToken))
public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken = default(CancellationToken))
{
if (GetType() != typeof(GZipStream))
{
// GZipStream is not sealed, and a derived type may have overridden WriteAsync(byte[], int, int) prior
// to this WriteAsync(ReadOnlyMemory<byte>) overload being introduced. In that case, this
// WriteAsync(ReadOnlyMemory<byte>) overload should use the behavior of Write(byte[],int,int) overload.
return base.WriteAsync(source, cancellationToken);
return base.WriteAsync(buffer, cancellationToken);
}
else
{
CheckDeflateStream();
return _deflateStream.WriteAsyncMemory(source, cancellationToken);
return _deflateStream.WriteAsyncMemory(buffer, cancellationToken);
}
}

View File

@@ -9,16 +9,16 @@ namespace System.IO.Compression
{
internal sealed partial class PositionPreservingWriteOnlyStreamWrapper : Stream
{
public override void Write(ReadOnlySpan<byte> source)
public override void Write(ReadOnlySpan<byte> buffer)
{
_position += source.Length;
_stream.Write(source);
_position += buffer.Length;
_stream.Write(buffer);
}
public override Task WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken = default(CancellationToken))
public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken = default(CancellationToken))
{
_position += source.Length;
return _stream.WriteAsync(source, cancellationToken);
_position += buffer.Length;
return _stream.WriteAsync(buffer, cancellationToken);
}
}
}

View File

@@ -72,7 +72,7 @@ namespace System.IO.Compression
ms.Position = 0;
using (var compressor = new DerivedDeflateStream(ms, CompressionMode.Compress, leaveOpen: true))
{
compressor.WriteAsync(new ReadOnlyMemory<byte>(new byte[1])).Wait();
compressor.WriteAsync(new ReadOnlyMemory<byte>(new byte[1])).AsTask().Wait();
Assert.True(compressor.WriteArrayInvoked);
}
}

View File

@@ -57,7 +57,7 @@ namespace System.IO.Compression
ms.Position = 0;
using (var compressor = new DerivedGZipStream(ms, CompressionMode.Compress, leaveOpen: true))
{
compressor.WriteAsync(new ReadOnlyMemory<byte>(new byte[1])).Wait();
compressor.WriteAsync(new ReadOnlyMemory<byte>(new byte[1])).AsTask().Wait();
Assert.True(compressor.WriteArrayInvoked);
}
}

View File

@@ -4,7 +4,7 @@
<PropertyGroup>
<AssemblyName>System.IO.Compression.Performance.Tests</AssemblyName>
<IncludePerformanceTests>true</IncludePerformanceTests>
<ProjectGuid>{1341F8C8-637A-49A1-BE0F-13867A634929}</ProjectGuid>
<ProjectGuid>{13C0F956-FB7B-4882-A411-39B8E22463D2}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netcoreapp-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netcoreapp-Release|AnyCPU'" />

View File

@@ -2,8 +2,8 @@
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<ProjectGuid>{BC2E1649-291D-412E-9529-EDDA94FA7AD6}</ProjectGuid>
<DefineConstants Condition="'$(TargetGroup)' == 'netcoreapp' or '$(TargetGroup)' == 'uap'">$(DefineConstants);netcoreapp;STREAM_MEMORY_OVERLOADS_AVAILABLE</DefineConstants>
<ProjectGuid>{17DA7FB5-4370-4385-9A02-FFEF9F482903}</ProjectGuid>
<DefineConstants Condition="'$(TargetGroup)' == 'netcoreapp' or '$(TargetGroup)' == 'uap'">$(DefineConstants);netcoreapp;STREAM_MEMORY_OVERLOADS_AVAILABLE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Unix-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Unix-Release|AnyCPU'" />
@@ -72,4 +72,4 @@
</SupplementalTestData>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
</Project>