Imported Upstream version 5.4.0.167

Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-08-21 15:34:15 +00:00
parent e49d6f06c0
commit 536cd135cc
12856 changed files with 563812 additions and 223249 deletions

View File

@@ -31,10 +31,10 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BC2E1649-291D-412E-9529-EDDA94FA7AD6}.Debug|Any CPU.ActiveCfg = netstandard-Windows_NT-Debug|Any CPU
{BC2E1649-291D-412E-9529-EDDA94FA7AD6}.Debug|Any CPU.Build.0 = netstandard-Windows_NT-Debug|Any CPU
{BC2E1649-291D-412E-9529-EDDA94FA7AD6}.Release|Any CPU.ActiveCfg = netstandard-Windows_NT-Release|Any CPU
{BC2E1649-291D-412E-9529-EDDA94FA7AD6}.Release|Any CPU.Build.0 = netstandard-Windows_NT-Release|Any CPU
{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

View File

@@ -2,8 +2,10 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\dir.props" />
<PropertyGroup>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyKey>ECMA</AssemblyKey>
<IsNETCoreApp>true</IsNETCoreApp>
<IsUAP>true</IsUAP>
<IsNetFxNETStandard>true</IsNetFxNETStandard>
</PropertyGroup>
</Project>

View File

@@ -4,6 +4,7 @@
<BuildConfigurations>
netcoreapp;
uap;
netfx;
</BuildConfigurations>
</PropertyGroup>
</Project>

View File

@@ -88,6 +88,7 @@ namespace System.IO.Compression
internal ZipArchiveEntry() { }
public System.IO.Compression.ZipArchive Archive { get { throw null; } }
public long CompressedLength { get { throw null; } }
public int ExternalAttributes { get { throw null; } set { } }
public string FullName { get { throw null; } }
public System.DateTimeOffset LastWriteTime { get { throw null; } set { } }
public long Length { get { throw null; } }

View File

@@ -2,21 +2,27 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<UseECMAKey>true</UseECMAKey>
<ProjectGuid>{4ADD9456-A929-4254-B8A2-16FC628ABFDA}</ProjectGuid>
<IsPartialFacadeAssembly Condition="'$(TargetGroup)' == 'netfx'">true</IsPartialFacadeAssembly>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Release|AnyCPU'" />
<ItemGroup>
<Compile Include="System.IO.Compression.cs" />
</ItemGroup>
<ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' != 'netfx'">
<ProjectReference Include="..\..\System.Runtime\ref\System.Runtime.csproj" />
<ProjectReference Include="..\..\System.IO\ref\System.IO.csproj" />
<ProjectReference Include="..\..\System.Text.Encoding\ref\System.Text.Encoding.csproj" />
<ProjectReference Include="..\..\System.Threading.Tasks\ref\System.Threading.Tasks.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netfx'">
<Reference Include="mscorlib" />
<Reference Include="System" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -0,0 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Security;
[assembly: SecurityTransparentAttribute()]

View File

@@ -5,6 +5,7 @@
netcoreapp-Unix;
netcoreapp-Windows_NT;
uap-Windows_NT;
netfx-Windows_NT;
</BuildConfigurations>
</PropertyGroup>
</Project>

View File

@@ -6,14 +6,15 @@
<OutputType>Library</OutputType>
<ProjectGuid>{5471BFE8-8071-466F-838E-5ADAA779E742}</ProjectGuid>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<UseECMAKey>true</UseECMAKey>
<DefineConstants Condition="'$(TargetGroup)' == 'netstandard'">$(DefineConstants);FEATURE_ZLIB</DefineConstants>
<IsPartialFacadeAssembly Condition="'$(TargetGroup)' == 'netfx'">true</IsPartialFacadeAssembly>
</PropertyGroup>
<!-- Default configurations to help VS understand the options -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Unix-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Unix-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Release|AnyCPU'" />
<ItemGroup>
@@ -43,6 +44,11 @@
<Compile Include="System\IO\Compression\DeflateManaged\OutputBuffer.cs" />
<Compile Include="System\IO\Compression\DeflateManaged\OutputWindow.cs" />
<Compile Include="System\IO\Compression\PositionPreservingWriteOnlyStreamWrapper.cs" />
<Compile Include="$(CommonPath)\System\Threading\Tasks\TaskToApm.cs">
<Link>Common\System\Threading\Tasks\TaskToApm.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' != 'netfx'">
<Compile Include="System\IO\Compression\CompressionLevel.cs" />
<Compile Include="System\IO\Compression\CompressionMode.cs" />
<Compile Include="System\IO\Compression\GZipStream.cs" />
@@ -55,9 +61,6 @@
<Compile Include="$(CommonPath)\System\IO\PathInternal.cs">
<Link>Common\System\IO\PathInternal.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Threading\Tasks\TaskToApm.cs">
<Link>Common\System\Threading\Tasks\TaskToApm.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\IO\StreamHelpers.CopyValidation.cs">
<Link>Common\System\IO\StreamHelpers.CopyValidation.cs</Link>
</Compile>
@@ -65,6 +68,8 @@
<!-- Windows specific files -->
<ItemGroup Condition=" '$(TargetsWindows)' == 'true'">
<Compile Include="System\IO\Compression\ZipArchiveEntry.Windows.cs" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetsWindows)' == 'true' AND '$(TargetGroup)' != 'netfx'">
<Compile Include="System\IO\Compression\DeflateZLib\ZLibNative.Windows.cs" />
<Compile Include="Interop\Interop.zlib.Windows.cs" />
<Compile Include="$(CommonPath)\System\IO\PathInternal.Windows.cs">
@@ -89,7 +94,7 @@
<Link>Common\Interop\Unix\System.Native\Interop.PathConf.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' != 'netfx'">
<Reference Include="System.Buffers" />
<Reference Include="System.Collections" />
<Reference Include="System.Diagnostics.Contracts" />
@@ -102,5 +107,10 @@
<Reference Include="System.Threading" />
<Reference Include="System.Threading.Tasks" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netfx'">
<Compile Include="AssemblyInfo.cs" />
<Reference Include="mscorlib" />
<Reference Include="System" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -16,17 +16,12 @@ namespace System.IO.Compression
/// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
protected ZLibException(SerializationInfo info, StreamingContext context) : base(info, context)
{
_zlibErrorContext = info.GetString("zlibErrorContext");
_zlibErrorCode = (ZLibNative.ErrorCode)info.GetInt32("zlibErrorCode");
_zlibErrorMessage = info.GetString("zlibErrorMessage");
throw new PlatformNotSupportedException();
}
void ISerializable.GetObjectData(SerializationInfo si, StreamingContext context)
{
base.GetObjectData(si, context);
si.AddValue("zlibErrorContext", _zlibErrorContext);
si.AddValue("zlibErrorCode", (int)_zlibErrorCode);
si.AddValue("zlibErrorMessage", _zlibErrorMessage);
}
}
}

