Update to latest SDK (#25421)
* React to platform compatibility analyzer warnings * React to new warnings * Add platform compatibility attributes
This commit is contained in:
parent
fa2a5076e4
commit
690c717314
|
|
@ -13,6 +13,9 @@
|
||||||
|
|
||||||
<!-- Public members should not use oblivious types. Not done with all nullable annotations. -->
|
<!-- Public members should not use oblivious types. Not done with all nullable annotations. -->
|
||||||
<NoWarn>$(NoWarn);RS0041</NoWarn>
|
<NoWarn>$(NoWarn);RS0041</NoWarn>
|
||||||
|
|
||||||
|
<!-- Turn off platform compatiblity analyzer warnings in test, test assets, and samples -->
|
||||||
|
<NoWarn Condition="'$(IsTestProject)' == 'true' OR '$(IsTestAssetProject)' == 'true' OR '$(ISBenchmarkProject)' == 'true' OR '$(IsSampleProject)' == 'true'">$(NoWarn);CA1416</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup Condition=" Exists('$(MSBuildProjectDirectory)\PublicAPI.*.txt') AND
|
<ItemGroup Condition=" Exists('$(MSBuildProjectDirectory)\PublicAPI.*.txt') AND
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
{
|
{
|
||||||
"sdk": {
|
"sdk": {
|
||||||
"version": "5.0.100-rc.1.20379.10"
|
"version": "5.0.100-rc.1.20429.2"
|
||||||
},
|
},
|
||||||
"tools": {
|
"tools": {
|
||||||
"dotnet": "5.0.100-rc.1.20379.10",
|
"dotnet": "5.0.100-rc.1.20429.2",
|
||||||
"runtimes": {
|
"runtimes": {
|
||||||
"dotnet/x64": [
|
"dotnet/x64": [
|
||||||
"2.1.18",
|
"2.1.18",
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ namespace Ignitor
|
||||||
{
|
{
|
||||||
Timeout = timeout;
|
Timeout = timeout;
|
||||||
|
|
||||||
Completion = new TaskCompletionSource<TResult>(TaskContinuationOptions.RunContinuationsAsynchronously);
|
Completion = new TaskCompletionSource<TResult>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||||
Completion.Task.ContinueWith(
|
Completion.Task.ContinueWith(
|
||||||
(task, state) =>
|
(task, state) =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ namespace Microsoft.AspNetCore.Components.E2ETest.ServerExecutionTests
|
||||||
Browser.MountTestComponent<CounterComponent>();
|
Browser.MountTestComponent<CounterComponent>();
|
||||||
Browser.Equal("Current count: 0", () => Browser.FindElement(By.TagName("p")).Text);
|
Browser.Equal("Current count: 0", () => Browser.FindElement(By.TagName("p")).Text);
|
||||||
|
|
||||||
GracefulDisconnectCompletionSource = new TaskCompletionSource<object>(TaskContinuationOptions.RunContinuationsAsynchronously);
|
GracefulDisconnectCompletionSource = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||||
Sink = _serverFixture.Host.Services.GetRequiredService<TestSink>();
|
Sink = _serverFixture.Host.Services.GetRequiredService<TestSink>();
|
||||||
Messages = new List<(Extensions.Logging.LogLevel level, string eventIdName)>();
|
Messages = new List<(Extensions.Logging.LogLevel level, string eventIdName)>();
|
||||||
Sink.MessageLogged += Log;
|
Sink.MessageLogged += Log;
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Runtime.Versioning;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
using Microsoft.AspNetCore.Cryptography;
|
using Microsoft.AspNetCore.Cryptography;
|
||||||
using Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption;
|
using Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption;
|
||||||
|
|
@ -223,6 +224,7 @@ namespace Microsoft.AspNetCore.DataProtection
|
||||||
/// <param name="builder">The <see cref="IDataProtectionBuilder"/>.</param>
|
/// <param name="builder">The <see cref="IDataProtectionBuilder"/>.</param>
|
||||||
/// <param name="registryKey">The location in the registry where keys should be stored.</param>
|
/// <param name="registryKey">The location in the registry where keys should be stored.</param>
|
||||||
/// <returns>A reference to the <see cref="IDataProtectionBuilder" /> after this operation has completed.</returns>
|
/// <returns>A reference to the <see cref="IDataProtectionBuilder" /> after this operation has completed.</returns>
|
||||||
|
[SupportedOSPlatform("windows")]
|
||||||
public static IDataProtectionBuilder PersistKeysToRegistry(this IDataProtectionBuilder builder, RegistryKey registryKey)
|
public static IDataProtectionBuilder PersistKeysToRegistry(this IDataProtectionBuilder builder, RegistryKey registryKey)
|
||||||
{
|
{
|
||||||
if (builder == null)
|
if (builder == null)
|
||||||
|
|
@ -356,6 +358,7 @@ namespace Microsoft.AspNetCore.DataProtection
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// This API is only supported on Windows platforms.
|
/// This API is only supported on Windows platforms.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
[SupportedOSPlatform("windows")]
|
||||||
public static IDataProtectionBuilder ProtectKeysWithDpapi(this IDataProtectionBuilder builder)
|
public static IDataProtectionBuilder ProtectKeysWithDpapi(this IDataProtectionBuilder builder)
|
||||||
{
|
{
|
||||||
if (builder == null)
|
if (builder == null)
|
||||||
|
|
@ -378,6 +381,7 @@ namespace Microsoft.AspNetCore.DataProtection
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// This API is only supported on Windows platforms.
|
/// This API is only supported on Windows platforms.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
[SupportedOSPlatform("windows")]
|
||||||
public static IDataProtectionBuilder ProtectKeysWithDpapi(this IDataProtectionBuilder builder, bool protectToLocalMachine)
|
public static IDataProtectionBuilder ProtectKeysWithDpapi(this IDataProtectionBuilder builder, bool protectToLocalMachine)
|
||||||
{
|
{
|
||||||
if (builder == null)
|
if (builder == null)
|
||||||
|
|
@ -408,6 +412,7 @@ namespace Microsoft.AspNetCore.DataProtection
|
||||||
/// See https://msdn.microsoft.com/en-us/library/windows/desktop/hh706794(v=vs.85).aspx
|
/// See https://msdn.microsoft.com/en-us/library/windows/desktop/hh706794(v=vs.85).aspx
|
||||||
/// for more information on DPAPI-NG. This API is only supported on Windows 8 / Windows Server 2012 and higher.
|
/// for more information on DPAPI-NG. This API is only supported on Windows 8 / Windows Server 2012 and higher.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
[SupportedOSPlatform("windows")]
|
||||||
public static IDataProtectionBuilder ProtectKeysWithDpapiNG(this IDataProtectionBuilder builder)
|
public static IDataProtectionBuilder ProtectKeysWithDpapiNG(this IDataProtectionBuilder builder)
|
||||||
{
|
{
|
||||||
if (builder == null)
|
if (builder == null)
|
||||||
|
|
@ -435,6 +440,7 @@ namespace Microsoft.AspNetCore.DataProtection
|
||||||
/// and <paramref name="flags"/> arguments.
|
/// and <paramref name="flags"/> arguments.
|
||||||
/// This API is only supported on Windows 8 / Windows Server 2012 and higher.
|
/// This API is only supported on Windows 8 / Windows Server 2012 and higher.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
[SupportedOSPlatform("windows")]
|
||||||
public static IDataProtectionBuilder ProtectKeysWithDpapiNG(this IDataProtectionBuilder builder, string protectionDescriptorRule, DpapiNGProtectionDescriptorFlags flags)
|
public static IDataProtectionBuilder ProtectKeysWithDpapiNG(this IDataProtectionBuilder builder, string protectionDescriptorRule, DpapiNGProtectionDescriptorFlags flags)
|
||||||
{
|
{
|
||||||
if (builder == null)
|
if (builder == null)
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ using System.Diagnostics;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
@ -500,6 +501,8 @@ namespace Microsoft.AspNetCore.DataProtection.KeyManagement
|
||||||
{
|
{
|
||||||
if (OSVersionUtil.IsWindows())
|
if (OSVersionUtil.IsWindows())
|
||||||
{
|
{
|
||||||
|
Debug.Assert(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)); // Hint for the platform compatibility analyzer.
|
||||||
|
|
||||||
// If the user profile is available, we can protect using DPAPI.
|
// If the user profile is available, we can protect using DPAPI.
|
||||||
// Probe to see if protecting to local user is available, and use it as the default if so.
|
// Probe to see if protecting to local user is available, and use it as the default if so.
|
||||||
encryptor = new DpapiXmlEncryptor(
|
encryptor = new DpapiXmlEncryptor(
|
||||||
|
|
@ -523,10 +526,14 @@ namespace Microsoft.AspNetCore.DataProtection.KeyManagement
|
||||||
RegistryKey regKeyStorageKey = null;
|
RegistryKey regKeyStorageKey = null;
|
||||||
if (OSVersionUtil.IsWindows())
|
if (OSVersionUtil.IsWindows())
|
||||||
{
|
{
|
||||||
|
Debug.Assert(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)); // Hint for the platform compatibility analyzer.
|
||||||
regKeyStorageKey = RegistryXmlRepository.DefaultRegistryKey;
|
regKeyStorageKey = RegistryXmlRepository.DefaultRegistryKey;
|
||||||
}
|
}
|
||||||
if (regKeyStorageKey != null)
|
if (regKeyStorageKey != null)
|
||||||
{
|
{
|
||||||
|
Debug.Assert(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)); // Hint for the platform compatibility analyzer.
|
||||||
|
regKeyStorageKey = RegistryXmlRepository.DefaultRegistryKey;
|
||||||
|
|
||||||
// If the user profile isn't available, we can protect using DPAPI (to machine).
|
// If the user profile isn't available, we can protect using DPAPI (to machine).
|
||||||
encryptor = new DpapiXmlEncryptor(protectToLocalMachine: true, loggerFactory: _loggerFactory);
|
encryptor = new DpapiXmlEncryptor(protectToLocalMachine: true, loggerFactory: _loggerFactory);
|
||||||
repository = new RegistryXmlRepository(regKeyStorageKey, _loggerFactory);
|
repository = new RegistryXmlRepository(regKeyStorageKey, _loggerFactory);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Description>ASP.NET Core logic to protect and unprotect data, similar to DPAPI.</Description>
|
<Description>ASP.NET Core logic to protect and unprotect data, similar to DPAPI.</Description>
|
||||||
|
|
@ -14,6 +14,8 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="..\..\shared\src\*.cs" />
|
<Compile Include="..\..\shared\src\*.cs" />
|
||||||
|
<Compile Include="$(SharedSourceRoot)PlatformAttributes.cs"
|
||||||
|
Condition="'$(TargetFramework)' != '$(DefaultNetCoreTargetFramework)'" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Runtime.Versioning;
|
||||||
using Microsoft.AspNetCore.Cryptography;
|
using Microsoft.AspNetCore.Cryptography;
|
||||||
using Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel;
|
using Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel;
|
||||||
using Microsoft.AspNetCore.DataProtection.Internal;
|
using Microsoft.AspNetCore.DataProtection.Internal;
|
||||||
|
|
@ -17,6 +18,7 @@ namespace Microsoft.AspNetCore.DataProtection
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A type which allows reading policy from the system registry.
|
/// A type which allows reading policy from the system registry.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[SupportedOSPlatform("windows")]
|
||||||
internal sealed class RegistryPolicyResolver: IRegistryPolicyResolver
|
internal sealed class RegistryPolicyResolver: IRegistryPolicyResolver
|
||||||
{
|
{
|
||||||
private readonly Func<RegistryKey> _getPolicyRegKey;
|
private readonly Func<RegistryKey> _getPolicyRegKey;
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Versioning;
|
||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
@ -15,6 +16,7 @@ namespace Microsoft.AspNetCore.DataProtection.Repositories
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An XML repository backed by the Windows registry.
|
/// An XML repository backed by the Windows registry.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[SupportedOSPlatform("windows")]
|
||||||
public class RegistryXmlRepository : IXmlRepository
|
public class RegistryXmlRepository : IXmlRepository
|
||||||
{
|
{
|
||||||
private static readonly Lazy<RegistryKey> _defaultRegistryKeyLazy = new Lazy<RegistryKey>(GetDefaultHklmStorageKey);
|
private static readonly Lazy<RegistryKey> _defaultRegistryKeyLazy = new Lazy<RegistryKey>(GetDefaultHklmStorageKey);
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Runtime.Versioning;
|
||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using Microsoft.AspNetCore.Cryptography;
|
using Microsoft.AspNetCore.Cryptography;
|
||||||
|
|
@ -18,6 +19,7 @@ namespace Microsoft.AspNetCore.DataProtection.XmlEncryption
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// This API is only supported on Windows 8 / Windows Server 2012 and higher.
|
/// This API is only supported on Windows 8 / Windows Server 2012 and higher.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
[SupportedOSPlatform("windows")]
|
||||||
public sealed class DpapiNGXmlEncryptor : IXmlEncryptor
|
public sealed class DpapiNGXmlEncryptor : IXmlEncryptor
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Runtime.Versioning;
|
||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using Microsoft.AspNetCore.Cryptography;
|
using Microsoft.AspNetCore.Cryptography;
|
||||||
|
|
@ -16,6 +17,7 @@ namespace Microsoft.AspNetCore.DataProtection.XmlEncryption
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// This API is only supported on Windows platforms.
|
/// This API is only supported on Windows platforms.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
[SupportedOSPlatform("windows")]
|
||||||
public sealed class DpapiXmlEncryptor : IXmlEncryptor
|
public sealed class DpapiXmlEncryptor : IXmlEncryptor
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,7 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.Versioning;
|
||||||
|
|
||||||
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Hosting.WindowsServices.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
|
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Hosting.WindowsServices.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
|
||||||
|
[assembly: SupportedOSPlatform("windows")]
|
||||||
|
|
@ -162,7 +162,7 @@ namespace Microsoft.AspNetCore.Http.Headers
|
||||||
{
|
{
|
||||||
public static bool TryParse(string value, out TestHeaderValue result)
|
public static bool TryParse(string value, out TestHeaderValue result)
|
||||||
{
|
{
|
||||||
if (string.Equals("valid", value))
|
if (string.Equals("valid", value, StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
result = new TestHeaderValue();
|
result = new TestHeaderValue();
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -176,7 +176,7 @@ namespace Microsoft.AspNetCore.Http.Headers
|
||||||
var results = new List<TestHeaderValue>();
|
var results = new List<TestHeaderValue>();
|
||||||
foreach (var value in values)
|
foreach (var value in values)
|
||||||
{
|
{
|
||||||
if (string.Equals("valid", value))
|
if (string.Equals("valid", value, StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
results.Add(new TestHeaderValue());
|
results.Add(new TestHeaderValue());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -896,7 +896,7 @@ namespace Microsoft.AspNetCore.Routing.Template.Tests
|
||||||
foreach (var xconstraint in x.InlineConstraints)
|
foreach (var xconstraint in x.InlineConstraints)
|
||||||
{
|
{
|
||||||
if (!y.InlineConstraints.Any<InlineConstraint>(
|
if (!y.InlineConstraints.Any<InlineConstraint>(
|
||||||
c => string.Equals(c.Constraint, xconstraint.Constraint)))
|
c => string.Equals(c.Constraint, xconstraint.Constraint, StringComparison.Ordinal)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -257,7 +257,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
||||||
Assert.BuildOutputContainsLine(result, $"RazorTasksPath: {expected}");
|
Assert.BuildOutputContainsLine(result, $"RazorTasksPath: {expected}");
|
||||||
}
|
}
|
||||||
|
|
||||||
[ConditionalFact]
|
[ConditionalFact(Skip = "https://github.com/dotnet/aspnetcore/issues/24427")]
|
||||||
[OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)]
|
[OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)]
|
||||||
[InitializeTestProject("SimpleMvc")]
|
[InitializeTestProject("SimpleMvc")]
|
||||||
public async Task IntrospectRazorTasksDllPath_DesktopMsBuild()
|
public async Task IntrospectRazorTasksDllPath_DesktopMsBuild()
|
||||||
|
|
|
||||||
|
|
@ -315,7 +315,7 @@ namespace Microsoft.AspNetCore.Authentication.Negotiate
|
||||||
// things like ClaimsTransformation run per request.
|
// things like ClaimsTransformation run per request.
|
||||||
var identity = _negotiateState.GetIdentity();
|
var identity = _negotiateState.GetIdentity();
|
||||||
ClaimsPrincipal user;
|
ClaimsPrincipal user;
|
||||||
if (identity is WindowsIdentity winIdentity)
|
if (OperatingSystem.IsWindows() && identity is WindowsIdentity winIdentity)
|
||||||
{
|
{
|
||||||
user = new WindowsPrincipal(winIdentity);
|
user = new WindowsPrincipal(winIdentity);
|
||||||
Response.RegisterForDispose(winIdentity);
|
Response.RegisterForDispose(winIdentity);
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,9 @@
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<PackageTags>aspnetcore;weblistener;httpsys</PackageTags>
|
<PackageTags>aspnetcore;weblistener;httpsys</PackageTags>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
|
|
||||||
|
<!-- Ignore platform compatibility warnings for this project. We know this only works on windows.-->
|
||||||
|
<NoWarn>$(NoWarn);CA1416</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Runtime.Versioning;
|
||||||
using Microsoft.AspNetCore.Hosting.Server;
|
using Microsoft.AspNetCore.Hosting.Server;
|
||||||
using Microsoft.AspNetCore.Server.HttpSys;
|
using Microsoft.AspNetCore.Server.HttpSys;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
@ -11,7 +12,7 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provides extensions method to use Http.sys as the server for the web host.
|
/// Provides extensions method to use Http.sys as the server for the web host.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class WebHostBuilderHttpSysExtensions
|
public static class WebHostBuilderHttpSysExtensions
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -23,6 +24,7 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// A reference to the <see cref="IWebHostBuilder" /> parameter object.
|
/// A reference to the <see cref="IWebHostBuilder" /> parameter object.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
|
[SupportedOSPlatform("windows")]
|
||||||
public static IWebHostBuilder UseHttpSys(this IWebHostBuilder hostBuilder)
|
public static IWebHostBuilder UseHttpSys(this IWebHostBuilder hostBuilder)
|
||||||
{
|
{
|
||||||
return hostBuilder.ConfigureServices(services => {
|
return hostBuilder.ConfigureServices(services => {
|
||||||
|
|
@ -52,6 +54,7 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// A reference to the <see cref="IWebHostBuilder" /> parameter object.
|
/// A reference to the <see cref="IWebHostBuilder" /> parameter object.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
|
[SupportedOSPlatform("windows")]
|
||||||
public static IWebHostBuilder UseHttpSys(this IWebHostBuilder hostBuilder, Action<HttpSysOptions> options)
|
public static IWebHostBuilder UseHttpSys(this IWebHostBuilder hostBuilder, Action<HttpSysOptions> options)
|
||||||
{
|
{
|
||||||
return hostBuilder.UseHttpSys().ConfigureServices(services =>
|
return hostBuilder.UseHttpSys().ConfigureServices(services =>
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,15 @@
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<NativeAssetsTargetFramework>$(DefaultNetCoreTargetFramework)</NativeAssetsTargetFramework>
|
<NativeAssetsTargetFramework>$(DefaultNetCoreTargetFramework)</NativeAssetsTargetFramework>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
|
|
||||||
|
<!-- Ignore platform compatibility warnings for this project. We know this only works on windows.-->
|
||||||
|
<NoWarn>$(NoWarn);CA1416</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="$(SharedSourceRoot)TypeNameHelper\*.cs" />
|
<Compile Include="$(SharedSourceRoot)TypeNameHelper\*.cs" />
|
||||||
<Compile Include="$(SharedSourceRoot)Buffers.MemoryPool\**\*.cs" LinkBase="Shared\" />
|
<Compile Include="$(SharedSourceRoot)Buffers.MemoryPool\**\*.cs" LinkBase="Shared\" />
|
||||||
<Compile Include="$(SharedSourceRoot)HttpSys\**\*.cs" LinkBase="Shared\"/>
|
<Compile Include="$(SharedSourceRoot)HttpSys\**\*.cs" LinkBase="Shared\" />
|
||||||
<Compile Include="$(SharedSourceRoot)StackTrace\**\*.cs" LinkBase="Shared\" />
|
<Compile Include="$(SharedSourceRoot)StackTrace\**\*.cs" LinkBase="Shared\" />
|
||||||
<Compile Include="$(SharedSourceRoot)RazorViews\*.cs" LinkBase="Shared\" />
|
<Compile Include="$(SharedSourceRoot)RazorViews\*.cs" LinkBase="Shared\" />
|
||||||
<Compile Include="$(SharedSourceRoot)ErrorPage\*.cs" LinkBase="Shared\" />
|
<Compile Include="$(SharedSourceRoot)ErrorPage\*.cs" LinkBase="Shared\" />
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,9 @@
|
||||||
<PackageTags>aspnetcore;iis</PackageTags>
|
<PackageTags>aspnetcore;iis</PackageTags>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
|
|
||||||
|
<!-- Ignore platform compatibility warnings for this project. We know this only works on windows.-->
|
||||||
|
<NoWarn>$(NoWarn);CA1416</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@
|
||||||
about this structure
|
about this structure
|
||||||
-->
|
-->
|
||||||
<NoWarn>$(NoWarn);NU5100</NoWarn>
|
<NoWarn>$(NoWarn);NU5100</NoWarn>
|
||||||
|
<!-- Ignore platform compatibility analyzer warnings for test and test infrastructure -->
|
||||||
|
<NoWarn>$(NoWarn);CA1416</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Import Project="..\..\build\assets.props" />
|
<Import Project="..\..\build\assets.props" />
|
||||||
|
|
|
||||||
|
|
@ -646,7 +646,7 @@ public class Program
|
||||||
{
|
{
|
||||||
await stream.WriteAsync(new byte[] { 1, 2, 3 });
|
await stream.WriteAsync(new byte[] { 1, 2, 3 });
|
||||||
|
|
||||||
var tcs = new TaskCompletionSource<bool>(TaskContinuationOptions.RunContinuationsAsynchronously);
|
var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||||
using (_cancellationToken.Register(() => tcs.SetResult(true)))
|
using (_cancellationToken.Register(() => tcs.SetResult(true)))
|
||||||
{
|
{
|
||||||
await tcs.Task.ConfigureAwait(false);
|
await tcs.Task.ConfigureAwait(false);
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,9 @@ namespace Microsoft.AspNetCore.Certificates.Generation
|
||||||
public const int RSAMinimumKeySizeInBits = 2048;
|
public const int RSAMinimumKeySizeInBits = 2048;
|
||||||
|
|
||||||
public static CertificateManager Instance { get; } = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ?
|
public static CertificateManager Instance { get; } = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ?
|
||||||
|
#pragma warning disable CA1416 // Validate platform compatibility
|
||||||
new WindowsCertificateManager() :
|
new WindowsCertificateManager() :
|
||||||
|
#pragma warning restore CA1416 // Validate platform compatibility
|
||||||
RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ?
|
RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ?
|
||||||
new MacOSCertificateManager() as CertificateManager :
|
new MacOSCertificateManager() as CertificateManager :
|
||||||
new UnixCertificateManager();
|
new UnixCertificateManager();
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Versioning;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Certificates.Generation
|
namespace Microsoft.AspNetCore.Certificates.Generation
|
||||||
{
|
{
|
||||||
|
[SupportedOSPlatform("windows")]
|
||||||
internal class WindowsCertificateManager : CertificateManager
|
internal class WindowsCertificateManager : CertificateManager
|
||||||
{
|
{
|
||||||
private const int UserCancelledErrorCode = 1223;
|
private const int UserCancelledErrorCode = 1223;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,107 @@
|
||||||
|
// Licensed to the .NET Foundation under one or more agreements.
|
||||||
|
// The .NET Foundation licenses this file to you under the MIT license.
|
||||||
|
|
||||||
|
// Copied from https://raw.githubusercontent.com/dotnet/runtime/b45ee9d37afec0c88141053e86ccf71c6f283000/src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/PlatformAttributes.cs
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
|
namespace System.Runtime.Versioning
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Base type for all platform-specific API attributes.
|
||||||
|
/// </summary>
|
||||||
|
#pragma warning disable CS3015 // Type has no accessible constructors which use only CLS-compliant types
|
||||||
|
#if SYSTEM_PRIVATE_CORELIB
|
||||||
|
public
|
||||||
|
#else
|
||||||
|
internal
|
||||||
|
#endif
|
||||||
|
abstract class OSPlatformAttribute : Attribute
|
||||||
|
#pragma warning restore CS3015
|
||||||
|
{
|
||||||
|
private protected OSPlatformAttribute(string platformName)
|
||||||
|
{
|
||||||
|
PlatformName = platformName;
|
||||||
|
}
|
||||||
|
public string PlatformName { get; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Records the platform that the project targeted.
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Assembly,
|
||||||
|
AllowMultiple = false, Inherited = false)]
|
||||||
|
#if SYSTEM_PRIVATE_CORELIB
|
||||||
|
public
|
||||||
|
#else
|
||||||
|
internal
|
||||||
|
#endif
|
||||||
|
sealed class TargetPlatformAttribute : OSPlatformAttribute
|
||||||
|
{
|
||||||
|
public TargetPlatformAttribute(string platformName) : base(platformName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Records the operating system (and minimum version) that supports an API. Multiple attributes can be
|
||||||
|
/// applied to indicate support on multiple operating systems.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Callers can apply a <see cref="System.Runtime.Versioning.SupportedOSPlatformAttribute " />
|
||||||
|
/// or use guards to prevent calls to APIs on unsupported operating systems.
|
||||||
|
///
|
||||||
|
/// A given platform should only be specified once.
|
||||||
|
/// </remarks>
|
||||||
|
[AttributeUsage(AttributeTargets.Assembly |
|
||||||
|
AttributeTargets.Class |
|
||||||
|
AttributeTargets.Constructor |
|
||||||
|
AttributeTargets.Enum |
|
||||||
|
AttributeTargets.Event |
|
||||||
|
AttributeTargets.Field |
|
||||||
|
AttributeTargets.Method |
|
||||||
|
AttributeTargets.Module |
|
||||||
|
AttributeTargets.Property |
|
||||||
|
AttributeTargets.Struct,
|
||||||
|
AllowMultiple = true, Inherited = false)]
|
||||||
|
#if SYSTEM_PRIVATE_CORELIB
|
||||||
|
public
|
||||||
|
#else
|
||||||
|
internal
|
||||||
|
#endif
|
||||||
|
sealed class SupportedOSPlatformAttribute : OSPlatformAttribute
|
||||||
|
{
|
||||||
|
public SupportedOSPlatformAttribute (string platformName) : base(platformName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Marks APIs that were removed in a given operating system version.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Primarily used by OS bindings to indicate APIs that are only available in
|
||||||
|
/// earlier versions.
|
||||||
|
/// </remarks>
|
||||||
|
[AttributeUsage(AttributeTargets.Assembly |
|
||||||
|
AttributeTargets.Class |
|
||||||
|
AttributeTargets.Constructor |
|
||||||
|
AttributeTargets.Enum |
|
||||||
|
AttributeTargets.Event |
|
||||||
|
AttributeTargets.Field |
|
||||||
|
AttributeTargets.Method |
|
||||||
|
AttributeTargets.Module |
|
||||||
|
AttributeTargets.Property |
|
||||||
|
AttributeTargets.Struct,
|
||||||
|
AllowMultiple = true, Inherited = false)]
|
||||||
|
#if SYSTEM_PRIVATE_CORELIB
|
||||||
|
public
|
||||||
|
#else
|
||||||
|
internal
|
||||||
|
#endif
|
||||||
|
sealed class UnsupportedOSPlatformAttribute : OSPlatformAttribute
|
||||||
|
{
|
||||||
|
public UnsupportedOSPlatformAttribute(string platformName) : base(platformName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -55,12 +55,13 @@ namespace System.Net.Http.Unit.Tests.HPack
|
||||||
public void IntegerEncoderDecoderRoundtrips()
|
public void IntegerEncoderDecoderRoundtrips()
|
||||||
{
|
{
|
||||||
IntegerDecoder decoder = new IntegerDecoder();
|
IntegerDecoder decoder = new IntegerDecoder();
|
||||||
|
Span<byte> integerBytes = stackalloc byte[5];
|
||||||
|
|
||||||
for (int i = 0; i < 2048; ++i)
|
for (int i = 0; i < 2048; ++i)
|
||||||
{
|
{
|
||||||
for (int prefixLength = 1; prefixLength <= 8; ++prefixLength)
|
for (int prefixLength = 1; prefixLength <= 8; ++prefixLength)
|
||||||
{
|
{
|
||||||
Span<byte> integerBytes = stackalloc byte[5];
|
integerBytes.Clear();
|
||||||
Assert.True(IntegerEncoder.Encode(i, prefixLength, integerBytes, out int length));
|
Assert.True(IntegerEncoder.Encode(i, prefixLength, integerBytes, out int length));
|
||||||
|
|
||||||
bool decodeResult = decoder.BeginTryDecode(integerBytes[0], prefixLength, out int intResult);
|
bool decodeResult = decoder.BeginTryDecode(integerBytes[0], prefixLength, out int intResult);
|
||||||
|
|
|
||||||
|
|
@ -580,7 +580,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal
|
||||||
if (oldContext.User.Identity is WindowsIdentity windowsIdentity)
|
if (oldContext.User.Identity is WindowsIdentity windowsIdentity)
|
||||||
{
|
{
|
||||||
var skipFirstIdentity = false;
|
var skipFirstIdentity = false;
|
||||||
if (oldContext.User is WindowsPrincipal)
|
if (OperatingSystem.IsWindows() && oldContext.User is WindowsPrincipal)
|
||||||
{
|
{
|
||||||
// We want to explicitly create a WindowsPrincipal instead of a ClaimsPrincipal
|
// We want to explicitly create a WindowsPrincipal instead of a ClaimsPrincipal
|
||||||
// so methods that WindowsPrincipal overrides like 'IsInRole', work as expected.
|
// so methods that WindowsPrincipal overrides like 'IsInRole', work as expected.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue