Remove net451 as a cross-compile target

This commit is contained in:
Pranav K 2017-03-11 20:49:51 -08:00
parent d3daf3e6e1
commit badb6ce8e5
123 changed files with 357 additions and 296 deletions

View File

@ -8,6 +8,7 @@
<NetStandardImplicitPackageVersion>1.6.1</NetStandardImplicitPackageVersion>
<RazorCodeAnalysisVersion>1.0.0-*</RazorCodeAnalysisVersion>
<RoslynVersion>1.3.0</RoslynVersion>
<RuntimeFrameworkVersion>2.0.0-*</RuntimeFrameworkVersion>
<TestSdkVersion>15.0.0</TestSdkVersion>
<WebApiClientVersion>5.2.2</WebApiClientVersion>
<XunitVersion>2.2.0</XunitVersion>

View File

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

View File

@ -6,7 +6,7 @@
<Description>ASP.NET Core MVC abstractions and interfaces for action invocation and dispatching, authorization, action filters, formatters, model binding, routing, validation, and more.
Commonly used types:
Microsoft.AspNetCore.Mvc.IActionResult</Description>
<TargetFrameworks>net451;netstandard1.3</TargetFrameworks>
<TargetFramework>netstandard1.3</TargetFramework>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore;aspnetcoremvc</PackageTags>
@ -14,15 +14,12 @@ Microsoft.AspNetCore.Mvc.IActionResult</Description>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Routing.Abstractions" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.CSharp" Version="$(CoreFxVersion)" />
<PackageReference Include="Microsoft.Extensions.ClosedGenericMatcher.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.CopyOnWriteDictionary.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.HashCodeCombiner.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.PropertyHelper.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
<PackageReference Include="Microsoft.Net.Http.Headers" Version="$(AspNetCoreVersion)" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<PackageReference Include="Microsoft.CSharp" Version="$(CoreFxVersion)" />
<PackageReference Include="System.ComponentModel.TypeConverter" Version="$(CoreFxVersion)" />
</ItemGroup>

View File

@ -4,7 +4,7 @@
<PropertyGroup>
<Description>ASP.NET Core MVC API explorer functionality for discovering metadata such as the list of controllers and actions, and their URLs and allowed HTTP methods.</Description>
<TargetFrameworks>net451;netstandard1.6</TargetFrameworks>
<TargetFrameworks>net46;netstandard1.6</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore;aspnetcoremvc</PackageTags>

View File

@ -84,7 +84,7 @@ namespace Microsoft.AspNetCore.Mvc
{
if (string.IsNullOrEmpty(original))
{
return EmptyArray<string>.Instance;
return Array.Empty<string>();
}
var split = original.Split(',').Select(piece => piece.Trim()).Where(piece => !string.IsNullOrEmpty(piece));

View File

@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Mvc
/// Initializes a new instance of <see cref="ChallengeResult"/>.
/// </summary>
public ChallengeResult()
: this(EmptyArray<string>.Instance)
: this(Array.Empty<string>())
{
}
@ -51,7 +51,7 @@ namespace Microsoft.AspNetCore.Mvc
/// <param name="properties"><see cref="AuthenticationProperties"/> used to perform the authentication
/// challenge.</param>
public ChallengeResult(AuthenticationProperties properties)
: this(EmptyArray<string>.Instance, properties)
: this(Array.Empty<string>(), properties)
{
}

View File

@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Mvc
/// Initializes a new instance of <see cref="ForbidResult"/>.
/// </summary>
public ForbidResult()
: this(EmptyArray<string>.Instance)
: this(Array.Empty<string>())
{
}
@ -51,7 +51,7 @@ namespace Microsoft.AspNetCore.Mvc
/// <param name="properties"><see cref="AuthenticationProperties"/> used to perform the authentication
/// challenge.</param>
public ForbidResult(AuthenticationProperties properties)
: this(EmptyArray<string>.Instance, properties)
: this(Array.Empty<string>(), properties)
{
}

View File

@ -1,34 +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;
#else
using System.Threading;
#endif
namespace Microsoft.AspNetCore.Mvc.Infrastructure
{
public class ActionContextAccessor : IActionContextAccessor
{
#if NET451
private static readonly string Key = typeof(ActionContext).FullName + AppDomain.CurrentDomain.Id;
public ActionContext ActionContext
{
get
{
var handle = CallContext.LogicalGetData(Key) as ObjectHandle;
return handle != null ? (ActionContext)handle.Unwrap() : null;
}
set
{
CallContext.LogicalSetData(Key, new ObjectHandle(value));
}
}
#else
private static readonly AsyncLocal<ActionContext> _storage = new AsyncLocal<ActionContext>();
public ActionContext ActionContext
@ -36,6 +14,5 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
get { return _storage.Value; }
set { _storage.Value = value; }
}
#endif
}
}

View File

@ -3,9 +3,6 @@
using System;
using System.Collections.Generic;
#if NET451
using System.ComponentModel;
#endif
using System.Linq;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.Infrastructure;

View File

@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
#if NET451
#if NET46
using System.Runtime.Serialization;
#endif
@ -11,8 +11,11 @@ namespace Microsoft.AspNetCore.Mvc.Internal
/// <summary>
/// An exception which indicates multiple matches in action selection.
/// </summary>
#if NET451
#if NET46
[Serializable]
#elif NETSTANDARD1_6
#else
#error target frameworks need to be updated
#endif
public class AmbiguousActionException : InvalidOperationException
{
@ -21,11 +24,14 @@ namespace Microsoft.AspNetCore.Mvc.Internal
{
}
#if NET451
#if NET46
protected AmbiguousActionException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
#elif NETSTANDARD1_6
#else
#error target frameworks need to be updated
#endif
}
}

