diff --git a/eng/Dependencies.props b/eng/Dependencies.props
index 0fbdbd667a71..3dcffbbef1d8 100644
--- a/eng/Dependencies.props
+++ b/eng/Dependencies.props
@@ -68,6 +68,7 @@ and are generated based on the last package release.
+
diff --git a/eng/TrimmableProjects.props b/eng/TrimmableProjects.props
index 2721673fb8db..a0b698bab8bc 100644
--- a/eng/TrimmableProjects.props
+++ b/eng/TrimmableProjects.props
@@ -28,6 +28,7 @@
+
@@ -37,7 +38,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -48,6 +70,9 @@
+
+
+
diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml
index 5885135ec1a3..eff998b5d354 100644
--- a/eng/Version.Details.xml
+++ b/eng/Version.Details.xml
@@ -181,6 +181,10 @@
https://github.com/dotnet/runtime
c10154087e734fa58f08f2797e5d99404e9cd96b
+
+ https://github.com/dotnet/runtime
+ c10154087e734fa58f08f2797e5d99404e9cd96b
+
https://github.com/dotnet/runtime
c10154087e734fa58f08f2797e5d99404e9cd96b
diff --git a/eng/Versions.props b/eng/Versions.props
index 7edf81dc11e6..b93c488586fe 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -105,6 +105,7 @@
7.0.0-preview.5.22226.6
7.0.0-preview.5.22226.6
7.0.0-preview.5.22226.6
+ 7.0.0-preview.5.22226.6
7.0.0-preview.5.22226.6
7.0.0-preview.5.22226.6
7.0.0-preview.5.22226.6
diff --git a/src/HealthChecks/Abstractions/src/Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.csproj b/src/HealthChecks/Abstractions/src/Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.csproj
index 378bdfe8374d..bcd1333e1e9f 100644
--- a/src/HealthChecks/Abstractions/src/Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.csproj
+++ b/src/HealthChecks/Abstractions/src/Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.csproj
@@ -1,4 +1,4 @@
-
+
Abstractions for defining health checks in .NET applications
@@ -12,7 +12,7 @@ Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck
true
diagnostics;healthchecks
true
- enable
+ true
diff --git a/src/HealthChecks/HealthChecks/src/DependencyInjection/HealthChecksBuilderAddCheckExtensions.cs b/src/HealthChecks/HealthChecks/src/DependencyInjection/HealthChecksBuilderAddCheckExtensions.cs
index 1305ba238734..44f2436f1d00 100644
--- a/src/HealthChecks/HealthChecks/src/DependencyInjection/HealthChecksBuilderAddCheckExtensions.cs
+++ b/src/HealthChecks/HealthChecks/src/DependencyInjection/HealthChecksBuilderAddCheckExtensions.cs
@@ -95,7 +95,7 @@ public static IHealthChecksBuilder AddCheck(
/// access to services from the dependency injection container.
///
// 2.0 BACKCOMPAT OVERLOAD -- DO NOT TOUCH
- public static IHealthChecksBuilder AddCheck(
+ public static IHealthChecksBuilder AddCheck<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] T>(
this IHealthChecksBuilder builder,
string name,
HealthStatus? failureStatus,
@@ -123,8 +123,7 @@ public static IHealthChecksBuilder AddCheck(
/// with any lifetime it will be used. Otherwise an instance of type will be constructed with
/// access to services from the dependency injection container.
///
- [SuppressMessage("ApiDesign", "RS0027:Public API with optional parameter(s) should have the most parameters amongst its public overloads.", Justification = "Required to maintain compatibility")]
- public static IHealthChecksBuilder AddCheck(
+ public static IHealthChecksBuilder AddCheck<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] T>(
this IHealthChecksBuilder builder,
string name,
HealthStatus? failureStatus = null,
@@ -141,7 +140,12 @@ public static IHealthChecksBuilder AddCheck(
throw new ArgumentNullException(nameof(name));
}
- return builder.Add(new HealthCheckRegistration(name, s => ActivatorUtilities.GetServiceOrCreateInstance(s), failureStatus, tags, timeout));
+ return builder.Add(new HealthCheckRegistration(name, GetServiceOrCreateInstance, failureStatus, tags, timeout));
+
+ [UnconditionalSuppressMessage("Trimming", "IL2091",
+ Justification = "DynamicallyAccessedMemberTypes.PublicConstructors is enforced by calling method.")]
+ static T GetServiceOrCreateInstance(IServiceProvider serviceProvider) =>
+ ActivatorUtilities.GetServiceOrCreateInstance(serviceProvider);
}
// NOTE: AddTypeActivatedCheck has overloads rather than default parameters values, because default parameter values don't
@@ -159,7 +163,9 @@ public static IHealthChecksBuilder AddCheck(
/// This method will use to create the health check
/// instance when needed. Additional arguments can be provided to the constructor via .
///
- public static IHealthChecksBuilder AddTypeActivatedCheck(this IHealthChecksBuilder builder, string name, params object[] args) where T : class, IHealthCheck
+ public static IHealthChecksBuilder AddTypeActivatedCheck<
+ [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] T>(
+ this IHealthChecksBuilder builder, string name, params object[] args) where T : class, IHealthCheck
{
if (builder == null)
{
@@ -190,7 +196,8 @@ public static IHealthChecksBuilder AddTypeActivatedCheck(this IHealthChecksBu
/// This method will use to create the health check
/// instance when needed. Additional arguments can be provided to the constructor via .
///
- public static IHealthChecksBuilder AddTypeActivatedCheck(
+ public static IHealthChecksBuilder AddTypeActivatedCheck<
+ [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] T>(
this IHealthChecksBuilder builder,
string name,
HealthStatus? failureStatus,
@@ -226,7 +233,8 @@ public static IHealthChecksBuilder AddTypeActivatedCheck(
/// This method will use to create the health check
/// instance when needed. Additional arguments can be provided to the constructor via .
///
- public static IHealthChecksBuilder AddTypeActivatedCheck(
+ public static IHealthChecksBuilder AddTypeActivatedCheck<
+ [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] T>(
this IHealthChecksBuilder builder,
string name,
HealthStatus? failureStatus,
@@ -243,7 +251,12 @@ public static IHealthChecksBuilder AddTypeActivatedCheck(
throw new ArgumentNullException(nameof(name));
}
- return builder.Add(new HealthCheckRegistration(name, s => ActivatorUtilities.CreateInstance(s, args), failureStatus, tags));
+ return builder.Add(new HealthCheckRegistration(name, CreateInstance, failureStatus, tags));
+
+ [UnconditionalSuppressMessage("Trimming", "IL2091",
+ Justification = "DynamicallyAccessedMemberTypes.PublicConstructors is enforced by calling method.")]
+ T CreateInstance(IServiceProvider serviceProvider) =>
+ ActivatorUtilities.CreateInstance(serviceProvider, args);
}
///
@@ -264,7 +277,8 @@ public static IHealthChecksBuilder AddTypeActivatedCheck(
/// This method will use to create the health check
/// instance when needed. Additional arguments can be provided to the constructor via .
///
- public static IHealthChecksBuilder AddTypeActivatedCheck(
+ public static IHealthChecksBuilder AddTypeActivatedCheck<
+ [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] T>(
this IHealthChecksBuilder builder,
string name,
HealthStatus? failureStatus,
@@ -282,6 +296,10 @@ public static IHealthChecksBuilder AddTypeActivatedCheck(
throw new ArgumentNullException(nameof(name));
}
- return builder.Add(new HealthCheckRegistration(name, s => ActivatorUtilities.CreateInstance(s, args), failureStatus, tags, timeout));
+ return builder.Add(new HealthCheckRegistration(name, CreateInstance, failureStatus, tags, timeout));
+
+ [UnconditionalSuppressMessage("Trimming", "IL2091",
+ Justification = "DynamicallyAccessedMemberTypes.PublicConstructors is enforced by calling method.")]
+ T CreateInstance(IServiceProvider serviceProvider) => ActivatorUtilities.CreateInstance(serviceProvider, args);
}
}
diff --git a/src/HealthChecks/HealthChecks/src/Microsoft.Extensions.Diagnostics.HealthChecks.csproj b/src/HealthChecks/HealthChecks/src/Microsoft.Extensions.Diagnostics.HealthChecks.csproj
index 8cb2a979d8ab..0bd7265565ce 100644
--- a/src/HealthChecks/HealthChecks/src/Microsoft.Extensions.Diagnostics.HealthChecks.csproj
+++ b/src/HealthChecks/HealthChecks/src/Microsoft.Extensions.Diagnostics.HealthChecks.csproj
@@ -11,9 +11,7 @@ Microsoft.Extensions.Diagnostics.HealthChecks.IHealthChecksBuilder
true
diagnostics;healthchecks
true
- enable
-
- $(NoWarn);SYSLIB1006
+ true
@@ -23,6 +21,9 @@ Microsoft.Extensions.Diagnostics.HealthChecks.IHealthChecksBuilder
+
+
diff --git a/src/Html.Abstractions/src/Microsoft.AspNetCore.Html.Abstractions.csproj b/src/Html.Abstractions/src/Microsoft.AspNetCore.Html.Abstractions.csproj
index 9f3710febf4c..4b87bfed848f 100644
--- a/src/Html.Abstractions/src/Microsoft.AspNetCore.Html.Abstractions.csproj
+++ b/src/Html.Abstractions/src/Microsoft.AspNetCore.Html.Abstractions.csproj
@@ -11,7 +11,7 @@ Microsoft.AspNetCore.Html.IHtmlContent
true
aspnetcore
false
- enable
+ true
diff --git a/src/Middleware/CORS/src/Microsoft.AspNetCore.Cors.csproj b/src/Middleware/CORS/src/Microsoft.AspNetCore.Cors.csproj
index ac6088f6b326..751cf4415ad5 100644
--- a/src/Middleware/CORS/src/Microsoft.AspNetCore.Cors.csproj
+++ b/src/Middleware/CORS/src/Microsoft.AspNetCore.Cors.csproj
@@ -10,7 +10,7 @@ Microsoft.AspNetCore.Cors.EnableCorsAttribute
true
aspnetcore;cors
false
- enable
+ true
diff --git a/src/Middleware/Diagnostics.Abstractions/src/Microsoft.AspNetCore.Diagnostics.Abstractions.csproj b/src/Middleware/Diagnostics.Abstractions/src/Microsoft.AspNetCore.Diagnostics.Abstractions.csproj
index 6696c7c0387a..7c88f05a958f 100644
--- a/src/Middleware/Diagnostics.Abstractions/src/Microsoft.AspNetCore.Diagnostics.Abstractions.csproj
+++ b/src/Middleware/Diagnostics.Abstractions/src/Microsoft.AspNetCore.Diagnostics.Abstractions.csproj
@@ -7,7 +7,7 @@
true
aspnetcore;diagnostics
false
- enable
+ true
diff --git a/src/Middleware/Diagnostics.EntityFrameworkCore/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.csproj b/src/Middleware/Diagnostics.EntityFrameworkCore/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.csproj
index 741861605894..b4716f36d3b2 100644
--- a/src/Middleware/Diagnostics.EntityFrameworkCore/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.csproj
+++ b/src/Middleware/Diagnostics.EntityFrameworkCore/src/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.csproj
@@ -5,7 +5,7 @@
$(DefaultNetCoreTargetFramework)
true
aspnetcore;diagnostics;entityframeworkcore
- enable
+ true
diff --git a/src/Middleware/Diagnostics.EntityFrameworkCore/src/MigrationsEndPointMiddleware.cs b/src/Middleware/Diagnostics.EntityFrameworkCore/src/MigrationsEndPointMiddleware.cs
index 4178a8bdca17..a78e2fb80a80 100644
--- a/src/Middleware/Diagnostics.EntityFrameworkCore/src/MigrationsEndPointMiddleware.cs
+++ b/src/Middleware/Diagnostics.EntityFrameworkCore/src/MigrationsEndPointMiddleware.cs
@@ -121,7 +121,9 @@ private async Task InvokeCore(HttpContext context)
var registeredContexts = context.RequestServices.GetServices()
.Select(o => o.ContextType);
- if (!registeredContexts.Any(c => string.Equals(contextTypeName, c.AssemblyQualifiedName)))
+ var contextType = registeredContexts.FirstOrDefault(c => string.Equals(contextTypeName, c.AssemblyQualifiedName, StringComparison.Ordinal));
+
+ if (contextType is null)
{
var message = Strings.FormatMigrationsEndPointMiddleware_ContextNotRegistered(contextTypeName);
@@ -132,8 +134,6 @@ private async Task InvokeCore(HttpContext context)
return null;
}
- var contextType = Type.GetType(contextTypeName)!;
-
var db = (DbContext?)context.RequestServices.GetService(contextType);
return db;
diff --git a/src/Middleware/Diagnostics/src/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs b/src/Middleware/Diagnostics/src/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs
index 4780baeb146e..979c71a2ad24 100644
--- a/src/Middleware/Diagnostics/src/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs
+++ b/src/Middleware/Diagnostics/src/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using Microsoft.AspNetCore.Builder;
@@ -115,9 +116,10 @@ public async Task Invoke(HttpContext context)
await _exceptionHandler(new ErrorContext(context, ex));
- if (_diagnosticSource.IsEnabled("Microsoft.AspNetCore.Diagnostics.UnhandledException"))
+ const string eventName = "Microsoft.AspNetCore.Diagnostics.UnhandledException";
+ if (_diagnosticSource.IsEnabled(eventName))
{
- _diagnosticSource.Write("Microsoft.AspNetCore.Diagnostics.UnhandledException", new { httpContext = context, exception = ex });
+ WriteDiagnosticEvent(_diagnosticSource, eventName, new { httpContext = context, exception = ex });
}
return;
@@ -129,6 +131,11 @@ public async Task Invoke(HttpContext context)
}
throw;
}
+
+ [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026",
+ Justification = "The values being passed into Write have the commonly used properties being preserved with DynamicDependency.")]
+ static void WriteDiagnosticEvent(DiagnosticSource diagnosticSource, string name, TValue value)
+ => diagnosticSource.Write(name, value);
}
// Assumes the response headers have not been sent. If they have, still attempt to write to the body.
diff --git a/src/Middleware/Diagnostics/src/ExceptionHandler/ExceptionHandlerMiddleware.cs b/src/Middleware/Diagnostics/src/ExceptionHandler/ExceptionHandlerMiddleware.cs
index 28a09ff14472..d7dd4ff90e1d 100644
--- a/src/Middleware/Diagnostics/src/ExceptionHandler/ExceptionHandlerMiddleware.cs
+++ b/src/Middleware/Diagnostics/src/ExceptionHandler/ExceptionHandlerMiddleware.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using System.Runtime.ExceptionServices;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
@@ -135,9 +136,10 @@ private async Task HandleException(HttpContext context, ExceptionDispatchInfo ed
// If the response has already started, assume exception handler was successful.
if (context.Response.HasStarted || context.Response.StatusCode != StatusCodes.Status404NotFound || _options.AllowStatusCode404Response)
{
- if (_diagnosticListener.IsEnabled() && _diagnosticListener.IsEnabled("Microsoft.AspNetCore.Diagnostics.HandledException"))
+ const string eventName = "Microsoft.AspNetCore.Diagnostics.HandledException";
+ if (_diagnosticListener.IsEnabled() && _diagnosticListener.IsEnabled(eventName))
{
- _diagnosticListener.Write("Microsoft.AspNetCore.Diagnostics.HandledException", new { httpContext = context, exception = edi.SourceException });
+ WriteDiagnosticEvent(_diagnosticListener, eventName, new { httpContext = context, exception = edi.SourceException });
}
return;
@@ -158,6 +160,11 @@ private async Task HandleException(HttpContext context, ExceptionDispatchInfo ed
}
edi.Throw(); // Re-throw wrapped exception or the original if we couldn't handle it
+
+ [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026",
+ Justification = "The values being passed into Write have the commonly used properties being preserved with DynamicDependency.")]
+ static void WriteDiagnosticEvent(DiagnosticSource diagnosticSource, string name, TValue value)
+ => diagnosticSource.Write(name, value);
}
private static void ClearHttpContext(HttpContext context)
diff --git a/src/Middleware/Diagnostics/src/Microsoft.AspNetCore.Diagnostics.csproj b/src/Middleware/Diagnostics/src/Microsoft.AspNetCore.Diagnostics.csproj
index 3a479bf0a025..ebf506b0a0ae 100644
--- a/src/Middleware/Diagnostics/src/Microsoft.AspNetCore.Diagnostics.csproj
+++ b/src/Middleware/Diagnostics/src/Microsoft.AspNetCore.Diagnostics.csproj
@@ -7,7 +7,7 @@
true
aspnetcore;diagnostics
false
- enable
+ true
diff --git a/src/Middleware/HeaderPropagation/src/Microsoft.AspNetCore.HeaderPropagation.csproj b/src/Middleware/HeaderPropagation/src/Microsoft.AspNetCore.HeaderPropagation.csproj
index c0c8415105ba..10e0fc033379 100644
--- a/src/Middleware/HeaderPropagation/src/Microsoft.AspNetCore.HeaderPropagation.csproj
+++ b/src/Middleware/HeaderPropagation/src/Microsoft.AspNetCore.HeaderPropagation.csproj
@@ -5,7 +5,7 @@
$(DefaultNetCoreTargetFramework)
true
aspnetcore;httpclient
- enable
+ true
diff --git a/src/Middleware/HealthChecks.EntityFrameworkCore/src/Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore.csproj b/src/Middleware/HealthChecks.EntityFrameworkCore/src/Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore.csproj
index 7dc9d6dac221..2dfa54b0c102 100644
--- a/src/Middleware/HealthChecks.EntityFrameworkCore/src/Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore.csproj
+++ b/src/Middleware/HealthChecks.EntityFrameworkCore/src/Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore.csproj
@@ -8,7 +8,7 @@
true
diagnostics;healthchecks;entityframeworkcore
Microsoft.Extensions.Diagnostics.HealthChecks
- enable
+ true
diff --git a/src/Middleware/HealthChecks/src/Microsoft.AspNetCore.Diagnostics.HealthChecks.csproj b/src/Middleware/HealthChecks/src/Microsoft.AspNetCore.Diagnostics.HealthChecks.csproj
index 1da2d8fb5b73..8a6aebd55d40 100644
--- a/src/Middleware/HealthChecks/src/Microsoft.AspNetCore.Diagnostics.HealthChecks.csproj
+++ b/src/Middleware/HealthChecks/src/Microsoft.AspNetCore.Diagnostics.HealthChecks.csproj
@@ -7,7 +7,7 @@
true
diagnostics;healthchecks
false
- enable
+ true
diff --git a/src/Middleware/HostFiltering/src/Microsoft.AspNetCore.HostFiltering.csproj b/src/Middleware/HostFiltering/src/Microsoft.AspNetCore.HostFiltering.csproj
index d041ad41ce04..7ea30334f14f 100644
--- a/src/Middleware/HostFiltering/src/Microsoft.AspNetCore.HostFiltering.csproj
+++ b/src/Middleware/HostFiltering/src/Microsoft.AspNetCore.HostFiltering.csproj
@@ -9,7 +9,7 @@
true
aspnetcore
false
- enable
+ true
diff --git a/src/Middleware/HttpLogging/src/Microsoft.AspNetCore.HttpLogging.csproj b/src/Middleware/HttpLogging/src/Microsoft.AspNetCore.HttpLogging.csproj
index 7fc0102e1312..5e304b5dfccf 100644
--- a/src/Middleware/HttpLogging/src/Microsoft.AspNetCore.HttpLogging.csproj
+++ b/src/Middleware/HttpLogging/src/Microsoft.AspNetCore.HttpLogging.csproj
@@ -9,14 +9,14 @@
true
true
false
- enable
+ true
true
-
+
diff --git a/src/Middleware/HttpsPolicy/src/HttpsRedirectionMiddleware.cs b/src/Middleware/HttpsPolicy/src/HttpsRedirectionMiddleware.cs
index 74f32307c539..ebc479192b1e 100644
--- a/src/Middleware/HttpsPolicy/src/HttpsRedirectionMiddleware.cs
+++ b/src/Middleware/HttpsPolicy/src/HttpsRedirectionMiddleware.cs
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
+using System.Globalization;
using Microsoft.AspNetCore.Hosting.Server.Features;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Extensions;
@@ -123,7 +124,7 @@ private int TryGetHttpsPort()
// 3. IServerAddressesFeature
// 4. Fail if not sets
- var nullablePort = _config.GetValue("HTTPS_PORT") ?? _config.GetValue("ANCM_HTTPS_PORT");
+ var nullablePort = GetIntConfigValue("HTTPS_PORT") ?? GetIntConfigValue("ANCM_HTTPS_PORT");
if (nullablePort.HasValue)
{
var port = nullablePort.Value;
@@ -165,5 +166,8 @@ private int TryGetHttpsPort()
_logger.FailedToDeterminePort();
return PortNotFound;
+
+ int? GetIntConfigValue(string name) =>
+ int.TryParse(_config[name], NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out var value) ? value : null;
}
}
diff --git a/src/Middleware/HttpsPolicy/src/Microsoft.AspNetCore.HttpsPolicy.csproj b/src/Middleware/HttpsPolicy/src/Microsoft.AspNetCore.HttpsPolicy.csproj
index c14e35c11fda..2722a69c9d5b 100644
--- a/src/Middleware/HttpsPolicy/src/Microsoft.AspNetCore.HttpsPolicy.csproj
+++ b/src/Middleware/HttpsPolicy/src/Microsoft.AspNetCore.HttpsPolicy.csproj
@@ -9,7 +9,7 @@
true
aspnetcore;https;hsts
false
- enable
+ true
diff --git a/src/Middleware/Localization.Routing/src/Microsoft.AspNetCore.Localization.Routing.csproj b/src/Middleware/Localization.Routing/src/Microsoft.AspNetCore.Localization.Routing.csproj
index e6a7d7337824..0177a1bbaa68 100644
--- a/src/Middleware/Localization.Routing/src/Microsoft.AspNetCore.Localization.Routing.csproj
+++ b/src/Middleware/Localization.Routing/src/Microsoft.AspNetCore.Localization.Routing.csproj
@@ -8,7 +8,7 @@
true
aspnetcore;localization
false
- enable
+ true
diff --git a/src/Middleware/Localization/src/Microsoft.AspNetCore.Localization.csproj b/src/Middleware/Localization/src/Microsoft.AspNetCore.Localization.csproj
index 0824605d9c0d..d66c2ed3e540 100644
--- a/src/Middleware/Localization/src/Microsoft.AspNetCore.Localization.csproj
+++ b/src/Middleware/Localization/src/Microsoft.AspNetCore.Localization.csproj
@@ -8,7 +8,7 @@
true
aspnetcore;localization
false
- enable
+ true
diff --git a/src/Middleware/RateLimiting/src/Microsoft.AspNetCore.RateLimiting.csproj b/src/Middleware/RateLimiting/src/Microsoft.AspNetCore.RateLimiting.csproj
index b8ba30375ac4..b35039fe3ace 100644
--- a/src/Middleware/RateLimiting/src/Microsoft.AspNetCore.RateLimiting.csproj
+++ b/src/Middleware/RateLimiting/src/Microsoft.AspNetCore.RateLimiting.csproj
@@ -5,6 +5,7 @@
$(DefaultNetCoreTargetFramework)
true
aspnetcore
+ true
diff --git a/src/Middleware/ResponseCaching.Abstractions/src/Microsoft.AspNetCore.ResponseCaching.Abstractions.csproj b/src/Middleware/ResponseCaching.Abstractions/src/Microsoft.AspNetCore.ResponseCaching.Abstractions.csproj
index 0fab4e01b07c..794dcb7accb8 100644
--- a/src/Middleware/ResponseCaching.Abstractions/src/Microsoft.AspNetCore.ResponseCaching.Abstractions.csproj
+++ b/src/Middleware/ResponseCaching.Abstractions/src/Microsoft.AspNetCore.ResponseCaching.Abstractions.csproj
@@ -7,7 +7,7 @@
true
aspnetcore;cache;caching
false
- enable
+ true
diff --git a/src/Middleware/ResponseCaching/src/Microsoft.AspNetCore.ResponseCaching.csproj b/src/Middleware/ResponseCaching/src/Microsoft.AspNetCore.ResponseCaching.csproj
index 73cd7526a089..850a333288be 100644
--- a/src/Middleware/ResponseCaching/src/Microsoft.AspNetCore.ResponseCaching.csproj
+++ b/src/Middleware/ResponseCaching/src/Microsoft.AspNetCore.ResponseCaching.csproj
@@ -8,7 +8,7 @@
true
aspnetcore;cache;caching
false
- enable
+ true
diff --git a/src/Middleware/ResponseCompression/src/CompressionProviderCollection.cs b/src/Middleware/ResponseCompression/src/CompressionProviderCollection.cs
index e3de051de5dc..1b1f80aeb292 100644
--- a/src/Middleware/ResponseCompression/src/CompressionProviderCollection.cs
+++ b/src/Middleware/ResponseCompression/src/CompressionProviderCollection.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.ObjectModel;
+using System.Diagnostics.CodeAnalysis;
namespace Microsoft.AspNetCore.ResponseCompression;
@@ -16,7 +17,8 @@ public class CompressionProviderCollection : Collection
///
/// Provider instances will be created using an .
///
- public void Add() where TCompressionProvider : ICompressionProvider
+ public void Add<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TCompressionProvider>()
+ where TCompressionProvider : ICompressionProvider
{
Add(typeof(TCompressionProvider));
}
@@ -28,7 +30,7 @@ public void Add() where TCompressionProvider : ICompressio
///
/// Provider instances will be created using an .
///
- public void Add(Type providerType)
+ public void Add([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type providerType)
{
if (providerType == null)
{
diff --git a/src/Middleware/ResponseCompression/src/CompressionProviderFactory.cs b/src/Middleware/ResponseCompression/src/CompressionProviderFactory.cs
index 370d01897e49..5cb1b39b9744 100644
--- a/src/Middleware/ResponseCompression/src/CompressionProviderFactory.cs
+++ b/src/Middleware/ResponseCompression/src/CompressionProviderFactory.cs
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
+using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.AspNetCore.ResponseCompression;
@@ -11,11 +12,12 @@ namespace Microsoft.AspNetCore.ResponseCompression;
///
internal class CompressionProviderFactory : ICompressionProvider
{
- public CompressionProviderFactory(Type providerType)
+ public CompressionProviderFactory([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type providerType)
{
ProviderType = providerType;
}
+ [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]
private Type ProviderType { get; }
public ICompressionProvider CreateInstance(IServiceProvider serviceProvider)
diff --git a/src/Middleware/ResponseCompression/src/Microsoft.AspNetCore.ResponseCompression.csproj b/src/Middleware/ResponseCompression/src/Microsoft.AspNetCore.ResponseCompression.csproj
index 67ef58a98417..99aedcc08b58 100644
--- a/src/Middleware/ResponseCompression/src/Microsoft.AspNetCore.ResponseCompression.csproj
+++ b/src/Middleware/ResponseCompression/src/Microsoft.AspNetCore.ResponseCompression.csproj
@@ -7,7 +7,7 @@
true
aspnetcore
false
- enable
+ true
diff --git a/src/Middleware/Rewrite/src/Microsoft.AspNetCore.Rewrite.csproj b/src/Middleware/Rewrite/src/Microsoft.AspNetCore.Rewrite.csproj
index f2d2f2233038..330bcf53be7a 100644
--- a/src/Middleware/Rewrite/src/Microsoft.AspNetCore.Rewrite.csproj
+++ b/src/Middleware/Rewrite/src/Microsoft.AspNetCore.Rewrite.csproj
@@ -10,7 +10,7 @@
true
aspnetcore;urlrewrite;mod_rewrite
false
- enable
+ true
diff --git a/src/Middleware/Spa/SpaProxy/src/Microsoft.AspNetCore.SpaProxy.csproj b/src/Middleware/Spa/SpaProxy/src/Microsoft.AspNetCore.SpaProxy.csproj
index 216c4401d0d3..1807fe067e83 100644
--- a/src/Middleware/Spa/SpaProxy/src/Microsoft.AspNetCore.SpaProxy.csproj
+++ b/src/Middleware/Spa/SpaProxy/src/Microsoft.AspNetCore.SpaProxy.csproj
@@ -3,7 +3,7 @@
Helpers for launching the SPA CLI proxy automatically when the application starts in ASP.NET MVC Core.
$(DefaultNetCoreTargetFramework)
- enable
+ true
diff --git a/src/Middleware/Spa/SpaServices.Extensions/src/Microsoft.AspNetCore.SpaServices.Extensions.csproj b/src/Middleware/Spa/SpaServices.Extensions/src/Microsoft.AspNetCore.SpaServices.Extensions.csproj
index 3ef37fdba9c9..0aa83bfa5563 100644
--- a/src/Middleware/Spa/SpaServices.Extensions/src/Microsoft.AspNetCore.SpaServices.Extensions.csproj
+++ b/src/Middleware/Spa/SpaServices.Extensions/src/Microsoft.AspNetCore.SpaServices.Extensions.csproj
@@ -3,7 +3,7 @@
Helpers for building single-page applications on ASP.NET MVC Core.
$(DefaultNetCoreTargetFramework)
- enable
+ true
diff --git a/src/Middleware/Spa/SpaServices.Extensions/src/Npm/NodeScriptRunner.cs b/src/Middleware/Spa/SpaServices.Extensions/src/Npm/NodeScriptRunner.cs
index 48a6a6484454..9b85944a8dc2 100644
--- a/src/Middleware/Spa/SpaServices.Extensions/src/Npm/NodeScriptRunner.cs
+++ b/src/Middleware/Spa/SpaServices.Extensions/src/Npm/NodeScriptRunner.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using System.Text.RegularExpressions;
using Microsoft.AspNetCore.NodeServices.Util;
using Microsoft.Extensions.Logging;
@@ -75,7 +76,8 @@ public NodeScriptRunner(string workingDirectory, string scriptName, string? argu
if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.NodeServices.Npm.NpmStarted"))
{
- diagnosticSource.Write(
+ WriteDiagnosticEvent(
+ diagnosticSource,
"Microsoft.AspNetCore.NodeServices.Npm.NpmStarted",
new
{
@@ -83,6 +85,11 @@ public NodeScriptRunner(string workingDirectory, string scriptName, string? argu
process = _npmProcess
});
}
+
+ [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026",
+ Justification = "The values being passed into Write have the commonly used properties being preserved with DynamicDependency.")]
+ static void WriteDiagnosticEvent(DiagnosticSource diagnosticSource, string name, TValue value)
+ => diagnosticSource.Write(name, value);
}
public void AttachToLogger(ILogger logger)
diff --git a/src/Middleware/StaticFiles/src/Microsoft.AspNetCore.StaticFiles.csproj b/src/Middleware/StaticFiles/src/Microsoft.AspNetCore.StaticFiles.csproj
index 7b36e43f674d..1b29e10b11f0 100644
--- a/src/Middleware/StaticFiles/src/Microsoft.AspNetCore.StaticFiles.csproj
+++ b/src/Middleware/StaticFiles/src/Microsoft.AspNetCore.StaticFiles.csproj
@@ -7,7 +7,7 @@
true
aspnetcore;staticfiles
false
- enable
+ true
diff --git a/src/Middleware/WebSockets/src/Microsoft.AspNetCore.WebSockets.csproj b/src/Middleware/WebSockets/src/Microsoft.AspNetCore.WebSockets.csproj
index 1443b5fae957..58c7524df4c2 100644
--- a/src/Middleware/WebSockets/src/Microsoft.AspNetCore.WebSockets.csproj
+++ b/src/Middleware/WebSockets/src/Microsoft.AspNetCore.WebSockets.csproj
@@ -8,7 +8,7 @@
true
aspnetcore
false
- enable
+ true
diff --git a/src/Shared/TrimmingAttributes.cs b/src/Shared/TrimmingAttributes.cs
index c4b5bc0c6505..30b6805a9f54 100644
--- a/src/Shared/TrimmingAttributes.cs
+++ b/src/Shared/TrimmingAttributes.cs
@@ -119,3 +119,117 @@ public UnconditionalSuppressMessageAttribute(string category, string checkId)
///
public string? Justification { get; set; }
}
+
+[AttributeUsage(
+ AttributeTargets.Field | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter |
+ AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Method |
+ AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct,
+ Inherited = false)]
+internal sealed class DynamicallyAccessedMembersAttribute : Attribute
+{
+ ///
+ /// Initializes a new instance of the class
+ /// with the specified member types.
+ ///
+ /// The types of members dynamically accessed.
+ public DynamicallyAccessedMembersAttribute(DynamicallyAccessedMemberTypes memberTypes)
+ {
+ MemberTypes = memberTypes;
+ }
+
+ ///
+ /// Gets the which specifies the type
+ /// of members dynamically accessed.
+ ///
+ public DynamicallyAccessedMemberTypes MemberTypes { get; }
+}
+
+///
+/// Specifies the types of members that are dynamically accessed.
+///
+/// This enumeration has a attribute that allows a
+/// bitwise combination of its member values.
+///
+[Flags]
+internal enum DynamicallyAccessedMemberTypes
+{
+ ///
+ /// Specifies no members.
+ ///
+ None = 0,
+
+ ///
+ /// Specifies the default, parameterless public constructor.
+ ///
+ PublicParameterlessConstructor = 0x0001,
+
+ ///
+ /// Specifies all public constructors.
+ ///
+ PublicConstructors = 0x0002 | PublicParameterlessConstructor,
+
+ ///
+ /// Specifies all non-public constructors.
+ ///
+ NonPublicConstructors = 0x0004,
+
+ ///
+ /// Specifies all public methods.
+ ///
+ PublicMethods = 0x0008,
+
+ ///
+ /// Specifies all non-public methods.
+ ///
+ NonPublicMethods = 0x0010,
+
+ ///
+ /// Specifies all public fields.
+ ///
+ PublicFields = 0x0020,
+
+ ///
+ /// Specifies all non-public fields.
+ ///
+ NonPublicFields = 0x0040,
+
+ ///
+ /// Specifies all public nested types.
+ ///
+ PublicNestedTypes = 0x0080,
+
+ ///
+ /// Specifies all non-public nested types.
+ ///
+ NonPublicNestedTypes = 0x0100,
+
+ ///
+ /// Specifies all public properties.
+ ///
+ PublicProperties = 0x0200,
+
+ ///
+ /// Specifies all non-public properties.
+ ///
+ NonPublicProperties = 0x0400,
+
+ ///
+ /// Specifies all public events.
+ ///
+ PublicEvents = 0x0800,
+
+ ///
+ /// Specifies all non-public events.
+ ///
+ NonPublicEvents = 0x1000,
+
+ ///
+ /// Specifies all interfaces implemented by the type.
+ ///
+ Interfaces = 0x2000,
+
+ ///
+ /// Specifies all members.
+ ///
+ All = ~None
+}
diff --git a/src/Tools/LinkabilityChecker/LinkabilityChecker.csproj b/src/Tools/LinkabilityChecker/LinkabilityChecker.csproj
index 2643063b73f2..394ebbfcfb6e 100644
--- a/src/Tools/LinkabilityChecker/LinkabilityChecker.csproj
+++ b/src/Tools/LinkabilityChecker/LinkabilityChecker.csproj
@@ -13,6 +13,7 @@
+
diff --git a/src/Tools/Tools.slnf b/src/Tools/Tools.slnf
index 9e1a35eff802..c90d6923b4e4 100644
--- a/src/Tools/Tools.slnf
+++ b/src/Tools/Tools.slnf
@@ -2,6 +2,7 @@
"solution": {
"path": "..\\..\\AspNetCore.sln",
"projects": [
+ "src\\Antiforgery\\src\\Microsoft.AspNetCore.Antiforgery.csproj",
"src\\Components\\Authorization\\src\\Microsoft.AspNetCore.Components.Authorization.csproj",
"src\\Components\\Components\\src\\Microsoft.AspNetCore.Components.csproj",
"src\\Components\\Forms\\src\\Microsoft.AspNetCore.Components.Forms.csproj",
@@ -23,6 +24,7 @@
"src\\Hosting\\Abstractions\\src\\Microsoft.AspNetCore.Hosting.Abstractions.csproj",
"src\\Hosting\\Hosting\\src\\Microsoft.AspNetCore.Hosting.csproj",
"src\\Hosting\\Server.Abstractions\\src\\Microsoft.AspNetCore.Hosting.Server.Abstractions.csproj",
+ "src\\Html.Abstractions\\src\\Microsoft.AspNetCore.Html.Abstractions.csproj",
"src\\Http\\Authentication.Abstractions\\src\\Microsoft.AspNetCore.Authentication.Abstractions.csproj",
"src\\Http\\Authentication.Core\\src\\Microsoft.AspNetCore.Authentication.Core.csproj",
"src\\Http\\Headers\\src\\Microsoft.Net.Http.Headers.csproj",
@@ -50,11 +52,14 @@
"src\\Middleware\\Localization.Routing\\src\\Microsoft.AspNetCore.Localization.Routing.csproj",
"src\\Middleware\\Localization\\src\\Microsoft.AspNetCore.Localization.csproj",
"src\\Middleware\\MiddlewareAnalysis\\src\\Microsoft.AspNetCore.MiddlewareAnalysis.csproj",
+ "src\\Middleware\\RateLimiting\\src\\Microsoft.AspNetCore.RateLimiting.csproj",
"src\\Middleware\\ResponseCaching.Abstractions\\src\\Microsoft.AspNetCore.ResponseCaching.Abstractions.csproj",
"src\\Middleware\\ResponseCaching\\src\\Microsoft.AspNetCore.ResponseCaching.csproj",
"src\\Middleware\\ResponseCompression\\src\\Microsoft.AspNetCore.ResponseCompression.csproj",
"src\\Middleware\\Rewrite\\src\\Microsoft.AspNetCore.Rewrite.csproj",
"src\\Middleware\\Session\\src\\Microsoft.AspNetCore.Session.csproj",
+ "src\\Middleware\\Spa\\SpaProxy\\src\\Microsoft.AspNetCore.SpaProxy.csproj",
+ "src\\Middleware\\Spa\\SpaServices.Extensions\\src\\Microsoft.AspNetCore.SpaServices.Extensions.csproj",
"src\\Middleware\\StaticFiles\\src\\Microsoft.AspNetCore.StaticFiles.csproj",
"src\\Middleware\\WebSockets\\src\\Microsoft.AspNetCore.WebSockets.csproj",
"src\\ObjectPool\\src\\Microsoft.Extensions.ObjectPool.csproj",
@@ -81,7 +86,8 @@
"src\\Tools\\dotnet-getdocument\\src\\dotnet-getdocument.csproj",
"src\\Tools\\dotnet-sql-cache\\src\\dotnet-sql-cache.csproj",
"src\\Tools\\dotnet-user-secrets\\src\\dotnet-user-secrets.csproj",
- "src\\Tools\\dotnet-user-secrets\\test\\dotnet-user-secrets.Tests.csproj"
+ "src\\Tools\\dotnet-user-secrets\\test\\dotnet-user-secrets.Tests.csproj",
+ "src\\WebEncoders\\src\\Microsoft.Extensions.WebEncoders.csproj"
]
}
}
\ No newline at end of file
diff --git a/src/WebEncoders/src/Microsoft.Extensions.WebEncoders.csproj b/src/WebEncoders/src/Microsoft.Extensions.WebEncoders.csproj
index 6f832eb8a11d..13b3a521af7f 100644
--- a/src/WebEncoders/src/Microsoft.Extensions.WebEncoders.csproj
+++ b/src/WebEncoders/src/Microsoft.Extensions.WebEncoders.csproj
@@ -7,7 +7,7 @@
true
aspnetcore
true
- enable
+ true