View File

@@ -39,6 +39,7 @@ namespace System.IO.Compression
private bool _currentlyOpenForWrite;
private bool _everOpenedForWrite;
private Stream _outstandingWriteStream;
private uint _externalFileAttr;
private string _storedEntryName;
private byte[] _storedEntryNameBytes;
// only apply to update mode
@@ -70,6 +71,7 @@ namespace System.IO.Compression
_lastModified = new DateTimeOffset(ZipHelper.DosTimeToDateTime(cd.LastModified));
_compressedSize = cd.CompressedSize;
_uncompressedSize = cd.UncompressedSize;
_externalFileAttr = cd.ExternalFileAttributes;
_offsetOfLocalHeader = cd.RelativeOffsetOfLocalHeader;
// we don't know this yet: should be _offsetOfLocalHeader + 30 + _storedEntryNameBytes.Length + extrafieldlength
// but entryname/extra length could be different in LH
@@ -116,6 +118,7 @@ namespace System.IO.Compression
_compressedSize = 0; // we don't know these yet
_uncompressedSize = 0;
_externalFileAttr = 0;
_offsetOfLocalHeader = 0;
_storedOffsetOfCompressedData = null;
_crc32 = 0;
@@ -165,6 +168,19 @@ namespace System.IO.Compression
}
}
public int ExternalAttributes
{
get
{
return (int)_externalFileAttr;
}
set
{
ThrowIfInvalidArchive();
_externalFileAttr = (uint)value;
}
}
/// <summary>
/// The relative path of the entry as stored in the Zip archive. Note that Zip archives allow any string to be the path of the entry, including invalid and absolute paths.
/// </summary>
@@ -527,7 +543,7 @@ namespace System.IO.Compression
writer.Write(_fileComment != null ? (ushort)_fileComment.Length : (ushort)0); // file comment length
writer.Write((ushort)0); // disk number start
writer.Write((ushort)0); // internal file attributes
writer.Write((uint)0); // external file attributes
writer.Write(_externalFileAttr); // external file attributes
writer.Write(offsetOfLocalHeaderTruncated); // offset of local header
writer.Write(_storedEntryNameBytes);