View File

@ -1,6 +1,7 @@
// 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.
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
@ -104,7 +105,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
if (count == 0)
{
return EmptyArray<IClientModelValidator>.Instance;
return Array.Empty<IClientModelValidator>();
}
var validators = new IClientModelValidator[count];

View File

@ -1,19 +0,0 @@
// 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;
#endif
namespace Microsoft.AspNetCore.Mvc.Internal
{
public static class EmptyArray<TElement>
{
public static TElement[] Instance { get; } =
#if NET451
new TElement[0];
#else
Array.Empty<TElement>();
#endif
}
}

View File

@ -117,7 +117,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
if (count == 0)
{
return EmptyArray<IFilterMetadata>.Instance;
return Array.Empty<IFilterMetadata>();
}
else
{

View File

@ -107,7 +107,8 @@ namespace Microsoft.AspNetCore.Mvc.Internal
{
return _innerStream.ReadAsync(buffer, offset, count, cancellationToken);
}
#if NET451
#if NET46
/// <inheritdoc />
public override IAsyncResult BeginRead(
byte[] buffer,
@ -124,6 +125,31 @@ namespace Microsoft.AspNetCore.Mvc.Internal
{
return _innerStream.EndRead(asyncResult);
}
/// <inheritdoc />
public override IAsyncResult BeginWrite(
byte[] buffer,
int offset,
int count,
AsyncCallback callback,
object state)
{
return _innerStream.BeginWrite(buffer, offset, count, callback, state);
}
/// <inheritdoc />
public override void EndWrite(IAsyncResult asyncResult)
{
_innerStream.EndWrite(asyncResult);
}
/// <inheritdoc />
public override void Close()
{
}
#elif NETSTANDARD1_6
#else
#error target frameworks need to be updated.
#endif
/// <inheritdoc />
public override int ReadByte()
@ -166,35 +192,13 @@ namespace Microsoft.AspNetCore.Mvc.Internal
{
return _innerStream.WriteAsync(buffer, offset, count, cancellationToken);
}
#if NET451
/// <inheritdoc />
public override IAsyncResult BeginWrite(
byte[] buffer,
int offset,
int count,
AsyncCallback callback,
object state)
{
return _innerStream.BeginWrite(buffer, offset, count, callback, state);
}
/// <inheritdoc />
public override void EndWrite(IAsyncResult asyncResult)
{
_innerStream.EndWrite(asyncResult);
}
#endif
/// <inheritdoc />
public override void WriteByte(byte value)
{
_innerStream.WriteByte(value);
}
#if NET451
/// <inheritdoc />
public override void Close()
{
}
#endif
/// <inheritdoc />
protected override void Dispose(bool disposing)
{

View File

@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
if (_originalValues.Count == 0)
{
_sortedValues = EmptyArray<string>.Instance;
_sortedValues = Array.Empty<string>();
}
else
{

View File

@ -15,10 +15,6 @@ namespace Microsoft.AspNetCore.Mvc.Internal
/// We're caching this in a static readonly field to make it more inlinable and avoid the volatile lookup done
/// by <c>Task.CompletedTask</c>.
/// </remarks>
#if NET451
public static readonly Task CompletedTask = Task.FromResult(0);
#else
public static readonly Task CompletedTask = Task.CompletedTask;
#endif
}
}

View File

@ -1,6 +1,7 @@
// 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.
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
@ -103,7 +104,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
if (count == 0)
{
return EmptyArray<IModelValidator>.Instance;
return Array.Empty<IModelValidator>();
}
var validators = new IModelValidator[count];

View File

@ -12,7 +12,7 @@ Microsoft.AspNetCore.Mvc.FromBodyAttribute
Microsoft.AspNetCore.Mvc.FromFormAttribute
Microsoft.AspNetCore.Mvc.RequireHttpsAttribute
Microsoft.AspNetCore.Mvc.RouteAttribute</Description>
<TargetFrameworks>net451;netstandard1.6</TargetFrameworks>
<TargetFrameworks>net46;netstandard1.6</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore;aspnetcoremvc</PackageTags>

View File

@ -37,7 +37,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
{
Debug.Assert(targetType == typeof(TElement[]), "GenericModelBinder only creates this binder for arrays.");
return EmptyArray<TElement>.Instance;
return Array.Empty<TElement>();
}
/// <inheritdoc />

View File

@ -4,7 +4,7 @@
<PropertyGroup>
<Description>ASP.NET Core MVC cross-origin resource sharing (CORS) features.</Description>
<TargetFrameworks>net451;netstandard1.6</TargetFrameworks>
<TargetFrameworks>net46;netstandard1.6</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore;aspnetcoremvc;cors</PackageTags>

View File

@ -3,7 +3,7 @@
<PropertyGroup>
<Description>ASP.NET Core MVC metadata and validation system using System.ComponentModel.DataAnnotations.</Description>
<TargetFrameworks>net451;netstandard1.6</TargetFrameworks>
<TargetFrameworks>net46;netstandard1.6</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore;aspnetcoremvc</PackageTags>

View File

@ -3,7 +3,7 @@
<PropertyGroup>
<Description>ASP.NET Core MVC formatters for JSON input and output and for JSON PATCH input using Json.NET.</Description>
<TargetFrameworks>net451;netstandard1.6</TargetFrameworks>
<TargetFrameworks>net46;netstandard1.6</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore;aspnetcoremvc;json</PackageTags>

View File

@ -1,7 +1,7 @@
// 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
#if NET46
using System.Runtime.Serialization;
#endif
using System.Xml;
@ -15,8 +15,11 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Xml.Internal
{
public static readonly int DefaultMaxDepth = 32;
#if NET451
#if NET46
public static readonly XsdDataContractExporter XsdDataContractExporter = new XsdDataContractExporter();
#elif NETSTANDARD1_6
#else
#error target frameworks needs to be updated.
#endif
/// <summary>

View File

@ -3,7 +3,7 @@
<PropertyGroup>
<Description>ASP.NET Core MVC formatters for XML input and output using DataContractSerializer and XmlSerializer.</Description>
<TargetFrameworks>net451;netstandard1.6</TargetFrameworks>
<TargetFrameworks>net46;netstandard1.6</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore;aspnetcoremvc;xml</PackageTags>

View File

@ -131,9 +131,12 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
try
{
#if NET451
#if NET46
// Verify that type is a valid data contract by forcing the serializer to try to create a data contract
FormattingUtilities.XsdDataContractExporter.GetRootElementName(type);
#elif NETSTANDARD1_6
#else
#error target frameworks need to be updated.
#endif
// If the serializer does not support this type it will throw an exception.
return new DataContractSerializer(type, _serializerSettings);

View File

@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Mvc.Localization
/// <param name="name">The name of the string resource.</param>
/// <param name="value">The string resource.</param>
public LocalizedHtmlString(string name, string value)
: this(name, value, isResourceNotFound: false, arguments: EmptyArray<string>.Instance)
: this(name, value, isResourceNotFound: false, arguments: Array.Empty<string>())
{
}
@ -33,7 +33,7 @@ namespace Microsoft.AspNetCore.Mvc.Localization
/// <param name="value">The string resource.</param>
/// <param name="isResourceNotFound">A flag that indicates if the resource is not found.</param>
public LocalizedHtmlString(string name, string value, bool isResourceNotFound)
: this(name, value, isResourceNotFound, arguments: EmptyArray<string>.Instance)
: this(name, value, isResourceNotFound, arguments: Array.Empty<string>())
{
}

View File

@ -7,7 +7,7 @@
Commonly used types:
Microsoft.AspNetCore.Mvc.Localization.IHtmlLocalizer&lt;TResource&gt;
Microsoft.AspNetCore.Mvc.Localization.IViewLocalizer</Description>
<TargetFrameworks>net451;netstandard1.6</TargetFrameworks>
<TargetFrameworks>net46;netstandard1.6</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore;aspnetcoremvc;localization</PackageTags>

View File

@ -4,7 +4,7 @@
<PropertyGroup>
<Description>ASP.NET Core MVC design time hosting infrastructure for the Razor view engine.</Description>
<TargetFrameworks>net451;netstandard1.6</TargetFrameworks>
<TargetFrameworks>net46;netstandard1.6</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore;aspnetcoremvc;cshtml;razor</PackageTags>

View File

@ -79,6 +79,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Compilation
}
}
}
#elif NET46
#else
#error target frameworks needs to be updated.
#endif
var precompiledAssemblyName = new AssemblyName(assemblyPart.Assembly.FullName);

View File

@ -15,12 +15,14 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
private readonly CSharpParseOptions _parseOptions;
private readonly RazorReferenceManager _referenceManager;
private readonly DebugInformationFormat _pdbFormat =
#if NET451
#if NET46
SymbolsUtility.SupportsFullPdbGeneration() ?
DebugInformationFormat.Pdb :
DebugInformationFormat.PortablePdb;
#else
#elif NETSTANDARD1_6
DebugInformationFormat.PortablePdb;
#else
#error target frameworks need to be updated.
#endif
public CSharpCompiler(RazorReferenceManager manager, IOptions<RazorViewEngineOptions> optionsAccessor)

View File

@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
/// <param name="compilationResult">The <see cref="CompilationResult"/>.</param>
/// <param name="isPrecompiled"><c>true</c> if the view is precompiled, <c>false</c> otherwise.</param>
public CompilerCacheResult(string relativePath, CompilationResult compilationResult, bool isPrecompiled)
: this(relativePath, compilationResult, EmptyArray<IChangeToken>.Instance)
: this(relativePath, compilationResult, Array.Empty<IChangeToken>())
{
IsPrecompiled = isPrecompiled;
}

View File

@ -14,7 +14,6 @@ using Microsoft.AspNetCore.Razor.Evolution;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Text;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
@ -186,10 +185,12 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
public static Assembly LoadAssembly(MemoryStream assemblyStream, MemoryStream pdbStream)
{
var assembly =
#if NET451
#if NET46
Assembly.Load(assemblyStream.ToArray(), pdbStream.ToArray());
#else
#elif NETSTANDARD1_6
System.Runtime.Loader.AssemblyLoadContext.Default.LoadFromStream(assemblyStream, pdbStream);
#else
#error target frameworks need to be updated
#endif
return assembly;
}

View File

@ -1,7 +1,7 @@
// 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
#if NET46
using System;
using System.Runtime.InteropServices;
@ -44,4 +44,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
}
}
}
#elif NETSTANDARD1_6
#else
#error target frameworks need to be updated
#endif

