Remove net451 as a cross-compile target

This commit is contained in:
Pranav K 2017-03-12 14:58:54 -07:00
parent 49daa416ba
commit b3b846c27e
29 changed files with 90 additions and 115 deletions

1
.gitignore vendored
View File

@ -28,3 +28,4 @@ project.lock.json
.build/
.testPublish/
/.vs/
global.json

View File

@ -3,7 +3,7 @@
<Import Project="..\..\build\dependencies.props" />
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net451</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
<OutputType>Exe</OutputType>
</PropertyGroup>

View File

@ -10,7 +10,7 @@ Microsoft.AspNetCore.Builder.IApplicationBuilder
Microsoft.AspNetCore.Http.HttpContext
Microsoft.AspNetCore.Http.HttpRequest
Microsoft.AspNetCore.Http.HttpResponse</Description>
<TargetFrameworks>net451;netstandard1.3</TargetFrameworks>
<TargetFramework>netstandard1.3</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore</PackageTags>
<NoWarn>$(NoWarn);CS1591</NoWarn>

View File

@ -4,7 +4,7 @@
<PropertyGroup>
<Description>ASP.NET Core common extension methods for HTTP abstractions, HTTP headers, HTTP request/response, and session state.</Description>
<TargetFrameworks>net451;netstandard1.3</TargetFrameworks>
<TargetFramework>netstandard1.3</TargetFramework>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore</PackageTags>

View File

@ -4,7 +4,7 @@
<PropertyGroup>
<Description>ASP.NET Core HTTP feature interface definitions.</Description>
<TargetFrameworks>net451;netstandard1.3</TargetFrameworks>
<TargetFramework>netstandard1.3</TargetFramework>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore</PackageTags>

View File

@ -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<string>();
private static readonly StringValues[] EmptyValues = Array.Empty<StringValues>();
#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<KeyValuePair<string, StringValues>> EmptyIEnumeratorType = EmptyEnumerator;

View File

@ -14,13 +14,8 @@ namespace Microsoft.AspNetCore.Http
/// </summary>
public class HeaderDictionary : IHeaderDictionary
{
#if NETSTANDARD1_3
private static readonly string[] EmptyKeys = Array.Empty<string>();
private static readonly StringValues[] EmptyValues = Array.Empty<StringValues>();
#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<KeyValuePair<string, StringValues>> EmptyIEnumeratorType = EmptyEnumerator;

View File

@ -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<HttpContext> _httpContextCurrent = new AsyncLocal<HttpContext>();
public HttpContext HttpContext
@ -43,6 +20,5 @@ namespace Microsoft.AspNetCore.Http
_httpContextCurrent.Value = value;
}
}
#endif
}
}

View File

@ -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<string>();
private static readonly StringValues[] EmptyValues = Array.Empty<StringValues>();
#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<KeyValuePair<string, StringValues>> EmptyIEnumeratorType = EmptyEnumerator;

View File

@ -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<int>)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();

View File

@ -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<string>();
#else
private static readonly string[] EmptyKeys = new string[0];
#endif
private static readonly Enumerator EmptyEnumerator = new Enumerator();
// Pre-box
private static readonly IEnumerator<KeyValuePair<string, string>> EmptyIEnumeratorType = EmptyEnumerator;

View File

@ -4,7 +4,7 @@
<PropertyGroup>
<Description>ASP.NET Core default HTTP feature implementations.</Description>
<TargetFrameworks>net451;netstandard1.3</TargetFrameworks>
<TargetFrameworks>netstandard1.3;net46</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>

View File

@ -4,7 +4,7 @@
<PropertyGroup>
<Description>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.</Description>
<TargetFrameworks>net451;netstandard1.3</TargetFrameworks>
<TargetFramework>netstandard1.3</TargetFramework>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore;owin</PackageTags>

View File

@ -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()
{

View File

@ -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<int>)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<int> 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();

View File

@ -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)

View File

@ -4,7 +4,7 @@
<PropertyGroup>
<Description>ASP.NET Core utilities, such as for working with forms, multipart messages, and query strings.</Description>
<TargetFrameworks>net451;netstandard1.3</TargetFrameworks>
<TargetFrameworks>netstandard1.3;net46</TargetFrameworks>
<DefineConstants>$(DefineConstants);WebEncoders_In_WebUtilities</DefineConstants>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>

View File

@ -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<int>(state);
@ -215,6 +215,9 @@ namespace Microsoft.AspNetCore.WebUtilities
var task = (Task<int>)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)

View File

@ -4,7 +4,7 @@
<PropertyGroup>
<Description>HTTP header parser implementations.</Description>
<TargetFrameworks>net451;netstandard1.1</TargetFrameworks>
<TargetFramework>netstandard1.1</TargetFramework>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>

View File

@ -3,7 +3,7 @@
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net452</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp2.0</TargetFrameworks>
</PropertyGroup>

View File

@ -3,7 +3,7 @@
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net452</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp2.0</TargetFrameworks>
</PropertyGroup>

View File

@ -3,7 +3,7 @@
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net452</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp2.0</TargetFrameworks>
</PropertyGroup>

View File

@ -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);

View File

@ -3,8 +3,10 @@
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net452</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp2.0</TargetFrameworks>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>
<ItemGroup>

View File

@ -3,7 +3,7 @@
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net452</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp2.0</TargetFrameworks>
</PropertyGroup>

View File

@ -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;

View File

@ -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++;

View File

@ -3,7 +3,7 @@
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net452</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp2.0</TargetFrameworks>
</PropertyGroup>

View File

@ -3,7 +3,7 @@
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net452</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp2.0</TargetFrameworks>
</PropertyGroup>