View File

@@ -85,6 +85,33 @@ namespace System.IO.Compression.Tests
[Fact]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Full Framework Flush is a no-op.")]
public async Task OverlappingFlushAsync_DuringReadAsync()
{
byte[] buffer = new byte[32];
string testFilePath = gzTestFile("GZTestDocument.pdf.gz");
using (var readStream = await ManualSyncMemoryStream.GetStreamFromFileAsync(testFilePath, false, StripHeaders))
using (var unzip = CreateStream(readStream, CompressionMode.Decompress, true))
{
Task task = null;
try
{
readStream.manualResetEvent.Reset();
readStream.ReadHit = false;
task = ReadAsync(unzip, buffer, 0, 32);
Assert.True(readStream.ReadHit);
Assert.Throws<InvalidOperationException>(() => { unzip.FlushAsync(); }); // "overlapping read"
}
finally
{
// Unblock Async operations
readStream.manualResetEvent.Set();
// The original ReadAsync should be able to complete
Assert.True(task.Wait(100 * 500));
}
}
}
[Fact]
public async Task OverlappingWriteAsync()
{
byte[] buffer = null;
@@ -101,7 +128,6 @@ namespace System.IO.Compression.Tests
try
{
task = WriteAsync(zip, buffer, 0, buffer.Length); // write needs to be bigger than the internal write buffer
Assert.True(writeStream.WriteHit);
Assert.Throws<InvalidOperationException>(() => { zip.WriteAsync(buffer, 32, 32); }); // "overlapping write"
}
finally
@@ -110,12 +136,12 @@ namespace System.IO.Compression.Tests
writeStream.manualResetEvent.Set();
// The original WriteAsync should be able to complete
Assert.True(task.Wait(100 * 500));
Assert.True(writeStream.WriteHit);
}
}
}
[Fact]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Full Framework Flush is a no-op.")]
public async Task OverlappingReadAsync()
{
byte[] buffer = new byte[32];
@@ -127,7 +153,6 @@ namespace System.IO.Compression.Tests
try
{
task = ReadAsync(unzip, buffer, 0, 32);
Assert.True(readStream.ReadHit);
Assert.Throws<InvalidOperationException>(() => { ReadAsync(unzip, buffer, 0, 32); }); // "overlapping read"
}
finally
@@ -136,31 +161,7 @@ namespace System.IO.Compression.Tests
readStream.manualResetEvent.Set();
// The original ReadAsync should be able to complete
Assert.True(task.Wait(100 * 500));
}
}
}
[Fact]
public async Task OverlappingFlushAsync_DuringReadAsync()
{
byte[] buffer = new byte[32];
string testFilePath = gzTestFile("GZTestDocument.pdf.gz");
using (var readStream = await ManualSyncMemoryStream.GetStreamFromFileAsync(testFilePath, false, StripHeaders))
using (var unzip = CreateStream(readStream, CompressionMode.Decompress, true))
{
Task task = null;
try
{
task = ReadAsync(unzip, buffer, 0, 32);
Assert.True(readStream.ReadHit);
Assert.Throws<InvalidOperationException>(() => { unzip.FlushAsync(); }); // "overlapping read"
}
finally
{
// Unblock Async operations
readStream.manualResetEvent.Set();
// The original ReadAsync should be able to complete
Assert.True(task.Wait(100 * 500));
}
}
}
@@ -238,4 +239,26 @@ namespace System.IO.Compression.Tests
public override Stream CreateStream(Stream stream, CompressionMode mode) => new GZipStream(stream, mode);
public override Stream CreateStream(Stream stream, CompressionMode mode, bool leaveOpen) => new GZipStream(stream, mode, leaveOpen);
}
}
public sealed class BeginEndDeflateStreamTests : CompressionStreamAsyncTestBase
{
public override bool StripHeaders => true;
public override Task<int> ReadAsync(Stream unzip, byte[] buffer, int offset, int count) =>
Task<int>.Factory.FromAsync<byte[], int, int>(((DeflateStream)unzip).BeginRead, ((DeflateStream)unzip).EndRead, buffer, offset, count, null);
public override Task WriteAsync(Stream unzip, byte[] buffer, int offset, int count) =>
Task.Factory.FromAsync<byte[], int, int>(((DeflateStream)unzip).BeginWrite, ((DeflateStream)unzip).EndWrite, buffer, offset, count, null);
public override Stream CreateStream(Stream stream, CompressionMode mode) => new DeflateStream(stream, mode);
public override Stream CreateStream(Stream stream, CompressionMode mode, bool leaveOpen) => new DeflateStream(stream, mode, leaveOpen);
}
public sealed class BeginEndGZipStreamTests : CompressionStreamAsyncTestBase
{
public override bool StripHeaders => false;
public override Task<int> ReadAsync(Stream unzip, byte[] buffer, int offset, int count) =>
Task<int>.Factory.FromAsync<byte[], int, int>(((GZipStream)unzip).BeginRead, ((GZipStream)unzip).EndRead, buffer, offset, count, null);
public override Task WriteAsync(Stream unzip, byte[] buffer, int offset, int count) =>
Task.Factory.FromAsync<byte[], int, int>(((GZipStream)unzip).BeginWrite, ((GZipStream)unzip).EndWrite, buffer, offset, count, null);
public override Stream CreateStream(Stream stream, CompressionMode mode) => new GZipStream(stream, mode);
public override Stream CreateStream(Stream stream, CompressionMode mode, bool leaveOpen) => new GZipStream(stream, mode, leaveOpen);
}
}