View File

@ -51,11 +51,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
}
// Using CurrentUICulture so it loads the locale specific resources for the views.
#if NET451
context.Values[ValueKey] = Thread.CurrentThread.CurrentUICulture.Name;
#else
context.Values[ValueKey] = CultureInfo.CurrentUICulture.Name;
#endif
}
/// <inheritdoc />

View File

@ -4,7 +4,7 @@
<PropertyGroup>
<Description>ASP.NET Core MVC Razor view engine for CSHTML files.</Description>
<TargetFrameworks>net451;netstandard1.6</TargetFrameworks>
<TargetFrameworks>net46;netstandard1.6</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore;aspnetcoremvc;cshtml;razor</PackageTags>

View File

@ -470,7 +470,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
// Only need to lookup _ViewStarts for the main page.
var viewStartPages = isMainPage ?
GetViewStartPages(relativePath, expirationTokens) :
EmptyArray<ViewLocationCacheItem>.Instance;
Array.Empty<ViewLocationCacheItem>();
if (factoryResult.IsPrecompiled)
{
_logger.PrecompiledViewFound(relativePath);

View File

@ -33,7 +33,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
}
var factory = ActivatorUtilities.CreateFactory(modelTypeInfo, Type.EmptyTypes);
return (context) => factory(context.HttpContext.RequestServices, EmptyArray<object>.Instance);
return (context) => factory(context.HttpContext.RequestServices, Array.Empty<object>());
}
public virtual Action<PageContext, object> CreateReleaser(CompiledPageActionDescriptor actionDescriptor)

