From b3b846c27eee1364db416f35dec4556469509fb4 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Sun, 12 Mar 2017 14:58:54 -0700 Subject: [PATCH] Remove net451 as a cross-compile target --- .gitignore | 1 + samples/SampleApp/SampleApp.csproj | 2 +- ...rosoft.AspNetCore.Http.Abstractions.csproj | 2 +- ...icrosoft.AspNetCore.Http.Extensions.csproj | 2 +- .../Microsoft.AspNetCore.Http.Features.csproj | 2 +- .../FormCollection.cs | 5 ---- .../HeaderDictionary.cs | 5 ---- .../HttpContextAccessor.cs | 24 --------------- .../Internal/QueryCollection.cs | 5 ---- .../Internal/ReferenceReadStream.cs | 24 ++++++++------- .../Internal/RequestCookieCollection.cs | 4 --- .../Microsoft.AspNetCore.Http.csproj | 2 +- .../Microsoft.AspNetCore.Owin.csproj | 2 +- .../BufferedReadStream.cs | 25 +++++++++------- .../FileBufferingReadStream.cs | 25 +++++++++------- .../HttpRequestStreamReader.cs | 5 +++- .../Microsoft.AspNetCore.WebUtilities.csproj | 2 +- .../MultipartReaderStream.cs | 29 ++++++++++--------- .../Microsoft.Net.Http.Headers.csproj | 2 +- ....AspNetCore.Http.Abstractions.Tests.csproj | 2 +- ...ft.AspNetCore.Http.Extensions.Tests.csproj | 2 +- ...soft.AspNetCore.Http.Features.Tests.csproj | 2 +- .../HttpContextFactoryTests.cs | 7 +++-- .../Microsoft.AspNetCore.Http.Tests.csproj | 4 ++- .../Microsoft.AspNetCore.Owin.Tests.csproj | 2 +- .../FileBufferingReadStreamTests.cs | 2 +- .../HttpResponseStreamWriterTest.cs | 12 ++++---- ...osoft.AspNetCore.WebUtilities.Tests.csproj | 2 +- .../Microsoft.Net.Http.Headers.Tests.csproj | 2 +- 29 files changed, 90 insertions(+), 115 deletions(-) diff --git a/.gitignore b/.gitignore index 0f91ad1208..bcc811de9a 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ project.lock.json .build/ .testPublish/ /.vs/ +global.json diff --git a/samples/SampleApp/SampleApp.csproj b/samples/SampleApp/SampleApp.csproj index d496a4e293..349d945d26 100644 --- a/samples/SampleApp/SampleApp.csproj +++ b/samples/SampleApp/SampleApp.csproj @@ -3,7 +3,7 @@ - netcoreapp2.0;net451 + netcoreapp2.0;net46 Exe diff --git a/src/Microsoft.AspNetCore.Http.Abstractions/Microsoft.AspNetCore.Http.Abstractions.csproj b/src/Microsoft.AspNetCore.Http.Abstractions/Microsoft.AspNetCore.Http.Abstractions.csproj index 0f57ef2bba..ab10fcc573 100644 --- a/src/Microsoft.AspNetCore.Http.Abstractions/Microsoft.AspNetCore.Http.Abstractions.csproj +++ b/src/Microsoft.AspNetCore.Http.Abstractions/Microsoft.AspNetCore.Http.Abstractions.csproj @@ -10,7 +10,7 @@ Microsoft.AspNetCore.Builder.IApplicationBuilder Microsoft.AspNetCore.Http.HttpContext Microsoft.AspNetCore.Http.HttpRequest Microsoft.AspNetCore.Http.HttpResponse - net451;netstandard1.3 + netstandard1.3 true aspnetcore $(NoWarn);CS1591 diff --git a/src/Microsoft.AspNetCore.Http.Extensions/Microsoft.AspNetCore.Http.Extensions.csproj b/src/Microsoft.AspNetCore.Http.Extensions/Microsoft.AspNetCore.Http.Extensions.csproj index 4f76ac1def..9f9a858a8a 100644 --- a/src/Microsoft.AspNetCore.Http.Extensions/Microsoft.AspNetCore.Http.Extensions.csproj +++ b/src/Microsoft.AspNetCore.Http.Extensions/Microsoft.AspNetCore.Http.Extensions.csproj @@ -4,7 +4,7 @@ ASP.NET Core common extension methods for HTTP abstractions, HTTP headers, HTTP request/response, and session state. - net451;netstandard1.3 + netstandard1.3 $(NoWarn);CS1591 true aspnetcore diff --git a/src/Microsoft.AspNetCore.Http.Features/Microsoft.AspNetCore.Http.Features.csproj b/src/Microsoft.AspNetCore.Http.Features/Microsoft.AspNetCore.Http.Features.csproj index 3974becb6d..e14b016d26 100644 --- a/src/Microsoft.AspNetCore.Http.Features/Microsoft.AspNetCore.Http.Features.csproj +++ b/src/Microsoft.AspNetCore.Http.Features/Microsoft.AspNetCore.Http.Features.csproj @@ -4,7 +4,7 @@ ASP.NET Core HTTP feature interface definitions. - net451;netstandard1.3 + netstandard1.3 $(NoWarn);CS1591 true aspnetcore diff --git a/src/Microsoft.AspNetCore.Http/FormCollection.cs b/src/Microsoft.AspNetCore.Http/FormCollection.cs index 564fdcbb29..23709b2bb0 100644 --- a/src/Microsoft.AspNetCore.Http/FormCollection.cs +++ b/src/Microsoft.AspNetCore.Http/FormCollection.cs @@ -15,13 +15,8 @@ namespace Microsoft.AspNetCore.Http public class FormCollection : IFormCollection { public static readonly FormCollection Empty = new FormCollection(); -#if NETSTANDARD1_3 private static readonly string[] EmptyKeys = Array.Empty(); private static readonly StringValues[] EmptyValues = Array.Empty(); -#else - private static readonly string[] EmptyKeys = new string[0]; - private static readonly StringValues[] EmptyValues = new StringValues[0]; -#endif private static readonly Enumerator EmptyEnumerator = new Enumerator(); // Pre-box private static readonly IEnumerator> EmptyIEnumeratorType = EmptyEnumerator; diff --git a/src/Microsoft.AspNetCore.Http/HeaderDictionary.cs b/src/Microsoft.AspNetCore.Http/HeaderDictionary.cs index 61c307a64e..30d338a20b 100644 --- a/src/Microsoft.AspNetCore.Http/HeaderDictionary.cs +++ b/src/Microsoft.AspNetCore.Http/HeaderDictionary.cs @@ -14,13 +14,8 @@ namespace Microsoft.AspNetCore.Http /// public class HeaderDictionary : IHeaderDictionary { -#if NETSTANDARD1_3 private static readonly string[] EmptyKeys = Array.Empty(); private static readonly StringValues[] EmptyValues = Array.Empty(); -#else - private static readonly string[] EmptyKeys = new string[0]; - private static readonly StringValues[] EmptyValues = new StringValues[0]; -#endif private static readonly Enumerator EmptyEnumerator = new Enumerator(); // Pre-box private static readonly IEnumerator> EmptyIEnumeratorType = EmptyEnumerator; diff --git a/src/Microsoft.AspNetCore.Http/HttpContextAccessor.cs b/src/Microsoft.AspNetCore.Http/HttpContextAccessor.cs index 324eb8ad97..5a4676234c 100644 --- a/src/Microsoft.AspNetCore.Http/HttpContextAccessor.cs +++ b/src/Microsoft.AspNetCore.Http/HttpContextAccessor.cs @@ -1,35 +1,12 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -#if NET451 -using System; -using System.Runtime.Remoting; -using System.Runtime.Remoting.Messaging; -#elif NETSTANDARD1_3 using System.Threading; -#endif namespace Microsoft.AspNetCore.Http { public class HttpContextAccessor : IHttpContextAccessor { -#if NET451 - private static readonly string LogicalDataKey = "__HttpContext_Current__" + AppDomain.CurrentDomain.Id; - - public HttpContext HttpContext - { - get - { - var handle = CallContext.LogicalGetData(LogicalDataKey) as ObjectHandle; - return handle?.Unwrap() as HttpContext; - } - set - { - CallContext.LogicalSetData(LogicalDataKey, new ObjectHandle(value)); - } - } - -#elif NETSTANDARD1_3 private static AsyncLocal _httpContextCurrent = new AsyncLocal(); public HttpContext HttpContext @@ -43,6 +20,5 @@ namespace Microsoft.AspNetCore.Http _httpContextCurrent.Value = value; } } -#endif } } diff --git a/src/Microsoft.AspNetCore.Http/Internal/QueryCollection.cs b/src/Microsoft.AspNetCore.Http/Internal/QueryCollection.cs index f2db4a874c..643034deaf 100644 --- a/src/Microsoft.AspNetCore.Http/Internal/QueryCollection.cs +++ b/src/Microsoft.AspNetCore.Http/Internal/QueryCollection.cs @@ -14,13 +14,8 @@ namespace Microsoft.AspNetCore.Http.Internal public class QueryCollection : IQueryCollection { public static readonly QueryCollection Empty = new QueryCollection(); -#if NETSTANDARD1_3 private static readonly string[] EmptyKeys = Array.Empty(); private static readonly StringValues[] EmptyValues = Array.Empty(); -#else - private static readonly string[] EmptyKeys = new string[0]; - private static readonly StringValues[] EmptyValues = new StringValues[0]; -#endif private static readonly Enumerator EmptyEnumerator = new Enumerator(); // Pre-box private static readonly IEnumerator> EmptyIEnumeratorType = EmptyEnumerator; diff --git a/src/Microsoft.AspNetCore.Http/Internal/ReferenceReadStream.cs b/src/Microsoft.AspNetCore.Http/Internal/ReferenceReadStream.cs index 8a8c1e95de..fbc435f406 100644 --- a/src/Microsoft.AspNetCore.Http/Internal/ReferenceReadStream.cs +++ b/src/Microsoft.AspNetCore.Http/Internal/ReferenceReadStream.cs @@ -115,7 +115,7 @@ namespace Microsoft.AspNetCore.Http.Internal _position += read; return read; } -#if NET451 +#if NET46 public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { ThrowIfDisposed(); @@ -164,16 +164,6 @@ namespace Microsoft.AspNetCore.Http.Internal var task = (Task)asyncResult; return task.GetAwaiter().GetResult(); } -#endif - public override void Write(byte[] buffer, int offset, int count) - { - throw new NotSupportedException(); - } - public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) - { - throw new NotSupportedException(); - } -#if NET451 public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { throw new NotSupportedException(); @@ -183,7 +173,19 @@ namespace Microsoft.AspNetCore.Http.Internal { throw new NotSupportedException(); } +#elif NETSTANDARD1_3 +#else +#error Target frameworks need to be updated. #endif + public override void Write(byte[] buffer, int offset, int count) + { + throw new NotSupportedException(); + } + public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) + { + throw new NotSupportedException(); + } + public override void SetLength(long value) { throw new NotSupportedException(); diff --git a/src/Microsoft.AspNetCore.Http/Internal/RequestCookieCollection.cs b/src/Microsoft.AspNetCore.Http/Internal/RequestCookieCollection.cs index 1555b0b7a4..d02c9fade5 100644 --- a/src/Microsoft.AspNetCore.Http/Internal/RequestCookieCollection.cs +++ b/src/Microsoft.AspNetCore.Http/Internal/RequestCookieCollection.cs @@ -11,11 +11,7 @@ namespace Microsoft.AspNetCore.Http.Internal public class RequestCookieCollection : IRequestCookieCollection { public static readonly RequestCookieCollection Empty = new RequestCookieCollection(); -#if NETSTANDARD1_3 private static readonly string[] EmptyKeys = Array.Empty(); -#else - private static readonly string[] EmptyKeys = new string[0]; -#endif private static readonly Enumerator EmptyEnumerator = new Enumerator(); // Pre-box private static readonly IEnumerator> EmptyIEnumeratorType = EmptyEnumerator; diff --git a/src/Microsoft.AspNetCore.Http/Microsoft.AspNetCore.Http.csproj b/src/Microsoft.AspNetCore.Http/Microsoft.AspNetCore.Http.csproj index f0163c501c..1623b6fcce 100644 --- a/src/Microsoft.AspNetCore.Http/Microsoft.AspNetCore.Http.csproj +++ b/src/Microsoft.AspNetCore.Http/Microsoft.AspNetCore.Http.csproj @@ -4,7 +4,7 @@ ASP.NET Core default HTTP feature implementations. - net451;netstandard1.3 + netstandard1.3;net46 $(NoWarn);CS1591 true true diff --git a/src/Microsoft.AspNetCore.Owin/Microsoft.AspNetCore.Owin.csproj b/src/Microsoft.AspNetCore.Owin/Microsoft.AspNetCore.Owin.csproj index e9af551d5f..356eafe318 100644 --- a/src/Microsoft.AspNetCore.Owin/Microsoft.AspNetCore.Owin.csproj +++ b/src/Microsoft.AspNetCore.Owin/Microsoft.AspNetCore.Owin.csproj @@ -4,7 +4,7 @@ ASP.NET Core component for running OWIN middleware in an ASP.NET Core application, and to run ASP.NET Core middleware in an OWIN application. - net451;netstandard1.3 + netstandard1.3 $(NoWarn);CS1591 true aspnetcore;owin diff --git a/src/Microsoft.AspNetCore.WebUtilities/BufferedReadStream.cs b/src/Microsoft.AspNetCore.WebUtilities/BufferedReadStream.cs index ef72c199c9..5d581164dc 100644 --- a/src/Microsoft.AspNetCore.WebUtilities/BufferedReadStream.cs +++ b/src/Microsoft.AspNetCore.WebUtilities/BufferedReadStream.cs @@ -162,17 +162,7 @@ namespace Microsoft.AspNetCore.WebUtilities { _inner.Write(buffer, offset, count); } -#if NET451 - public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) - { - return _inner.BeginWrite(buffer, offset, count, callback, state); - } - public override void EndWrite(IAsyncResult asyncResult) - { - _inner.EndWrite(asyncResult); - } -#endif public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) { return _inner.WriteAsync(buffer, offset, count, cancellationToken); @@ -211,7 +201,17 @@ namespace Microsoft.AspNetCore.WebUtilities return await _inner.ReadAsync(buffer, offset, count, cancellationToken); } -#if NET451 +#if NET46 + public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) + { + return _inner.BeginWrite(buffer, offset, count, callback, state); + } + + public override void EndWrite(IAsyncResult asyncResult) + { + _inner.EndWrite(asyncResult); + } + // We only anticipate using ReadAsync public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { @@ -262,6 +262,9 @@ namespace Microsoft.AspNetCore.WebUtilities } return _inner.EndRead(asyncResult); } +#elif NETSTANDARD1_3 +#else +#error Target frameworks need to be updated. #endif public bool EnsureBuffered() { diff --git a/src/Microsoft.AspNetCore.WebUtilities/FileBufferingReadStream.cs b/src/Microsoft.AspNetCore.WebUtilities/FileBufferingReadStream.cs index 2eea705a57..db72b3af84 100644 --- a/src/Microsoft.AspNetCore.WebUtilities/FileBufferingReadStream.cs +++ b/src/Microsoft.AspNetCore.WebUtilities/FileBufferingReadStream.cs @@ -250,7 +250,7 @@ namespace Microsoft.AspNetCore.WebUtilities return read; } -#if NET451 +#if NET46 public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { ThrowIfDisposed(); @@ -298,6 +298,19 @@ namespace Microsoft.AspNetCore.WebUtilities var task = (Task)asyncResult; return task.GetAwaiter().GetResult(); } + + public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) + { + throw new NotSupportedException(); + } + + public override void EndWrite(IAsyncResult asyncResult) + { + throw new NotSupportedException(); + } +#elif NETSTANDARD1_3 +#else +#error Target frameworks need to be updated. #endif public override async Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) { @@ -358,17 +371,7 @@ namespace Microsoft.AspNetCore.WebUtilities { throw new NotSupportedException(); } -#if NET451 - public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) - { - throw new NotSupportedException(); - } - public override void EndWrite(IAsyncResult asyncResult) - { - throw new NotSupportedException(); - } -#endif public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) { throw new NotSupportedException(); diff --git a/src/Microsoft.AspNetCore.WebUtilities/HttpRequestStreamReader.cs b/src/Microsoft.AspNetCore.WebUtilities/HttpRequestStreamReader.cs index 67977ca6f0..08331555c4 100644 --- a/src/Microsoft.AspNetCore.WebUtilities/HttpRequestStreamReader.cs +++ b/src/Microsoft.AspNetCore.WebUtilities/HttpRequestStreamReader.cs @@ -108,11 +108,14 @@ namespace Microsoft.AspNetCore.WebUtilities } } -#if NET451 +#if NET46 public override void Close() { Dispose(true); } +#elif NETSTANDARD1_3 +#else +#error Target frameworks need to be updated. #endif protected override void Dispose(bool disposing) diff --git a/src/Microsoft.AspNetCore.WebUtilities/Microsoft.AspNetCore.WebUtilities.csproj b/src/Microsoft.AspNetCore.WebUtilities/Microsoft.AspNetCore.WebUtilities.csproj index 1f900cb99a..d4b6bc397e 100644 --- a/src/Microsoft.AspNetCore.WebUtilities/Microsoft.AspNetCore.WebUtilities.csproj +++ b/src/Microsoft.AspNetCore.WebUtilities/Microsoft.AspNetCore.WebUtilities.csproj @@ -4,7 +4,7 @@ ASP.NET Core utilities, such as for working with forms, multipart messages, and query strings. - net451;netstandard1.3 + netstandard1.3;net46 $(DefineConstants);WebEncoders_In_WebUtilities $(NoWarn);CS1591 true diff --git a/src/Microsoft.AspNetCore.WebUtilities/MultipartReaderStream.cs b/src/Microsoft.AspNetCore.WebUtilities/MultipartReaderStream.cs index bc40b08afc..c2a266db0d 100644 --- a/src/Microsoft.AspNetCore.WebUtilities/MultipartReaderStream.cs +++ b/src/Microsoft.AspNetCore.WebUtilities/MultipartReaderStream.cs @@ -126,17 +126,7 @@ namespace Microsoft.AspNetCore.WebUtilities { throw new NotSupportedException(); } -#if NET451 - public override IAsyncResult BeginWrite(byte[] buffer, int offset, int size, AsyncCallback callback, object state) - { - throw new NotSupportedException(); - } - public override void EndWrite(IAsyncResult asyncResult) - { - throw new NotSupportedException(); - } -#endif public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) { throw new NotSupportedException(); @@ -168,7 +158,17 @@ namespace Microsoft.AspNetCore.WebUtilities } return read; } -#if NET451 +#if NET46 + public override IAsyncResult BeginWrite(byte[] buffer, int offset, int size, AsyncCallback callback, object state) + { + throw new NotSupportedException(); + } + + public override void EndWrite(IAsyncResult asyncResult) + { + throw new NotSupportedException(); + } + public override IAsyncResult BeginRead(byte[] buffer, int offset, int size, AsyncCallback callback, object state) { var tcs = new TaskCompletionSource(state); @@ -215,6 +215,9 @@ namespace Microsoft.AspNetCore.WebUtilities var task = (Task)asyncResult; return task.GetAwaiter().GetResult(); } +#elif NETSTANDARD1_3 +#else +#error Target frameworks need to be updated. #endif public override int Read(byte[] buffer, int offset, int count) { @@ -231,10 +234,8 @@ namespace Microsoft.AspNetCore.WebUtilities var bufferedData = _innerStream.BufferedData; // scan for a boundary match, full or partial. - int matchOffset; - int matchCount; int read; - if (SubMatch(bufferedData, _boundary.BoundaryBytes, out matchOffset, out matchCount)) + if (SubMatch(bufferedData, _boundary.BoundaryBytes, out var matchOffset, out var matchCount)) { // We found a possible match, return any data before it. if (matchOffset > bufferedData.Offset) diff --git a/src/Microsoft.Net.Http.Headers/Microsoft.Net.Http.Headers.csproj b/src/Microsoft.Net.Http.Headers/Microsoft.Net.Http.Headers.csproj index a32841da8e..8dc2020da1 100644 --- a/src/Microsoft.Net.Http.Headers/Microsoft.Net.Http.Headers.csproj +++ b/src/Microsoft.Net.Http.Headers/Microsoft.Net.Http.Headers.csproj @@ -4,7 +4,7 @@ HTTP header parser implementations. - net451;netstandard1.1 + netstandard1.1 $(NoWarn);CS1591 true true diff --git a/test/Microsoft.AspNetCore.Http.Abstractions.Tests/Microsoft.AspNetCore.Http.Abstractions.Tests.csproj b/test/Microsoft.AspNetCore.Http.Abstractions.Tests/Microsoft.AspNetCore.Http.Abstractions.Tests.csproj index ce293532eb..72ef16dc34 100644 --- a/test/Microsoft.AspNetCore.Http.Abstractions.Tests/Microsoft.AspNetCore.Http.Abstractions.Tests.csproj +++ b/test/Microsoft.AspNetCore.Http.Abstractions.Tests/Microsoft.AspNetCore.Http.Abstractions.Tests.csproj @@ -3,7 +3,7 @@ - netcoreapp2.0;net452 + netcoreapp2.0;net46 netcoreapp2.0 diff --git a/test/Microsoft.AspNetCore.Http.Extensions.Tests/Microsoft.AspNetCore.Http.Extensions.Tests.csproj b/test/Microsoft.AspNetCore.Http.Extensions.Tests/Microsoft.AspNetCore.Http.Extensions.Tests.csproj index d7a065af56..12e14311b0 100644 --- a/test/Microsoft.AspNetCore.Http.Extensions.Tests/Microsoft.AspNetCore.Http.Extensions.Tests.csproj +++ b/test/Microsoft.AspNetCore.Http.Extensions.Tests/Microsoft.AspNetCore.Http.Extensions.Tests.csproj @@ -3,7 +3,7 @@ - netcoreapp2.0;net452 + netcoreapp2.0;net46 netcoreapp2.0 diff --git a/test/Microsoft.AspNetCore.Http.Features.Tests/Microsoft.AspNetCore.Http.Features.Tests.csproj b/test/Microsoft.AspNetCore.Http.Features.Tests/Microsoft.AspNetCore.Http.Features.Tests.csproj index fde9ce797e..9b9b88308d 100644 --- a/test/Microsoft.AspNetCore.Http.Features.Tests/Microsoft.AspNetCore.Http.Features.Tests.csproj +++ b/test/Microsoft.AspNetCore.Http.Features.Tests/Microsoft.AspNetCore.Http.Features.Tests.csproj @@ -3,7 +3,7 @@ - netcoreapp2.0;net452 + netcoreapp2.0;net46 netcoreapp2.0 diff --git a/test/Microsoft.AspNetCore.Http.Tests/HttpContextFactoryTests.cs b/test/Microsoft.AspNetCore.Http.Tests/HttpContextFactoryTests.cs index c7bb075df9..ee1249897b 100644 --- a/test/Microsoft.AspNetCore.Http.Tests/HttpContextFactoryTests.cs +++ b/test/Microsoft.AspNetCore.Http.Tests/HttpContextFactoryTests.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.IO; using Microsoft.AspNetCore.Http.Features; using Microsoft.Extensions.ObjectPool; using Microsoft.Extensions.Options; @@ -36,7 +37,7 @@ namespace Microsoft.AspNetCore.Http contextFactory.Dispose(context); } -#if NET452 +#if NET46 private static void DomainFunc() { var accessor = new HttpContextAccessor(); @@ -50,9 +51,11 @@ namespace Microsoft.AspNetCore.Http // Arrange var accessor = new HttpContextAccessor(); var contextFactory = new HttpContextFactory(new DefaultObjectPoolProvider(), Options.Create(new FormOptions()), accessor); + var baseDirectory = AppDomain.CurrentDomain.BaseDirectory; var setupInfo = new AppDomainSetup { - ApplicationBase = AppDomain.CurrentDomain.BaseDirectory + ApplicationBase = baseDirectory, + ConfigurationFile = Path.Combine(baseDirectory, Path.GetFileNameWithoutExtension(GetType().Assembly.Location) + ".dll.config"), }; var domain = AppDomain.CreateDomain("newDomain", null, setupInfo); diff --git a/test/Microsoft.AspNetCore.Http.Tests/Microsoft.AspNetCore.Http.Tests.csproj b/test/Microsoft.AspNetCore.Http.Tests/Microsoft.AspNetCore.Http.Tests.csproj index 9de27f7667..902e0a52b6 100644 --- a/test/Microsoft.AspNetCore.Http.Tests/Microsoft.AspNetCore.Http.Tests.csproj +++ b/test/Microsoft.AspNetCore.Http.Tests/Microsoft.AspNetCore.Http.Tests.csproj @@ -3,8 +3,10 @@ - netcoreapp2.0;net452 + netcoreapp2.0;net46 netcoreapp2.0 + true + true diff --git a/test/Microsoft.AspNetCore.Owin.Tests/Microsoft.AspNetCore.Owin.Tests.csproj b/test/Microsoft.AspNetCore.Owin.Tests/Microsoft.AspNetCore.Owin.Tests.csproj index 30a4721d3c..7c97057bf0 100644 --- a/test/Microsoft.AspNetCore.Owin.Tests/Microsoft.AspNetCore.Owin.Tests.csproj +++ b/test/Microsoft.AspNetCore.Owin.Tests/Microsoft.AspNetCore.Owin.Tests.csproj @@ -3,7 +3,7 @@ - netcoreapp2.0;net452 + netcoreapp2.0;net46 netcoreapp2.0 diff --git a/test/Microsoft.AspNetCore.WebUtilities.Tests/FileBufferingReadStreamTests.cs b/test/Microsoft.AspNetCore.WebUtilities.Tests/FileBufferingReadStreamTests.cs index ea8e609b49..0ffc8506fb 100644 --- a/test/Microsoft.AspNetCore.WebUtilities.Tests/FileBufferingReadStreamTests.cs +++ b/test/Microsoft.AspNetCore.WebUtilities.Tests/FileBufferingReadStreamTests.cs @@ -293,7 +293,7 @@ namespace Microsoft.AspNetCore.WebUtilities private static string GetCurrentDirectory() { -#if NET452 +#if NET46 return AppDomain.CurrentDomain.BaseDirectory; #elif NETCOREAPP2_0 return AppContext.BaseDirectory; diff --git a/test/Microsoft.AspNetCore.WebUtilities.Tests/HttpResponseStreamWriterTest.cs b/test/Microsoft.AspNetCore.WebUtilities.Tests/HttpResponseStreamWriterTest.cs index 41a73e8876..878accd163 100644 --- a/test/Microsoft.AspNetCore.WebUtilities.Tests/HttpResponseStreamWriterTest.cs +++ b/test/Microsoft.AspNetCore.WebUtilities.Tests/HttpResponseStreamWriterTest.cs @@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.WebUtilities.Test Assert.Equal(expectedData, memoryStream.ToArray()); } -#if NET452 +#if NET46 [Fact] public async Task DoesNotFlush_UnderlyingStream_OnClosingWriter() { @@ -71,7 +71,7 @@ namespace Microsoft.AspNetCore.WebUtilities.Test Assert.Equal(0, stream.FlushAsyncCallCount); } -#if NET452 +#if NET46 [Fact] public async Task DoesNotClose_UnderlyingStream_OnDisposingWriter() { @@ -119,7 +119,7 @@ namespace Microsoft.AspNetCore.WebUtilities.Test await writer.WriteAsync(new string('a', byteLength)); // Act -#if NET452 +#if NET46 writer.Close(); #elif NETCOREAPP2_0 writer.Dispose(); @@ -345,7 +345,7 @@ namespace Microsoft.AspNetCore.WebUtilities.Test [Theory] [InlineData("你好世界", "utf-16")] -#if NET452 +#if NET46 // CoreCLR does not like shift_jis as an encoding. [InlineData("こんにちは世界", "shift_jis")] #elif NETCOREAPP2_0 @@ -379,7 +379,7 @@ namespace Microsoft.AspNetCore.WebUtilities.Test [InlineData('你', 1023, "utf-16")] [InlineData('你', 1024, "utf-16")] [InlineData('你', 1050, "utf-16")] -#if NET452 +#if NET46 // CoreCLR does not like shift_jis as an encoding. [InlineData('こ', 1023, "shift_jis")] [InlineData('こ', 1024, "shift_jis")] @@ -516,7 +516,7 @@ namespace Microsoft.AspNetCore.WebUtilities.Test return base.WriteAsync(buffer, offset, count, cancellationToken); } -#if NET452 +#if NET46 public override void Close() { CloseCallCount++; diff --git a/test/Microsoft.AspNetCore.WebUtilities.Tests/Microsoft.AspNetCore.WebUtilities.Tests.csproj b/test/Microsoft.AspNetCore.WebUtilities.Tests/Microsoft.AspNetCore.WebUtilities.Tests.csproj index c4c0973c46..ab9cca9cd5 100644 --- a/test/Microsoft.AspNetCore.WebUtilities.Tests/Microsoft.AspNetCore.WebUtilities.Tests.csproj +++ b/test/Microsoft.AspNetCore.WebUtilities.Tests/Microsoft.AspNetCore.WebUtilities.Tests.csproj @@ -3,7 +3,7 @@ - netcoreapp2.0;net452 + netcoreapp2.0;net46 netcoreapp2.0 diff --git a/test/Microsoft.Net.Http.Headers.Tests/Microsoft.Net.Http.Headers.Tests.csproj b/test/Microsoft.Net.Http.Headers.Tests/Microsoft.Net.Http.Headers.Tests.csproj index 1996f25c58..3b151518ba 100644 --- a/test/Microsoft.Net.Http.Headers.Tests/Microsoft.Net.Http.Headers.Tests.csproj +++ b/test/Microsoft.Net.Http.Headers.Tests/Microsoft.Net.Http.Headers.Tests.csproj @@ -3,7 +3,7 @@ - netcoreapp2.0;net452 + netcoreapp2.0;net46 netcoreapp2.0