View File

@@ -1,30 +0,0 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Threading.Tasks;
namespace System.IO.Compression.Tests
{
public sealed class BeginEndDeflateStreamTests : CompressionStreamAsyncTestBase
{
public override bool StripHeaders => true;
public override Task<int> ReadAsync(Stream unzip, byte[] buffer, int offset, int count) =>
Task<int>.Factory.FromAsync<byte[], int, int>(((DeflateStream)unzip).BeginRead, ((DeflateStream)unzip).EndRead, buffer, offset, count, null);
public override Task WriteAsync(Stream unzip, byte[] buffer, int offset, int count) =>
Task.Factory.FromAsync<byte[], int, int>(((DeflateStream)unzip).BeginWrite, ((DeflateStream)unzip).EndWrite, buffer, offset, count, null);
public override Stream CreateStream(Stream stream, CompressionMode mode) => new DeflateStream(stream, mode);
public override Stream CreateStream(Stream stream, CompressionMode mode, bool leaveOpen) => new DeflateStream(stream, mode, leaveOpen);
}
public sealed class BeginEndGZipStreamTests : CompressionStreamAsyncTestBase
{
public override bool StripHeaders => false;
public override Task<int> ReadAsync(Stream unzip, byte[] buffer, int offset, int count) =>
Task<int>.Factory.FromAsync<byte[], int, int>(((GZipStream)unzip).BeginRead, ((GZipStream)unzip).EndRead, buffer, offset, count, null);
public override Task WriteAsync(Stream unzip, byte[] buffer, int offset, int count) =>
Task.Factory.FromAsync<byte[], int, int>(((GZipStream)unzip).BeginWrite, ((GZipStream)unzip).EndWrite, buffer, offset, count, null);
public override Stream CreateStream(Stream stream, CompressionMode mode) => new GZipStream(stream, mode);
public override Stream CreateStream(Stream stream, CompressionMode mode, bool leaveOpen) => new GZipStream(stream, mode, leaveOpen);
}
}

View File

@@ -4,6 +4,8 @@
<BuildConfigurations>
netstandard-Unix;
netstandard-Windows_NT;
netcoreapp-Unix;
netcoreapp-Windows_NT;
</BuildConfigurations>
</PropertyGroup>
</Project>