View File

@ -314,7 +314,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Internal
if (CacheEntry.PageStartFactories == null || CacheEntry.PageStartFactories.Count == 0)
{
pageStarts = EmptyArray<IRazorPage>.Instance;
pageStarts = Array.Empty<IRazorPage>();
}
else
{

View File

@ -4,7 +4,7 @@
<PropertyGroup>
<Description>ASP.NET Core MVC Razor Pages.</Description>
<TargetFrameworks>netstandard1.6;net451</TargetFrameworks>
<TargetFrameworks>netstandard1.6;net46</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore;aspnetcoremvc;cshtml;razor</PackageTags>

View File

@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers.Internal
return sha256;
}
#else
#elif NET46
public static SHA256 CreateSHA256()
{
SHA256 sha256;
@ -33,6 +33,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers.Internal
return sha256;
}
#else
#error target frameworks needs to be updated.
#endif
}
}

View File

@ -110,7 +110,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers.Internal
{
if (string.IsNullOrEmpty(include))
{
return EmptyArray<string>.Instance;
return Array.Empty<string>();
}
var cacheKey = new GlobbingUrlKey(include, exclude);
@ -124,7 +124,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers.Internal
var includeEnumerator = includeTokenizer.GetEnumerator();
if (!includeEnumerator.MoveNext())
{
return EmptyArray<string>.Instance;
return Array.Empty<string>();
}
var options = new MemoryCacheEntryOptions();

View File

@ -3,7 +3,7 @@
<PropertyGroup>
<Description>ASP.NET Core MVC default tag helpers. Contains tag helpers for anchor tags, HTML input elements, caching, scripts, links (for CSS), and more.</Description>
<TargetFrameworks>net451;netstandard1.6</TargetFrameworks>
<TargetFrameworks>net46;netstandard1.6</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore;aspnetcoremvc;taghelper;taghelpers</PackageTags>

View File

@ -103,7 +103,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal
{
if (arguments == null || arguments.Length == 0)
{
return EmptyArray<string>.Instance;
return Array.Empty<string>();
}
var formattedArguments = new string[arguments.Length];

View File

@ -1,9 +1,9 @@
// 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.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc.Internal;
using Microsoft.AspNetCore.Mvc.ModelBinding;
namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal
@ -79,7 +79,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal
return entries;
}
return EmptyArray<ModelStateEntry>.Instance;
return Array.Empty<ModelStateEntry>();
}
private static void Visit(

View File

@ -8,7 +8,7 @@ Commonly used types:
Microsoft.AspNetCore.Mvc.Controller
Microsoft.AspNetCore.Mvc.ValidateAntiForgeryTokenAttribute
Microsoft.AspNetCore.Mvc.ViewComponent</Description>
<TargetFrameworks>net451;netstandard1.6</TargetFrameworks>
<TargetFrameworks>net46;netstandard1.6</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>

View File

@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.Mvc
public class RemoteAttribute : ValidationAttribute, IClientModelValidator
{
private string _additionalFields = string.Empty;
private string[] _additionalFieldsSplit = EmptyArray<string>.Instance;
private string[] _additionalFieldsSplit = Array.Empty<string>();
private bool _checkedForLocalizer;
private IStringLocalizer _stringLocalizer;
@ -276,7 +276,7 @@ namespace Microsoft.AspNetCore.Mvc
{
if (string.IsNullOrEmpty(original))
{
return EmptyArray<string>.Instance;
return Array.Empty<string>();
}
var split = original

View File

@ -293,4 +293,7 @@ namespace System.Collections.Generic
}
}
}
#elif NET46
#else
#error target frameworks needs to be updated.
#endif

