Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eng/RequiresDelayedBuildProjects.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<ItemGroup>
<RequiresDelayedBuild Include="$(RepoRoot)src\DataProtection\DataProtection\test\Microsoft.AspNetCore.DataProtection.TrimmingTests\Microsoft.AspNetCore.DataProtection.TrimmingTests.proj" />
<RequiresDelayedBuild Include="$(RepoRoot)src\DefaultBuilder\test\Microsoft.AspNetCore.NativeAotTests\Microsoft.AspNetCore.NativeAotTests.proj" />
<RequiresDelayedBuild Include="$(RepoRoot)src\DefaultBuilder\test\Microsoft.AspNetCore.TrimmingTests\Microsoft.AspNetCore.TrimmingTests.proj" />
<RequiresDelayedBuild Include="$(RepoRoot)src\Grpc\JsonTranscoding\perf\Microsoft.AspNetCore.Grpc.Microbenchmarks\Microsoft.AspNetCore.Grpc.Microbenchmarks.csproj" />
<RequiresDelayedBuild Include="$(RepoRoot)src\Grpc\JsonTranscoding\src\Microsoft.AspNetCore.Grpc.JsonTranscoding\Microsoft.AspNetCore.Grpc.JsonTranscoding.csproj" />
<RequiresDelayedBuild Include="$(RepoRoot)src\Grpc\JsonTranscoding\src\Microsoft.AspNetCore.Grpc.Swagger\Microsoft.AspNetCore.Grpc.Swagger.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<TestConsoleAppSourceFiles Include="SlimBuilderDoesNotDependOnX509Test0.cs">
<DisabledFeatureSwitches>System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault</DisabledFeatureSwitches>
<AdditionalSourceFiles>X509Utilities.cs</AdditionalSourceFiles>
</TestConsoleAppSourceFiles>
<TestConsoleAppSourceFiles Include="SlimBuilderDoesNotDependOnX509Test1.cs">
<DisabledFeatureSwitches>System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault</DisabledFeatureSwitches>
<AdditionalSourceFiles>X509Utilities.cs</AdditionalSourceFiles>
</TestConsoleAppSourceFiles>
<TestConsoleAppSourceFiles Include="SlimBuilderDoesNotDependOnX509Test2.cs">
<DisabledFeatureSwitches>System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault</DisabledFeatureSwitches>
<AdditionalSourceFiles>X509Utilities.cs</AdditionalSourceFiles>
</TestConsoleAppSourceFiles>
<TestConsoleAppSourceFiles Include="SlimBuilderDoesNotDependOnX509Test3.cs">
<DisabledFeatureSwitches>System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault</DisabledFeatureSwitches>
<AdditionalSourceFiles>X509Utilities.cs</AdditionalSourceFiles>
</TestConsoleAppSourceFiles>
<TestConsoleAppSourceFiles Include="SlimBuilderDoesNotDependOnX509Test4.cs">
<DisabledFeatureSwitches>System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault</DisabledFeatureSwitches>
<AdditionalSourceFiles>X509Utilities.cs</AdditionalSourceFiles>
</TestConsoleAppSourceFiles>
<TestConsoleAppSourceFiles Include="SlimBuilderDoesNotDependOnX509Test5.cs">
<DisabledFeatureSwitches>System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault</DisabledFeatureSwitches>
<AdditionalSourceFiles>X509Utilities.cs</AdditionalSourceFiles>
</TestConsoleAppSourceFiles>
<TestConsoleAppSourceFiles Include="SlimBuilderDoesNotDependOnX509Test6.cs">
<DisabledFeatureSwitches>System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault</DisabledFeatureSwitches>
<AdditionalSourceFiles>X509Utilities.cs</AdditionalSourceFiles>
</TestConsoleAppSourceFiles>
<TestConsoleAppSourceFiles Include="SlimBuilderDoesNotDependOnX509Test7.cs">
<DisabledFeatureSwitches>System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault</DisabledFeatureSwitches>
<AdditionalSourceFiles>X509Utilities.cs</AdditionalSourceFiles>
</TestConsoleAppSourceFiles>
<TestConsoleAppSourceFiles Include="SlimBuilderDoesNotDependOnX509Test8.cs">
<DisabledFeatureSwitches>System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault</DisabledFeatureSwitches>
<AdditionalSourceFiles>X509Utilities.cs</AdditionalSourceFiles>
</TestConsoleAppSourceFiles>
<TestConsoleAppSourceFiles Include="SlimBuilderDoesNotDependOnX509Test9.cs">
<DisabledFeatureSwitches>System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault</DisabledFeatureSwitches>
<AdditionalSourceFiles>X509Utilities.cs</AdditionalSourceFiles>
</TestConsoleAppSourceFiles>
<TestConsoleAppSourceFiles Include="UseHttpsDoesDependOnX509Test.cs">
<DisabledFeatureSwitches>System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault</DisabledFeatureSwitches>
<AdditionalSourceFiles>X509Utilities.cs</AdditionalSourceFiles>
</TestConsoleAppSourceFiles>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.AspNetCore.Builder;