View File

@@ -408,8 +408,8 @@ namespace System.IO.Compression.Tests
{
using (DeflateStream ds = new DeflateStream(new MemoryStream(), CompressionMode.Decompress))
{
Assert.Throws<ArgumentNullException>("destination", () => { ds.CopyToAsync(null); });
Assert.Throws<ArgumentOutOfRangeException>("bufferSize", () => { ds.CopyToAsync(new MemoryStream(), 0); });
AssertExtensions.Throws<ArgumentNullException>("destination", () => { ds.CopyToAsync(null); });
AssertExtensions.Throws<ArgumentOutOfRangeException>("bufferSize", () => { ds.CopyToAsync(new MemoryStream(), 0); });
Assert.Throws<NotSupportedException>(() => { ds.CopyToAsync(new MemoryStream(new byte[1], writable: false)); });
ds.Dispose();
Assert.Throws<ObjectDisposedException>(() => { ds.CopyToAsync(new MemoryStream()); });
@@ -833,6 +833,11 @@ namespace System.IO.Compression.Tests
isSync = sync;
}
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) => TaskToApm.Begin(ReadAsync(buffer, offset, count), callback, state);
public override int EndRead(IAsyncResult asyncResult) => TaskToApm.End<int>(asyncResult);
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) => TaskToApm.Begin(WriteAsync(buffer, offset, count), callback, state);
public override void EndWrite(IAsyncResult asyncResult) => TaskToApm.End(asyncResult);
public override async Task<int> ReadAsync(byte[] array, int offset, int count, CancellationToken cancellationToken)
{
ReadHit = true;
@@ -863,4 +868,4 @@ namespace System.IO.Compression.Tests
await base.WriteAsync(array, offset, count, cancellationToken);
}
}
}
}

View File