View File

@ -50,4 +50,7 @@ namespace System.Net.Http.Formatting
public MediaTypeHeaderValue MediaType { get; set; }
}
}
#elif NET46
#else
#error target frameworks needs to be updated.
#endif

View File

@ -585,4 +585,7 @@ namespace System.Net.Http.Formatting
}
}
}
#elif NET46
#else
#error target frameworks needs to be updated.
#endif

View File

@ -40,5 +40,7 @@ namespace System.Net.Http.Formatting
}
}
}
#elif NET46
#else
#error target frameworks needs to be updated.
#endif

View File

@ -162,9 +162,6 @@ namespace System.Net.Http
{
// MaxDepth is a DOS mitigation. We don't support MaxDepth in portable libraries because it is strictly
// client side.
#if NETFX_CORE
return XmlDictionaryReaderQuotas.Max;
#else
return new XmlDictionaryReaderQuotas()
{
MaxArrayLength = int.MaxValue,
@ -173,7 +170,6 @@ namespace System.Net.Http
MaxNameTableCharCount = int.MaxValue,
MaxStringContentLength = int.MaxValue
};
#endif
}
/// <summary>
@ -241,4 +237,7 @@ namespace System.Net.Http
}
}
}
#elif NET46
#else
#error target frameworks needs to be updated.
#endif

View File

@ -38,4 +38,7 @@ namespace System.Net.Http.Formatting
IEnumerable<MediaTypeFormatter> formatters);
}
}
#elif NET46
#else
#error target frameworks needs to be updated.
#endif

View File

@ -31,4 +31,7 @@ namespace System.Collections.ObjectModel
}
}
}
#elif NET46
#else
#error target frameworks needs to be updated.
#endif

View File

@ -109,4 +109,7 @@ namespace System.Net.Http.Formatting
}
}
}
#elif NET46
#else
#error target frameworks needs to be updated.
#endif

View File

@ -57,4 +57,7 @@ namespace System.Net.Http.Formatting
public MediaTypeFormatterMatchRanking Ranking { get; private set; }
}
}
#elif NET46
#else
#error target frameworks needs to be updated.
#endif

View File

@ -45,4 +45,7 @@ namespace System.Net.Http.Formatting
MatchOnRequestMediaType,
}
}
#elif NET46
#else
#error target frameworks needs to be updated.
#endif

View File

@ -118,4 +118,7 @@ namespace System.Net.Http.Formatting
}
}
}
#elif NET46
#else
#error target frameworks needs to be updated.
#endif

View File

@ -116,4 +116,7 @@ namespace System.Net.Http.Formatting
}
}
}
#elif NET46
#else
#error target frameworks needs to be updated.
#endif

View File

@ -88,4 +88,7 @@ namespace System.Net.Http.Formatting
}
}
}
#elif NET46
#else
#error target frameworks needs to be updated.
#endif

View File

@ -75,4 +75,7 @@ namespace System.Net.Http.Formatting
}
}
}
#elif NET46
#else
#error target frameworks needs to be updated.
#endif

View File

@ -19,7 +19,7 @@ namespace System.Net.Http
/// </summary>
public static class HttpRequestMessageExtensions
{
#if !NETSTANDARD1_6
#if NET46
/// <summary>
/// Helper method for creating an <see cref="HttpResponseMessage"/> message with a "416 (Requested Range Not
@ -55,7 +55,9 @@ namespace System.Net.Http
rangeNotSatisfiableResponse.Content.Headers.ContentRange = invalidByteRangeException.ContentRange;
return rangeNotSatisfiableResponse;
}
#elif NETSTANDARD1_6
#else
#error target frameworks needs to be updated.
#endif
/// <summary>

View File

@ -6,7 +6,7 @@
<Description>Provides compatibility in ASP.NET Core MVC with ASP.NET Web API 2 to simplify migration of existing Web API implementations.
Commonly used types:
System.Web.Http.ApiController</Description>
<TargetFrameworks>net451;netstandard1.6</TargetFrameworks>
<TargetFrameworks>net46;netstandard1.6</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore;aspnetcoremvc;aspnetwebapi</PackageTags>

View File

@ -4,7 +4,7 @@
<PropertyGroup>
<Description>ASP.NET Core MVC is a web framework that gives you a powerful, patterns-based way to build dynamic websites and web APIs. ASP.NET Core MVC enables a clean separation of concerns and gives you full control over markup.</Description>
<TargetFrameworks>net451;netstandard1.6</TargetFrameworks>
<TargetFrameworks>net46;netstandard1.6</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore;aspnetcoremvc</PackageTags>

View File

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

View File

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

View File

@ -6,7 +6,7 @@ using Xunit;
namespace Microsoft.AspNetCore.Mvc.Infrastructure
{
#if NET452
#if NET46
public class ActionContextAccessorTests
{
private static void DomainFunc()
@ -38,5 +38,8 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
Assert.True(ReferenceEquals(context, accessor.ActionContext));
}
}
#elif NETCOREAPP2_0
#else
#error target frameworks needs to be updated.
#endif
}

View File

@ -4,9 +4,7 @@
using System;
using System.Collections.Generic;
using System.Text.Encodings.Web;
#if NETCOREAPP1_1
using System.Reflection;
#endif
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Abstractions;

View File