var builder = WebApplication.CreateSlimBuilder(args);
var app = builder.Build();

if (X509Utilities.HasCertificateType) {
return 19;
}

return 100; // Success
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.AspNetCore.Builder;

var builder = WebApplication.CreateSlimBuilder(args);
var app = builder.Build();

if (X509Utilities.HasCertificateType) {
return 19;
}

return 100; // Success
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.AspNetCore.Builder;

var builder = WebApplication.CreateSlimBuilder(args);
var app = builder.Build();

if (X509Utilities.HasCertificateType) {
return 19;
}

return 100; // Success
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.AspNetCore.Builder;

var builder = WebApplication.CreateSlimBuilder(args);
var app = builder.Build();

if (X509Utilities.HasCertificateType) {
return 19;
}

return 100; // Success
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.AspNetCore.Builder;

var builder = WebApplication.CreateSlimBuilder(args);
var app = builder.Build();

if (X509Utilities.HasCertificateType) {
return 19;
}

return 100; // Success
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.AspNetCore.Builder;

var builder = WebApplication.CreateSlimBuilder(args);
var app = builder.Build();

if (X509Utilities.HasCertificateType) {
return 19;
}

return 100; // Success
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.AspNetCore.Builder;

var builder = WebApplication.CreateSlimBuilder(args);
var app = builder.Build();

if (X509Utilities.HasCertificateType) {
return 19;
}

return 100; // Success
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.AspNetCore.Builder;

var builder = WebApplication.CreateSlimBuilder(args);
var app = builder.Build();

if (X509Utilities.HasCertificateType) {
return 19;
}

return 100; // Success
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.AspNetCore.Builder;

var builder = WebApplication.CreateSlimBuilder(args);
var app = builder.Build();

if (X509Utilities.HasCertificateType) {
return 19;
}

return 100; // Success
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.AspNetCore.Builder;

var builder = WebApplication.CreateSlimBuilder(args);
var app = builder.Build();

if (X509Utilities.HasCertificateType) {
return 19;
}

return 100; // Success
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Security.Cryptography.X509Certificates;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;

var builder = WebApplication.CreateSlimBuilder(args);

builder.WebHost.UseKestrel(serverOptions =>
{
serverOptions.ListenLocalhost(5000, listenOptions =>
{
listenOptions.UseHttps();
});
});

try
{
_ = builder.Build();
}
catch (InvalidOperationException)
{
// Expected if there's no dev cert installed
}

if (!X509Utilities.HasCertificateType) {
return -1;
}

return 100; // Success
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using Microsoft.AspNetCore.Builder;

#nullable enable

public static class X509Utilities
{
public static bool HasCertificateType =>
GetType("System.Security.Cryptography", "System.Security.Cryptography.X509Certificates", "X509Certificate") is not null;

[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2057:UnrecognizedReflectionPattern",
Justification = "Returning null when the type is unreferenced is desirable")]
private static Type? GetType(string assemblyName, string namespaceName, string typeName) {
return Type.GetType($"{namespaceName}.{typeName}, {assemblyName}");
}
}