@@ -217,8 +217,8 @@ namespace System.IO.Compression.Tests
{
using (GZipStream gs = new GZipStream(new MemoryStream(), CompressionMode.Decompress))
{
Assert.Throws<ArgumentNullException>("destination", () => { gs.CopyToAsync(null); });
Assert.Throws<ArgumentOutOfRangeException>("bufferSize", () => { gs.CopyToAsync(new MemoryStream(), 0); });
AssertExtensions.Throws<ArgumentNullException>("destination", () => { gs.CopyToAsync(null); });
AssertExtensions.Throws<ArgumentOutOfRangeException>("bufferSize", () => { gs.CopyToAsync(new MemoryStream(), 0); });
Assert.Throws<NotSupportedException>(() => { gs.CopyToAsync(new MemoryStream(new byte[1], writable: false)); });
gs.Dispose();
Assert.Throws<ObjectDisposedException>(() => { gs.CopyToAsync(new MemoryStream()); });

View File

@@ -23,7 +23,7 @@
</Compile>
</ItemGroup>
<ItemGroup>
<SupplementalTestData Include="$(PackagesDir)System.IO.Compression.TestData\1.0.4-prerelease\content\**\*.*">
<SupplementalTestData Include="$(PackagesDir)system.io.compression.testdata\1.0.5-prerelease\content\**\*.*">
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
</SupplementalTestData>
</ItemGroup>

View File

@@ -4,13 +4,16 @@
<PropertyGroup>
<ProjectGuid>{BC2E1649-291D-412E-9529-EDDA94FA7AD6}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Unix-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Unix-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Unix-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Unix-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Windows_NT-Release|AnyCPU'" />
<ItemGroup>
<Compile Include="AsyncStreamTests.cs" />
<Compile Include="AsyncStreamTests.netstandard.cs" />
<Compile Include="DeflateStreamTests.cs" />
<Compile Include="GZipStreamTests.cs" />
<Compile Include="XunitAssemblyAttributes.cs" />
@@ -21,6 +24,12 @@
<Compile Include="ZipArchive\zip_UpdateTests.cs" />
<Compile Include="Utilities\StripHeaderAndFooter.cs" />
<Compile Include="Utilities\WrappedStream.cs" />
<Compile Include="$(CommonTestPath)\System\AssertExtensions.cs">
<Link>Common\System\AssertExtensions.cs</Link>
</Compile>
<Compile Include="$(CommonTestPath)\System\IO\PathFeatures.cs">
<Link>Common\System\IO\PathFeatures.cs</Link>
</Compile>
<Compile Include="$(CommonTestPath)\System\IO\Compression\CRC.cs">
<Link>Common\System\IO\Compression\CRC.cs</Link>
</Compile>
@@ -42,11 +51,17 @@
<Compile Include="$(CommonTestPath)\System\IO\Compression\ZipTestHelper.cs">
<Link>Common\System\IO\Compression\ZipTestHelper.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\System\Threading\Tasks\TaskToApm.cs">
<Link>Common\System\Threading\Tasks\TaskToApm.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
<Compile Include="ZipArchive\zip_netcoreappTests.cs" />
</ItemGroup>
<ItemGroup>
<SupplementalTestData Include="$(PackagesDir)System.IO.Compression.TestData\1.0.4-prerelease\content\**\*.*">
<SupplementalTestData Include="$(PackagesDir)system.io.compression.testdata\1.0.5-prerelease\content\**\*.*">
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
</SupplementalTestData>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
</Project>

View File

@@ -9,6 +9,8 @@ namespace System.IO.Compression.Tests
{
public class zip_ManualAndCompatabilityTests : ZipFileTestBase
{
public static bool IsUsingNewPathNormalization => !PathFeatures.IsUsingLegacyPathNormalization();
[Theory]
[InlineData("7zip.zip", "normal", true, true)]
[InlineData("windows.zip", "normalWithoutEmptyDir", false, true)]
@@ -45,7 +47,7 @@ namespace System.IO.Compression.Tests
/// For example, the file "aa\bb\cc\dd" in a zip created on Unix should be one file "aa\bb\cc\dd" whereas the same file
/// in a zip created on Windows should be interpreted as the file "dd" underneath three subdirectories.
/// </summary>
[Theory]
[ConditionalTheory(nameof(IsUsingNewPathNormalization))]
[InlineData("backslashes_FromUnix.zip", "aa\\bb\\cc\\dd")]
[InlineData("backslashes_FromWindows.zip", "dd")]
[InlineData("WindowsInvalid_FromUnix.zip", "aa<b>d")]

View File

@@ -0,0 +1,56 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Xunit;
namespace System.IO.Compression.Tests
{
public class zip_netcoreappTests : ZipFileTestBase
{
[Theory]
[InlineData("sharpziplib.zip", 0)]
[InlineData("Linux_RW_RW_R__.zip", 0x8000 + 0x0100 + 0x0080 + 0x0020 + 0x0010 + 0x0004)]
[InlineData("Linux_RWXRW_R__.zip", 0x8000 + 0x01C0 + 0x0020 + 0x0010 + 0x0004)]
[InlineData("OSX_RWXRW_R__.zip", 0x8000 + 0x01C0 + 0x0020 + 0x0010 + 0x0004)]
public static async Task Read_UnixFilePermissions(string zipName, uint expectedAttr)
{
using (ZipArchive archive = new ZipArchive(await StreamHelpers.CreateTempCopyStream(compat(zipName)), ZipArchiveMode.Read))
{
foreach (ZipArchiveEntry e in archive.Entries)
{
Assert.Equal(expectedAttr, ((uint)e.ExternalAttributes) >> 16);
}
}
}
[Theory]
[InlineData(int.MaxValue)]
[InlineData(int.MinValue)]
[InlineData(0)]
[InlineData((0x8000 + 0x01C0 + 0x0020 + 0x0010 + 0x0004) << 16)]
public static async Task RoundTrips_UnixFilePermissions(int expectedAttr)
{
using (var stream = await StreamHelpers.CreateTempCopyStream(zfile("normal.zip")))
{
using (ZipArchive archive = new ZipArchive(stream, ZipArchiveMode.Update, true))
{
foreach (ZipArchiveEntry e in archive.Entries)
{
e.ExternalAttributes = expectedAttr;
Assert.Equal(expectedAttr, e.ExternalAttributes);
}
}
using (ZipArchive archive = new ZipArchive(stream, ZipArchiveMode.Read))
{
foreach (ZipArchiveEntry e in archive.Entries)
{
Assert.Equal(expectedAttr, e.ExternalAttributes);
}
}
}
}
}
}