@ -70,7 +70,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
// Arrange
var expected = GetLibrary("MyApplication", "Microsoft.AspNetCore.Server.Kestrel", "Microsoft.AspNetCore.Mvc");
var deps = new DependencyContext(
new TargetInfo("netcoreapp1.1", "rurntime", "signature", isPortable: true),
new TargetInfo("netcoreapp2.0", "rurntime", "signature", isPortable: true),
CompilationOptions.Default,
Enumerable.Empty<CompilationLibrary>(),
new[]

View File

@ -2,8 +2,8 @@
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<TargetFrameworks>netcoreapp1.1;net452</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp1.1</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp2.0</TargetFrameworks>
<PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup>

View File

@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
{
public class NonDisposableStreamTest
{
#if !NETCOREAPP1_1
#if NET46
[Fact]
public void InnerStreamIsOpenOnClose()
{
@ -23,6 +23,21 @@ namespace Microsoft.AspNetCore.Mvc.Internal
// Assert
Assert.True(innerStream.CanRead);
}
[Fact]
public void InnerStreamIsNotFlushedOnClose()
{
// Arrange
var stream = FlushReportingStream.GetThrowingStream();
var nonDisposableStream = new NonDisposableStream(stream);
// Act & Assert
nonDisposableStream.Close();
}
#elif NETCOREAPP2_0
#else
#error The target frameworks need to be updated
#endif
[Fact]
@ -49,20 +64,6 @@ namespace Microsoft.AspNetCore.Mvc.Internal
nonDisposableStream.Dispose();
}
#if !NETCOREAPP1_1
[Fact]
public void InnerStreamIsNotFlushedOnClose()
{
// Arrange
var stream = FlushReportingStream.GetThrowingStream();
var nonDisposableStream = new NonDisposableStream(stream);
// Act & Assert
nonDisposableStream.Close();
}
#endif
[Fact]
public void InnerStreamIsNotFlushedOnFlush()
{

View File

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

View File

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

View File

@ -308,20 +308,26 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
{ "This is a test 激光這兩個字是甚麼意思 string written using utf-8", "utf-8", true },
{ "This is a test 激光這兩個字是甚麼意思 string written using utf-16", "utf-16", true },
{ "This is a test 激光這兩個字是甚麼意思 string written using utf-32", "utf-32", false },
#if !NETCOREAPP1_1
#if NET46
// CoreCLR does not like shift_jis as an encoding.
{ "This is a test 激光這兩個字是甚麼意思 string written using shift_jis", "shift_jis", false },
#elif NETCOREAPP2_0
#else
#error target frameworks needs to be updated.
#endif
{ "This is a test æøå string written using iso-8859-1", "iso-8859-1", false },
};
#if !NETCOREAPP1_1
#if NET46
// CoreCLR does not like iso-2022-kr as an encoding.
if (!TestPlatformHelper.IsMono)
{
// Mono issue - https://github.com/aspnet/External/issues/28
data.Add("This is a test 레이저 단어 뜻 string written using iso-2022-kr", "iso-2022-kr", false);
}
#elif NETCOREAPP2_0
#else
#error target frameworks needs to be updated.
#endif
return data;

View File

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

View File

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

View File

@ -1,7 +1,7 @@
// 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 NET452
#if NET46
using System;
using System.Collections.Generic;
using System.IO;

View File

@ -22,14 +22,16 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
public async Task CompilationOptions_AreUsedByViewsAndPartials()
{
// Arrange
#if NET452
#if NET46
var expected =
@"This method is running from NET452
This method is only defined in NET452";
#elif NETCOREAPP1_1
@"This method is running from NET46
This method is only defined in NET46";
#elif NETCOREAPP2_0
var expected =
@"This method is running from NETCOREAPP1_1
This method is only defined in NETCOREAPP1_1";
@"This method is running from NETCOREAPP2_0
This method is only defined in NETCOREAPP2_0";
#else
#error the target framework needs to be updated.
#endif
// Act

View File

@ -97,7 +97,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
// The desktop CLR does not correctly read the stack trace from portable PDBs. However generating full pdbs
// is only supported on machines with CLSID_CorSymWriter available. On desktop, we'll skip this test on
// machines without this component.
#if NET452
#if NET46
if (!SymbolsUtility.SupportsFullPdbGeneration())
{
return;

View File

@ -2,16 +2,16 @@
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<TargetFrameworks>netcoreapp1.1;net452</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp1.1</TargetFrameworks>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">$(PackageTargetFallback);portable-net451+win8</PackageTargetFallback>
<TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp2.0</TargetFrameworks>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">$(PackageTargetFallback);portable-net451+win8</PackageTargetFallback>
<DefineConstants Condition="'$(GenerateBaselines)'=='true'">$(DefineConstants);GENERATE_BASELINES</DefineConstants>
<DefineConstants>$(DefineConstants);__RemoveThisBitTo__GENERATE_BASELINES</DefineConstants>
<DefineConstants>$(DefineConstants);FUNCTIONAL_TESTS</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' != 'netcoreapp1.1' ">
<PropertyGroup Condition=" '$(TargetFramework)' != 'netcoreapp2.0' ">
<!-- Work around https://github.com/dotnet/sdk/issues/926. Align with bitness of the web site projects. -->
<PlatformTarget>x86</PlatformTarget>

View File

@ -62,8 +62,11 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
{
typeof(JsonMediaTypeFormatter).FullName,
typeof(XmlMediaTypeFormatter).FullName,
#if !NETCOREAPP1_1
#if NET46
typeof(FormUrlEncodedMediaTypeFormatter).FullName,
#elif NETCOREAPP2_0
#else
#error the target framework needs to be updated.
#endif
};

View File

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

View File

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

View File

@ -3,12 +3,14 @@
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<TargetFrameworks>netcoreapp1.1;net452</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp1.1</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp2.0</TargetFrameworks>
<PreserveCompilationContext>true</PreserveCompilationContext>
<DefineConstants Condition="'$(GenerateBaselines)'=='true'">$(DefineConstants);GENERATE_BASELINES</DefineConstants>
<DefineConstants>$(DefineConstants);__RemoveThisBitTo__GENERATE_BASELINES</DefineConstants>
<DefaultItemExcludes>$(DefaultItemExcludes);TestFiles\**</DefaultItemExcludes>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>
<ItemGroup>

View File

@ -90,7 +90,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Compilation
Assert.Empty(feature.Views);
}
#if !NETCOREAPP1_1
#if NET46
[Fact]
public void PopulateFeature_DoesNotFail_IfAssemblyHasEmptyLocation()
{
@ -107,6 +107,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Compilation
// Assert
Assert.Empty(feature.Views);
}
#elif NETCOREAPP2_0
#else
#error target frameworks needs to be updated.
#endif
private class TestableViewsFeatureProvider : ViewsFeatureProvider
@ -145,7 +148,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Compilation
}
}
#if !NETCOREAPP1_1
#if NET46
private class AssemblyWithEmptyLocation : Assembly
{
public override string Location => string.Empty;

View File

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

View File

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

View File

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

View File

@ -2,8 +2,10 @@
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<TargetFrameworks>netcoreapp1.1;net452</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp1.1</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>net452;netstandard1.6</TargetFrameworks>
<TargetFrameworks>net46;netstandard1.6</TargetFrameworks>
</PropertyGroup>
<ItemGroup>

View File

@ -2,7 +2,7 @@
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<TargetFrameworks>net452;netstandard1.6</TargetFrameworks>
<TargetFrameworks>net46;netstandard1.6</TargetFrameworks>
</PropertyGroup>
<ItemGroup>

View File

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

View File

@ -149,10 +149,13 @@ namespace System.Net.Http.Formatting
{
get
{
#if !NETCOREAPP1_1
#if NET46
// Only mapping and accept makes sense with q != 1.0
MediaTypeFormatterMatch matchMapping10 = CreateMatch(1.0, MediaTypeFormatterMatchRanking.MatchOnRequestWithMediaTypeMapping);
MediaTypeFormatterMatch matchMapping05 = CreateMatch(0.5, MediaTypeFormatterMatchRanking.MatchOnRequestWithMediaTypeMapping);
#elif NETCOREAPP2_0
#else
#error target frameworks needs to be updated.
#endif
MediaTypeFormatterMatch matchAccept10 = CreateMatch(1.0, MediaTypeFormatterMatchRanking.MatchOnRequestAcceptHeaderLiteral);
@ -176,9 +179,6 @@ namespace System.Net.Http.Formatting
{ new List<MediaTypeFormatterMatch>() { matchType10, matchRequest10, matchAcceptAllRange10 }, matchAcceptAllRange10 },
{ new List<MediaTypeFormatterMatch>() { matchType10, matchRequest10, matchAcceptAllRange10, matchAcceptSubTypeRange10 }, matchAcceptSubTypeRange10 },
{ new List<MediaTypeFormatterMatch>() { matchType10, matchRequest10, matchAcceptAllRange10, matchAcceptSubTypeRange10, matchAccept10 }, matchAccept10 },
#if !NETCOREAPP1_1
{ new List<MediaTypeFormatterMatch>() { matchType10, matchRequest10, matchAcceptAllRange10, matchAcceptSubTypeRange10, matchAccept10, matchMapping10 }, matchMapping10 },
#endif
{ new List<MediaTypeFormatterMatch>() { matchAccept05, matchAccept10 }, matchAccept10 },
{ new List<MediaTypeFormatterMatch>() { matchAccept10, matchAccept05 }, matchAccept10 },
@ -187,7 +187,8 @@ namespace System.Net.Http.Formatting
{ new List<MediaTypeFormatterMatch>() { matchAcceptAllRange05, matchAcceptAllRange10 }, matchAcceptAllRange10 },
{ new List<MediaTypeFormatterMatch>() { matchAcceptAllRange10, matchAcceptAllRange05 }, matchAcceptAllRange10 },
#if !NETCOREAPP1_1
#if NET46
{ new List<MediaTypeFormatterMatch>() { matchType10, matchRequest10, matchAcceptAllRange10, matchAcceptSubTypeRange10, matchAccept10, matchMapping10 }, matchMapping10 },
{ new List<MediaTypeFormatterMatch>() { matchMapping05, matchMapping10 }, matchMapping10 },
{ new List<MediaTypeFormatterMatch>() { matchMapping10, matchMapping05 }, matchMapping10 },
@ -203,6 +204,9 @@ namespace System.Net.Http.Formatting
{ new List<MediaTypeFormatterMatch>() { matchMapping05, matchAccept10 }, matchAccept10 },
{ new List<MediaTypeFormatterMatch>() { matchMapping05, matchAcceptSubTypeRange10 }, matchAcceptSubTypeRange10 },
{ new List<MediaTypeFormatterMatch>() { matchMapping05, matchAcceptAllRange10 }, matchAcceptAllRange10 },
#elif NETCOREAPP2_0
#else
#error target frameworks needs to be updated.
#endif
};
}
@ -251,7 +255,7 @@ namespace System.Net.Http.Formatting
Assert.Null(result);
}
#if !NETCOREAPP1_1
#if NET46
[Fact]
public void Negotiate_MediaTypeMappingTakesPrecedenceOverAcceptHeader()
@ -280,7 +284,9 @@ namespace System.Net.Http.Formatting
Assert.Equal("application/xml", result.MediaType.MediaType);
Assert.IsType<PlainTextFormatter>(result.Formatter);
}
#elif NETCOREAPP2_0
#else
#error target frameworks needs to be updated.
#endif
[Fact]
@ -359,7 +365,7 @@ namespace System.Net.Http.Formatting
Assert.IsType<JsonMediaTypeFormatter>(result.Formatter);
}
#if !NETCOREAPP1_1
#if NET46
[Fact]
public void Negotiate_RespectsFormatterOrdering_ForXhrRequestThatDoesNotSpecifyAcceptHeaders()
@ -382,7 +388,9 @@ namespace System.Net.Http.Formatting
Assert.Equal("application/json", result.MediaType.MediaType);
Assert.IsType<JsonMediaTypeFormatter>(result.Formatter);
}
#elif NETCOREAPP2_0
#else
#error target frameworks needs to be updated.
#endif
[Fact]
@ -458,7 +466,7 @@ namespace System.Net.Http.Formatting
}
}
#if !NETCOREAPP1_1
#if NET46
[Fact]
public void MatchMediaTypeMapping_ReturnsMatch()
@ -485,7 +493,9 @@ namespace System.Net.Http.Formatting
Assert.Equal(mockMediaTypeMapping.MatchQuality, match.Quality);
Assert.Equal(MediaTypeFormatterMatchRanking.MatchOnRequestWithMediaTypeMapping, match.Ranking);
}
#elif NETCOREAPP2_0
#else
#error target frameworks needs to be updated.
#endif
[Theory]
@ -810,7 +820,7 @@ namespace System.Net.Http.Formatting
}
}
#if !NETCOREAPP1_1
#if NET46
private class MyMediaTypeMapping : MediaTypeMapping
{
@ -832,6 +842,9 @@ namespace System.Net.Http.Formatting
}
}
#elif NETCOREAPP2_0
#else
#error target frameworks needs to be updated.
#endif
}

