You've already forked linux-packaging-mono
Imported Upstream version 5.4.0.167
Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
parent
e49d6f06c0
commit
536cd135cc
3
external/corefx/src/System.IO/dir.props
vendored
3
external/corefx/src/System.IO/dir.props
vendored
@@ -2,7 +2,8 @@
|
||||
<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>MSFT</AssemblyKey>
|
||||
<IsNETCoreApp>true</IsNETCoreApp>
|
||||
<IsUAP>true</IsUAP>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// 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.
|
||||
|
||||
@@ -114,6 +114,8 @@ namespace System.IO.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Difference in behavior that added extra checks to BinaryReader/Writer buffers on .Net Core")]
|
||||
[ActiveIssue(20753, TargetFrameworkMonikers.UapAot)]
|
||||
public void Read_InvalidEncoding()
|
||||
{
|
||||
using (var str = CreateStream())
|
||||
@@ -125,7 +127,7 @@ namespace System.IO.Tests
|
||||
|
||||
using (var reader = new BinaryReader(str, new NegEncoding()))
|
||||
{
|
||||
Assert.Throws<ArgumentOutOfRangeException>("charsRemaining", () => reader.Read(new char[10], 0, 10));
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("charsRemaining", () => reader.Read(new char[10], 0, 10));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace System.IO.Tests
|
||||
using (BufferedStream stream = new BufferedStream(new MemoryStream()))
|
||||
{
|
||||
byte[] array = new byte[10];
|
||||
Assert.Throws<ArgumentNullException>("array", () => stream.Read(null, 1, 1));
|
||||
AssertExtensions.Throws<ArgumentNullException>("array", () => stream.Read(null, 1, 1));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => stream.Read(array, -1, 1));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => stream.Read(array, 1, -1));
|
||||
Assert.Throws<ArgumentException>(() => stream.Read(array, 9, 2));
|
||||
@@ -63,7 +63,7 @@ namespace System.IO.Tests
|
||||
using (BufferedStream stream = new BufferedStream(new MemoryStream()))
|
||||
{
|
||||
byte[] array = new byte[10];
|
||||
Assert.Throws<ArgumentNullException>("array", () => stream.Write(null, 1, 1));
|
||||
AssertExtensions.Throws<ArgumentNullException>("array", () => stream.Write(null, 1, 1));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => stream.Write(array, -1, 1));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => stream.Write(array, 1, -1));
|
||||
Assert.Throws<ArgumentException>(() => stream.Write(array, 9, 2));
|
||||
@@ -119,11 +119,11 @@ namespace System.IO.Tests
|
||||
using (var s = new BufferedStream(new MemoryStream()))
|
||||
{
|
||||
// Null destination
|
||||
Assert.Throws<ArgumentNullException>("destination", () => { s.CopyToAsync(null); });
|
||||
AssertExtensions.Throws<ArgumentNullException>("destination", () => { s.CopyToAsync(null); });
|
||||
|
||||
// Buffer size out-of-range
|
||||
Assert.Throws<ArgumentOutOfRangeException>("bufferSize", () => { s.CopyToAsync(new MemoryStream(), 0); });
|
||||
Assert.Throws<ArgumentOutOfRangeException>("bufferSize", () => { s.CopyToAsync(new MemoryStream(), -1, CancellationToken.None); });
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("bufferSize", () => { s.CopyToAsync(new MemoryStream(), 0); });
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("bufferSize", () => { s.CopyToAsync(new MemoryStream(), -1, CancellationToken.None); });
|
||||
|
||||
// Copying to non-writable stream
|
||||
Assert.Throws<NotSupportedException>(() => { s.CopyToAsync(new WrappedMemoryStream(canRead: true, canWrite: false, canSeek: true)); });
|
||||
|
||||
@@ -278,4 +278,31 @@ namespace System.IO.Tests
|
||||
throw new InvalidOperationException("Exception from FlushAsync");
|
||||
}
|
||||
}
|
||||
|
||||
public class BufferedStream_NS17
|
||||
{
|
||||
protected Stream CreateStream()
|
||||
{
|
||||
return new BufferedStream(new MemoryStream());
|
||||
}
|
||||
|
||||
public void EndCallback(IAsyncResult ar)
|
||||
{ }
|
||||
|
||||
[Fact]
|
||||
public void BeginEndReadTest()
|
||||
{
|
||||
Stream stream = CreateStream();
|
||||
IAsyncResult result = stream.BeginRead(new byte[1], 0, 1, new AsyncCallback(EndCallback), new object());
|
||||
stream.EndRead(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BeginEndWriteTest()
|
||||
{
|
||||
Stream stream = CreateStream();
|
||||
IAsyncResult result = stream.BeginWrite(new byte[1], 0, 1, new AsyncCallback(EndCallback), new object());
|
||||
stream.EndWrite(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,40 +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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace System.IO.Tests
|
||||
{
|
||||
public class BufferedStream_NS17
|
||||
{
|
||||
protected Stream CreateStream()
|
||||
{
|
||||
return new BufferedStream(new MemoryStream());
|
||||
}
|
||||
|
||||
public void EndCallback(IAsyncResult ar)
|
||||
{ }
|
||||
|
||||
[Fact]
|
||||
public void BeginEndReadTest()
|
||||
{
|
||||
Stream stream = CreateStream();
|
||||
IAsyncResult result = stream.BeginRead(new byte[1], 0, 1, new AsyncCallback(EndCallback), new object());
|
||||
stream.EndRead(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BeginEndWriteTest()
|
||||
{
|
||||
Stream stream = CreateStream();
|
||||
IAsyncResult result = stream.BeginWrite(new byte[1], 0, 1, new AsyncCallback(EndCallback), new object());
|
||||
stream.EndWrite(result);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// 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 Xunit;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
@@ -202,20 +203,20 @@ namespace System.IO.Tests
|
||||
MemoryStream memoryStream;
|
||||
using (memoryStream = new MemoryStream())
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("destination", () => memoryStream.CopyTo(destination: null));
|
||||
AssertExtensions.Throws<ArgumentNullException>("destination", () => memoryStream.CopyTo(destination: null));
|
||||
|
||||
// Validate the destination parameter first.
|
||||
Assert.Throws<ArgumentNullException>("destination", () => memoryStream.CopyTo(destination: null, bufferSize: 0));
|
||||
Assert.Throws<ArgumentNullException>("destination", () => memoryStream.CopyTo(destination: null, bufferSize: -1));
|
||||
AssertExtensions.Throws<ArgumentNullException>("destination", () => memoryStream.CopyTo(destination: null, bufferSize: 0));
|
||||
AssertExtensions.Throws<ArgumentNullException>("destination", () => memoryStream.CopyTo(destination: null, bufferSize: -1));
|
||||
|
||||
// Then bufferSize.
|
||||
Assert.Throws<ArgumentOutOfRangeException>("bufferSize", () => memoryStream.CopyTo(Stream.Null, bufferSize: 0)); // 0-length buffer doesn't make sense.
|
||||
Assert.Throws<ArgumentOutOfRangeException>("bufferSize", () => memoryStream.CopyTo(Stream.Null, bufferSize: -1));
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("bufferSize", () => memoryStream.CopyTo(Stream.Null, bufferSize: 0)); // 0-length buffer doesn't make sense.
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("bufferSize", () => memoryStream.CopyTo(Stream.Null, bufferSize: -1));
|
||||
}
|
||||
|
||||
// After the Stream is disposed, we should fail on all CopyTos.
|
||||
Assert.Throws<ArgumentOutOfRangeException>("bufferSize", () => memoryStream.CopyTo(Stream.Null, bufferSize: 0)); // Not before bufferSize is validated.
|
||||
Assert.Throws<ArgumentOutOfRangeException>("bufferSize", () => memoryStream.CopyTo(Stream.Null, bufferSize: -1));
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("bufferSize", () => memoryStream.CopyTo(Stream.Null, bufferSize: 0)); // Not before bufferSize is validated.
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("bufferSize", () => memoryStream.CopyTo(Stream.Null, bufferSize: -1));
|
||||
|
||||
MemoryStream disposedStream = memoryStream;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// 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;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -274,14 +275,14 @@ namespace System.IO.Tests
|
||||
Assert.Equal(TaskStatus.Canceled, stream.WriteAsync(new byte[1], 0, 1, new CancellationToken(canceled: true)).Status);
|
||||
Assert.Equal(TaskStatus.Canceled, stream.FlushAsync(new CancellationToken(canceled: true)).Status);
|
||||
|
||||
Assert.Throws<ArgumentNullException>("buffer", () => { stream.ReadAsync(null, 0, 0); });
|
||||
Assert.Throws<ArgumentNullException>("buffer", () => { stream.WriteAsync(null, 0, 0); });
|
||||
AssertExtensions.Throws<ArgumentNullException>("buffer", () => { stream.ReadAsync(null, 0, 0); });
|
||||
AssertExtensions.Throws<ArgumentNullException>("buffer", () => { stream.WriteAsync(null, 0, 0); });
|
||||
|
||||
Assert.Throws<ArgumentOutOfRangeException>("offset", () => { stream.ReadAsync(new byte[1], -1, 0); });
|
||||
Assert.Throws<ArgumentOutOfRangeException>("offset", () => { stream.WriteAsync(new byte[1], -1, 0); });
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("offset", () => { stream.ReadAsync(new byte[1], -1, 0); });
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("offset", () => { stream.WriteAsync(new byte[1], -1, 0); });
|
||||
|
||||
Assert.Throws<ArgumentOutOfRangeException>("count", () => { stream.ReadAsync(new byte[1], 0, -1); });
|
||||
Assert.Throws<ArgumentOutOfRangeException>("count", () => { stream.WriteAsync(new byte[1], 0, -1); });
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => { stream.ReadAsync(new byte[1], 0, -1); });
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => { stream.WriteAsync(new byte[1], 0, -1); });
|
||||
|
||||
Assert.Throws<ArgumentException>(() => { stream.ReadAsync(new byte[1], 0, 2); });
|
||||
Assert.Throws<ArgumentException>(() => { stream.WriteAsync(new byte[1], 0, 2); });
|
||||
|
||||
@@ -57,6 +57,7 @@ namespace System.IO.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ActiveIssue(20753, TargetFrameworkMonikers.UapAot)]
|
||||
public async static Task TestNullStream_CopyToAsyncValidation()
|
||||
{
|
||||
// Since Stream.Null previously inherited its CopyToAsync
|
||||
|
||||
@@ -14,13 +14,13 @@ namespace System.IO.Tests
|
||||
[Fact]
|
||||
public static void NullArgs_ThrowsArgumentNullException()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("path", () => new StreamReader((string)null));
|
||||
Assert.Throws<ArgumentNullException>("path", () => new StreamReader((string)null, null));
|
||||
Assert.Throws<ArgumentNullException>("path", () => new StreamReader((string)null, null, true));
|
||||
Assert.Throws<ArgumentNullException>("path", () => new StreamReader((string)null, null, true, -1));
|
||||
Assert.Throws<ArgumentNullException>("encoding", () => new StreamReader("", null));
|
||||
Assert.Throws<ArgumentNullException>("encoding", () => new StreamReader("", null, true));
|
||||
Assert.Throws<ArgumentNullException>("encoding", () => new StreamReader("", null, true, -1));
|
||||
AssertExtensions.Throws<ArgumentNullException>("path", () => new StreamReader((string)null));
|
||||
AssertExtensions.Throws<ArgumentNullException>("path", () => new StreamReader((string)null, null));
|
||||
AssertExtensions.Throws<ArgumentNullException>("path", () => new StreamReader((string)null, null, true));
|
||||
AssertExtensions.Throws<ArgumentNullException>("path", () => new StreamReader((string)null, null, true, -1));
|
||||
AssertExtensions.Throws<ArgumentNullException>("encoding", () => new StreamReader("", null));
|
||||
AssertExtensions.Throws<ArgumentNullException>("encoding", () => new StreamReader("", null, true));
|
||||
AssertExtensions.Throws<ArgumentNullException>("encoding", () => new StreamReader("", null, true, -1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -36,8 +36,8 @@ namespace System.IO.Tests
|
||||
[Fact]
|
||||
public static void NegativeBufferSize_ThrowsArgumentOutOfRangeException()
|
||||
{
|
||||
Assert.Throws<ArgumentOutOfRangeException>("bufferSize", () => new StreamReader("path", Encoding.UTF8, true, -1));
|
||||
Assert.Throws<ArgumentOutOfRangeException>("bufferSize", () => new StreamReader("path", Encoding.UTF8, true, 0));
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("bufferSize", () => new StreamReader("path", Encoding.UTF8, true, -1));
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("bufferSize", () => new StreamReader("path", Encoding.UTF8, true, 0));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
||||
@@ -15,14 +15,14 @@ namespace System.IO.Tests
|
||||
[Fact]
|
||||
public static void NullArgs_ThrowsArgumentNullException()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("path", () => new StreamWriter((string)null));
|
||||
Assert.Throws<ArgumentNullException>("path", () => new StreamWriter((string)null, true));
|
||||
Assert.Throws<ArgumentNullException>("path", () => new StreamWriter((string)null, true, null));
|
||||
Assert.Throws<ArgumentNullException>("path", () => new StreamWriter((string)null, true, null, -1));
|
||||
Assert.Throws<ArgumentNullException>("encoding", () => new StreamWriter("path", true, null));
|
||||
Assert.Throws<ArgumentNullException>("encoding", () => new StreamWriter("path", true, null, -1));
|
||||
Assert.Throws<ArgumentNullException>("encoding", () => new StreamWriter("", true, null));
|
||||
Assert.Throws<ArgumentNullException>("encoding", () => new StreamWriter("", true, null, -1));
|
||||
AssertExtensions.Throws<ArgumentNullException>("path", () => new StreamWriter((string)null));
|
||||
AssertExtensions.Throws<ArgumentNullException>("path", () => new StreamWriter((string)null, true));
|
||||
AssertExtensions.Throws<ArgumentNullException>("path", () => new StreamWriter((string)null, true, null));
|
||||
AssertExtensions.Throws<ArgumentNullException>("path", () => new StreamWriter((string)null, true, null, -1));
|
||||
AssertExtensions.Throws<ArgumentNullException>("encoding", () => new StreamWriter("path", true, null));
|
||||
AssertExtensions.Throws<ArgumentNullException>("encoding", () => new StreamWriter("path", true, null, -1));
|
||||
AssertExtensions.Throws<ArgumentNullException>("encoding", () => new StreamWriter("", true, null));
|
||||
AssertExtensions.Throws<ArgumentNullException>("encoding", () => new StreamWriter("", true, null, -1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -38,8 +38,8 @@ namespace System.IO.Tests
|
||||
[Fact]
|
||||
public static void NegativeBufferSize_ThrowsArgumentOutOfRangeException()
|
||||
{
|
||||
Assert.Throws<ArgumentOutOfRangeException>("bufferSize", () => new StreamWriter("path", false, Encoding.UTF8, -1));
|
||||
Assert.Throws<ArgumentOutOfRangeException>("bufferSize", () => new StreamWriter("path", true, Encoding.UTF8, 0));
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("bufferSize", () => new StreamWriter("path", false, Encoding.UTF8, -1));
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("bufferSize", () => new StreamWriter("path", true, Encoding.UTF8, 0));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -195,6 +195,7 @@ namespace System.IO.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Full framework throws NullReferenceException")]
|
||||
public async Task NullNewLineAsync()
|
||||
{
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
|
||||
@@ -391,6 +391,7 @@ namespace System.IO.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Full framework throws NullReferenceException")]
|
||||
public async Task NullNewLineAsync()
|
||||
{
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
|
||||
@@ -15,13 +15,12 @@
|
||||
<Compile Include="IndentedTextWriter.cs" />
|
||||
<Compile Include="BinaryReader\BinaryReaderTests.cs" />
|
||||
<Compile Include="MemoryStream\MemoryStream.GetBufferTests.cs" />
|
||||
<Compile Include="Stream\Stream.netstandard.cs" />
|
||||
<Compile Include="StreamReader\StreamReader.netstandard.cs" />
|
||||
<Compile Include="Stream\Stream.cs" />
|
||||
<Compile Include="StreamReader\StreamReader.cs" />
|
||||
<Compile Include="StreamReader\StreamReader.StringCtorTests.cs" />
|
||||
<Compile Include="StreamWriter\StreamWriter.netstandard.cs" />
|
||||
<Compile Include="StreamWriter\StreamWriter.cs" />
|
||||
<Compile Include="StreamWriter\StreamWriter.StringCtorTests.cs" />
|
||||
<Compile Include="Stream\Stream.APMMethodsTests.cs" />
|
||||
<Compile Include="BufferedStream\BufferedStreamTests.netstandard.cs" />
|
||||
<Compile Include="BinaryWriter\BinaryWriter.WriteByteCharTests.cs" />
|
||||
<Compile Include="BinaryWriter\BinaryWriter.WriteTests.cs" />
|
||||
<Compile Include="BinaryWriter\BinaryWriterTests.cs" />
|
||||
@@ -48,6 +47,9 @@
|
||||
<Compile Include="Stream\Stream.TimeoutTests.cs" />
|
||||
<Compile Include="StringReader\StringReader.CtorTests.cs" />
|
||||
<Compile Include="StringWriter\StringWriterTests.cs" />
|
||||
<Compile Include="$(CommonTestPath)\System\AssertExtensions.cs">
|
||||
<Link>Common\System\AssertExtensions.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonTestPath)\System\IO\CallTrackingStream.cs">
|
||||
<Link>Common\System\IO\CallTrackingStream.cs</Link>
|
||||
</Compile>
|
||||
@@ -59,4 +61,4 @@
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user