View File

@ -278,7 +278,7 @@ namespace System.Net.Http
Assert.Equal("bin/baz", response.Content.Headers.ContentType.MediaType);
}
#if !NETCOREAPP1_1
#if NET46
// API doesn't exist in CoreCLR.
[Fact]
public void CreateErrorResponseRangeNotSatisfiable_SetsCorrectStatusCodeAndContentRangeHeader()
@ -299,6 +299,9 @@ namespace System.Net.Http
Assert.Equal(HttpStatusCode.RequestedRangeNotSatisfiable, response.StatusCode);
Assert.Same(expectedContentRange, response.Content.Headers.ContentRange);
}
#elif NETCOREAPP2_0
#else
#error target frameworks needs to be updated.
#endif
private static IServiceProvider CreateServices(

View File

@ -3,9 +3,11 @@
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<TargetFrameworks>netcoreapp1.1;net452</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp1.1</TargetFrameworks>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">$(PackageTargetFallback);portable-net451+win8</PackageTargetFallback>
<TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp2.0</TargetFrameworks>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">$(PackageTargetFallback);portable-net451+win8</PackageTargetFallback>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>
<ItemGroup>
@ -16,6 +18,7 @@
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
<PackageReference Include="Moq" Version="$(MoqVersion)" />
<PackageReference Include="System.Reflection.TypeExtensions" Version="$(CoreFxVersion)" />
<PackageReference Include="xunit" Version="$(XunitVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)" />
</ItemGroup>

View File

@ -34,14 +34,16 @@ namespace System.Net.Http.Formatting.Mocks
return base.SelectResponseCharacterEncoding(request, formatter);
}
#if !NETCOREAPP1_1
#if NET46
public new MediaTypeFormatterMatch MatchMediaTypeMapping(HttpRequestMessage request, MediaTypeFormatter formatter)
{
return base.MatchMediaTypeMapping(request, formatter);
}
#endif
#elif NETCOREAPP2_0
#else
#error target frameworks needs to be updated.
#endif
public new MediaTypeFormatterMatch MatchAcceptHeader(IEnumerable<MediaTypeWithQualityHeaderValue> sortedAcceptValues, MediaTypeFormatter formatter)
{

View File

@ -1,7 +1,7 @@
// 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 !NETCOREAPP1_1
#if NET46
using System.Net.Http.Headers;
@ -35,4 +35,7 @@ namespace System.Net.Http.Formatting.Mocks
}
}
}
#elif NETCOREAPP2_0
#else
#error target frameworks needs to be updated.
#endif

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@
<Import Project="..\..\..\build\common.props" />
<PropertyGroup>
<TargetFrameworks>net452;netstandard1.6</TargetFrameworks>
<TargetFrameworks>net46;netstandard1.6</TargetFrameworks>
<PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup>

Some files were not shown because too many files have changed in this diff Show More