diff --git a/Directory.Build.props b/Directory.Build.props
index 24c1bb96cae..cea28e22ade 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -90,12 +90,6 @@
$(MicrosoftCodeAnalysisCSharpVersion)
-
-
-
-
-
-
diff --git a/src/Libraries/Directory.Build.props b/src/Libraries/Directory.Build.props
index 518a00ad5b8..5dabc150a2c 100644
--- a/src/Libraries/Directory.Build.props
+++ b/src/Libraries/Directory.Build.props
@@ -4,6 +4,7 @@
$(NetCoreTargetFrameworks)$(ConditionalNet462)
true
+ true
true
true
diff --git a/src/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware/Latency/RequestLatencyTelemetryServiceCollectionExtensions.cs b/src/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware/Latency/RequestLatencyTelemetryServiceCollectionExtensions.cs
index a6b7876fb8e..db2c76df323 100644
--- a/src/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware/Latency/RequestLatencyTelemetryServiceCollectionExtensions.cs
+++ b/src/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware/Latency/RequestLatencyTelemetryServiceCollectionExtensions.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
-using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Diagnostics.Latency;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
@@ -64,11 +63,6 @@ public static IServiceCollection AddRequestLatencyTelemetry(this IServiceCollect
/// Configuration of .
/// The value of .
/// Either or is .
- [DynamicDependency(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicParameterlessConstructor, type: typeof(RequestLatencyTelemetryOptions))]
- [UnconditionalSuppressMessage(
- "Trimming",
- "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code",
- Justification = "Addressed with [DynamicDependency]")]
public static IServiceCollection AddRequestLatencyTelemetry(this IServiceCollection services, IConfigurationSection section)
=> Throw.IfNull(services)
.Configure(Throw.IfNull(section))
diff --git a/src/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware/Logging/HttpLoggingServiceCollectionExtensions.cs b/src/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware/Logging/HttpLoggingServiceCollectionExtensions.cs
index a8c6da4bd75..7de962db012 100644
--- a/src/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware/Logging/HttpLoggingServiceCollectionExtensions.cs
+++ b/src/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware/Logging/HttpLoggingServiceCollectionExtensions.cs
@@ -60,7 +60,7 @@ public static IServiceCollection AddHttpLoggingRedaction(this IServiceCollection
{
_ = Throw.IfNull(section);
- return services.AddHttpLoggingRedaction(section.Bind);
+ return services.AddHttpLoggingRedaction(o => section.Bind(o));
}
///
diff --git a/src/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware/Microsoft.AspNetCore.Diagnostics.Middleware.csproj b/src/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware/Microsoft.AspNetCore.Diagnostics.Middleware.csproj
index 89262b07f64..654e36f481f 100644
--- a/src/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware/Microsoft.AspNetCore.Diagnostics.Middleware.csproj
+++ b/src/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware/Microsoft.AspNetCore.Diagnostics.Middleware.csproj
@@ -8,6 +8,7 @@
$(NetCoreTargetFrameworks)
+ true
true
false
false
@@ -38,6 +39,7 @@
+
diff --git a/src/Libraries/Microsoft.AspNetCore.HeaderParsing/Microsoft.AspNetCore.HeaderParsing.csproj b/src/Libraries/Microsoft.AspNetCore.HeaderParsing/Microsoft.AspNetCore.HeaderParsing.csproj
index 1a37baabfdf..70cf5f0290f 100644
--- a/src/Libraries/Microsoft.AspNetCore.HeaderParsing/Microsoft.AspNetCore.HeaderParsing.csproj
+++ b/src/Libraries/Microsoft.AspNetCore.HeaderParsing/Microsoft.AspNetCore.HeaderParsing.csproj
@@ -8,6 +8,8 @@
$(NetCoreTargetFrameworks)
+
+ false
true
true
true
diff --git a/src/Libraries/Microsoft.Extensions.AmbientMetadata.Application/ApplicationMetadataHostBuilderExtensions.cs b/src/Libraries/Microsoft.Extensions.AmbientMetadata.Application/ApplicationMetadataHostBuilderExtensions.cs
index 9ad46f152cb..e2635bbcc4d 100644
--- a/src/Libraries/Microsoft.Extensions.AmbientMetadata.Application/ApplicationMetadataHostBuilderExtensions.cs
+++ b/src/Libraries/Microsoft.Extensions.AmbientMetadata.Application/ApplicationMetadataHostBuilderExtensions.cs
@@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
-using System.Diagnostics.CodeAnalysis;
-using Microsoft.Extensions.AmbientMetadata;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Shared.Diagnostics;
@@ -25,11 +23,6 @@ public static class ApplicationMetadataHostBuilderExtensions
/// The value of .
/// is .
/// is either , empty, or whitespace.
- [DynamicDependency(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicParameterlessConstructor, typeof(ApplicationMetadata))]
- [UnconditionalSuppressMessage(
- "Trimming",
- "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code",
- Justification = "Addressed with [DynamicDependency]")]
public static IHostBuilder UseApplicationMetadata(this IHostBuilder builder, string sectionName = DefaultSectionName)
{
_ = Throw.IfNull(builder);
diff --git a/src/Libraries/Microsoft.Extensions.AmbientMetadata.Application/ApplicationMetadataServiceCollectionExtensions.cs b/src/Libraries/Microsoft.Extensions.AmbientMetadata.Application/ApplicationMetadataServiceCollectionExtensions.cs
index 3734d8686f4..bc08c2a60e9 100644
--- a/src/Libraries/Microsoft.Extensions.AmbientMetadata.Application/ApplicationMetadataServiceCollectionExtensions.cs
+++ b/src/Libraries/Microsoft.Extensions.AmbientMetadata.Application/ApplicationMetadataServiceCollectionExtensions.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
-using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.AmbientMetadata;
using Microsoft.Extensions.Configuration;
using Microsoft.Shared.Diagnostics;
@@ -21,11 +20,6 @@ public static class ApplicationMetadataServiceCollectionExtensions
/// The configuration section to bind.
/// The value of .
/// or is .
- [DynamicDependency(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicParameterlessConstructor, typeof(ApplicationMetadata))]
- [UnconditionalSuppressMessage(
- "Trimming",
- "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code",
- Justification = "Addressed with [DynamicDependency]")]
public static IServiceCollection AddApplicationMetadata(this IServiceCollection services, IConfigurationSection section)
{
_ = Throw.IfNull(services);
diff --git a/src/Libraries/Microsoft.Extensions.AmbientMetadata.Application/Microsoft.Extensions.AmbientMetadata.Application.csproj b/src/Libraries/Microsoft.Extensions.AmbientMetadata.Application/Microsoft.Extensions.AmbientMetadata.Application.csproj
index 615c7ec6e14..5cc014f22ca 100644
--- a/src/Libraries/Microsoft.Extensions.AmbientMetadata.Application/Microsoft.Extensions.AmbientMetadata.Application.csproj
+++ b/src/Libraries/Microsoft.Extensions.AmbientMetadata.Application/Microsoft.Extensions.AmbientMetadata.Application.csproj
@@ -5,6 +5,10 @@
Fundamentals
+
+ true
+
+
normal
100
@@ -15,6 +19,7 @@
+
diff --git a/src/Libraries/Microsoft.Extensions.Compliance.Redaction/Microsoft.Extensions.Compliance.Redaction.csproj b/src/Libraries/Microsoft.Extensions.Compliance.Redaction/Microsoft.Extensions.Compliance.Redaction.csproj
index 9f9f4149ca1..286a14ca69e 100644
--- a/src/Libraries/Microsoft.Extensions.Compliance.Redaction/Microsoft.Extensions.Compliance.Redaction.csproj
+++ b/src/Libraries/Microsoft.Extensions.Compliance.Redaction/Microsoft.Extensions.Compliance.Redaction.csproj
@@ -7,6 +7,7 @@
true
+ true
true
true
true
@@ -25,6 +26,7 @@
+
diff --git a/src/Libraries/Microsoft.Extensions.Compliance.Redaction/RedactionExtensions.cs b/src/Libraries/Microsoft.Extensions.Compliance.Redaction/RedactionExtensions.cs
index 191d8af6f55..577cd0e8d7a 100644
--- a/src/Libraries/Microsoft.Extensions.Compliance.Redaction/RedactionExtensions.cs
+++ b/src/Libraries/Microsoft.Extensions.Compliance.Redaction/RedactionExtensions.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
-using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Compliance.Classification;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@@ -45,11 +44,6 @@ public static IRedactionBuilder SetHmacRedactor(this IRedactionBuilder builder,
/// The data classifications for which the redactor type should be used.
/// The value of .
/// , , or is .
- [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(HmacRedactorOptions))]
- [UnconditionalSuppressMessage(
- "Trimming",
- "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code",
- Justification = "Addressed with [DynamicDependency]")]
public static IRedactionBuilder SetHmacRedactor(this IRedactionBuilder builder, IConfigurationSection section, params DataClassificationSet[] classifications)
{
_ = Throw.IfNull(builder);
diff --git a/src/Libraries/Microsoft.Extensions.Compliance.Testing/FakeRedactionBuilderExtensions.cs b/src/Libraries/Microsoft.Extensions.Compliance.Testing/FakeRedactionBuilderExtensions.cs
index a954985c881..4c6314ec811 100644
--- a/src/Libraries/Microsoft.Extensions.Compliance.Testing/FakeRedactionBuilderExtensions.cs
+++ b/src/Libraries/Microsoft.Extensions.Compliance.Testing/FakeRedactionBuilderExtensions.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
-using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Compliance.Classification;
using Microsoft.Extensions.Compliance.Redaction;
using Microsoft.Extensions.Compliance.Testing;
@@ -65,9 +64,6 @@ public static IRedactionBuilder SetFakeRedactor(this IRedactionBuilder builder,
/// The data classifications for which the redactor type should be used.
/// The value of .
/// or is .
- [UnconditionalSuppressMessage("Trimming",
- "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code",
- Justification = "The type is FakeRedactorOptions and we know it.")]
public static IRedactionBuilder SetFakeRedactor(this IRedactionBuilder builder, IConfigurationSection section, params DataClassificationSet[] classifications)
{
_ = Throw.IfNull(builder);
diff --git a/src/Libraries/Microsoft.Extensions.Compliance.Testing/Microsoft.Extensions.Compliance.Testing.csproj b/src/Libraries/Microsoft.Extensions.Compliance.Testing/Microsoft.Extensions.Compliance.Testing.csproj
index 1883b86af55..0da536c5c51 100644
--- a/src/Libraries/Microsoft.Extensions.Compliance.Testing/Microsoft.Extensions.Compliance.Testing.csproj
+++ b/src/Libraries/Microsoft.Extensions.Compliance.Testing/Microsoft.Extensions.Compliance.Testing.csproj
@@ -7,6 +7,7 @@
+ true
true
true
true
@@ -24,6 +25,7 @@
+
diff --git a/src/Libraries/Microsoft.Extensions.DependencyInjection.AutoActivation/AutoActivationExtensions.Keyed.cs b/src/Libraries/Microsoft.Extensions.DependencyInjection.AutoActivation/AutoActivationExtensions.Keyed.cs
index 03a9f17810c..88a4d5d10e4 100644
--- a/src/Libraries/Microsoft.Extensions.DependencyInjection.AutoActivation/AutoActivationExtensions.Keyed.cs
+++ b/src/Libraries/Microsoft.Extensions.DependencyInjection.AutoActivation/AutoActivationExtensions.Keyed.cs
@@ -55,13 +55,9 @@ public static IServiceCollection ActivateKeyedSingleton(
/// The type of the service to activate.
/// An object used to uniquely identify the specific service.
/// The value of .
- [UnconditionalSuppressMessage(
- "Trimming",
- "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code",
- Justification = "Addressed with [DynamicallyAccessedMembers]")]
public static IServiceCollection ActivateKeyedSingleton(
this IServiceCollection services,
- [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type serviceType,
+ Type serviceType,
object? serviceKey)
{
_ = Throw.IfNull(services);
@@ -72,7 +68,7 @@ public static IServiceCollection ActivateKeyedSingleton(
.AddOptions()
.Configure(ao =>
{
- var constructed = typeof(IEnumerable<>).MakeGenericType(serviceType);
+ var constructed = GetEnumerableServiceType(serviceType);
if (ao.KeyedAutoActivators.Contains((constructed, serviceKey)))
{
return;
@@ -85,6 +81,10 @@ public static IServiceCollection ActivateKeyedSingleton(
}
_ = ao.KeyedAutoActivators.Add((serviceType, serviceKey));
+
+ [UnconditionalSuppressMessage("AotAnalysis", "IL3050:RequiresDynamicCode",
+ Justification = "When IsDynamicCodeSupported is not supported, DependencyInjection ensures IEnumerable service types are not a ValueType.")]
+ static Type GetEnumerableServiceType(Type serviceType) => typeof(IEnumerable<>).MakeGenericType(serviceType);
});
return services;
diff --git a/src/Libraries/Microsoft.Extensions.DependencyInjection.AutoActivation/AutoActivationExtensions.cs b/src/Libraries/Microsoft.Extensions.DependencyInjection.AutoActivation/AutoActivationExtensions.cs
index 136a704ecfd..7b9c5c8a450 100644
--- a/src/Libraries/Microsoft.Extensions.DependencyInjection.AutoActivation/AutoActivationExtensions.cs
+++ b/src/Libraries/Microsoft.Extensions.DependencyInjection.AutoActivation/AutoActivationExtensions.cs
@@ -55,11 +55,7 @@ public static IServiceCollection ActivateSingleton(this IServiceCollec
/// The service collection containing the service.
/// The type of the service to activate.
/// The value of .
- [UnconditionalSuppressMessage(
- "Trimming",
- "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code",
- Justification = "Addressed with [DynamicallyAccessedMembers]")]
- public static IServiceCollection ActivateSingleton(this IServiceCollection services, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type serviceType)
+ public static IServiceCollection ActivateSingleton(this IServiceCollection services, Type serviceType)
{
_ = Throw.IfNull(services);
_ = Throw.IfNull(serviceType);
@@ -69,7 +65,7 @@ public static IServiceCollection ActivateSingleton(this IServiceCollection servi
.AddOptions()
.Configure(ao =>
{
- var constructed = typeof(IEnumerable<>).MakeGenericType(serviceType);
+ var constructed = GetEnumerableServiceType(serviceType);
if (ao.AutoActivators.Contains(constructed))
{
return;
@@ -82,6 +78,10 @@ public static IServiceCollection ActivateSingleton(this IServiceCollection servi
}
_ = ao.AutoActivators.Add(serviceType);
+
+ [UnconditionalSuppressMessage("AotAnalysis", "IL3050:RequiresDynamicCode",
+ Justification = "When IsDynamicCodeSupported is not supported, DependencyInjection ensures IEnumerable service types are not a ValueType.")]
+ static Type GetEnumerableServiceType(Type serviceType) => typeof(IEnumerable<>).MakeGenericType(serviceType);
});
return services;
diff --git a/src/Libraries/Microsoft.Extensions.Diagnostics.ExceptionSummarization/HttpExceptionSummaryProvider.cs b/src/Libraries/Microsoft.Extensions.Diagnostics.ExceptionSummarization/HttpExceptionSummaryProvider.cs
index fa31f2f2b5d..c6cd436a15d 100644
--- a/src/Libraries/Microsoft.Extensions.Diagnostics.ExceptionSummarization/HttpExceptionSummaryProvider.cs
+++ b/src/Libraries/Microsoft.Extensions.Diagnostics.ExceptionSummarization/HttpExceptionSummaryProvider.cs
@@ -35,9 +35,14 @@ static HttpExceptionSummaryProvider()
};
var socketErrors = new Dictionary();
+#if NET5_0_OR_GREATER
+ foreach (var socketError in Enum.GetValues())
+ {
+#else
foreach (var v in Enum.GetValues(typeof(SocketError)))
{
var socketError = (SocketError)v!;
+#endif
var name = socketError.ToString();
socketErrors[socketError] = descriptions.Count;
@@ -45,9 +50,14 @@ static HttpExceptionSummaryProvider()
}
var webStatuses = new Dictionary();
+#if NET5_0_OR_GREATER
+ foreach (var status in Enum.GetValues())
+ {
+#else
foreach (var v in Enum.GetValues(typeof(WebExceptionStatus)))
{
var status = (WebExceptionStatus)v!;
+#endif
var name = status.ToString();
webStatuses[status] = descriptions.Count;
diff --git a/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.Common/Microsoft.Extensions.Diagnostics.HealthChecks.Common.csproj b/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.Common/Microsoft.Extensions.Diagnostics.HealthChecks.Common.csproj
index 9d98141bfae..9109e0df176 100644
--- a/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.Common/Microsoft.Extensions.Diagnostics.HealthChecks.Common.csproj
+++ b/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.Common/Microsoft.Extensions.Diagnostics.HealthChecks.Common.csproj
@@ -1,4 +1,4 @@
-
+
Microsoft.Extensions.Diagnostics.HealthChecks
Health check implementations.
@@ -6,6 +6,7 @@
+ true
true
true
true
@@ -22,6 +23,7 @@
+
diff --git a/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.csproj b/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.csproj
index dd73a1da586..183f4b21f41 100644
--- a/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.csproj
+++ b/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.csproj
@@ -6,6 +6,7 @@
+ true
true
true
@@ -21,6 +22,7 @@
+
diff --git a/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization/ResourceUtilizationHealthCheckExtensions.cs b/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization/ResourceUtilizationHealthCheckExtensions.cs
index e3b6c086605..ee5d466e0a3 100644
--- a/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization/ResourceUtilizationHealthCheckExtensions.cs
+++ b/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization/ResourceUtilizationHealthCheckExtensions.cs
@@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Shared.Diagnostics;
@@ -56,11 +55,6 @@ public static IHealthChecksBuilder AddResourceUtilizationHealthCheck(this IHealt
/// Configuration for .
/// The value of .
/// or is .
- [DynamicDependency(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicParameterlessConstructor, typeof(ResourceUtilizationHealthCheckOptions))]
- [UnconditionalSuppressMessage(
- "Trimming",
- "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code",
- Justification = "Addressed by [DynamicDependency]")]
public static IHealthChecksBuilder AddResourceUtilizationHealthCheck(
this IHealthChecksBuilder builder,
IConfigurationSection section)
@@ -80,11 +74,6 @@ public static IHealthChecksBuilder AddResourceUtilizationHealthCheck(
/// A list of tags that can be used to filter health checks.
/// The value of .
/// , or is .
- [DynamicDependency(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicParameterlessConstructor, typeof(ResourceUtilizationHealthCheckOptions))]
- [UnconditionalSuppressMessage(
- "Trimming",
- "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code",
- Justification = "Addressed by [DynamicDependency]")]
public static IHealthChecksBuilder AddResourceUtilizationHealthCheck(
this IHealthChecksBuilder builder,
IConfigurationSection section,
@@ -106,11 +95,6 @@ public static IHealthChecksBuilder AddResourceUtilizationHealthCheck(
/// A list of tags that can be used to filter health checks.
/// The value of .
/// , or is .
- [DynamicDependency(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicParameterlessConstructor, typeof(ResourceUtilizationHealthCheckOptions))]
- [UnconditionalSuppressMessage(
- "Trimming",
- "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code",
- Justification = "Addressed by [DynamicDependency]")]
public static IHealthChecksBuilder AddResourceUtilizationHealthCheck(
this IHealthChecksBuilder builder,
IConfigurationSection section,
diff --git a/src/Libraries/Microsoft.Extensions.Diagnostics.Probes/KubernetesProbesExtensions.cs b/src/Libraries/Microsoft.Extensions.Diagnostics.Probes/KubernetesProbesExtensions.cs
index 3663cef85d3..f4f60965655 100644
--- a/src/Libraries/Microsoft.Extensions.Diagnostics.Probes/KubernetesProbesExtensions.cs
+++ b/src/Libraries/Microsoft.Extensions.Diagnostics.Probes/KubernetesProbesExtensions.cs
@@ -33,7 +33,7 @@ public static IServiceCollection AddKubernetesProbes(this IServiceCollection ser
_ = Throw.IfNull(services);
_ = Throw.IfNull(section);
- return services.AddKubernetesProbes(section.Bind);
+ return services.AddKubernetesProbes(o => section.Bind(o));
}
///
diff --git a/src/Libraries/Microsoft.Extensions.Diagnostics.Probes/Microsoft.Extensions.Diagnostics.Probes.csproj b/src/Libraries/Microsoft.Extensions.Diagnostics.Probes/Microsoft.Extensions.Diagnostics.Probes.csproj
index 529a9c73fa2..b83ecbbd0fc 100644
--- a/src/Libraries/Microsoft.Extensions.Diagnostics.Probes/Microsoft.Extensions.Diagnostics.Probes.csproj
+++ b/src/Libraries/Microsoft.Extensions.Diagnostics.Probes/Microsoft.Extensions.Diagnostics.Probes.csproj
@@ -6,6 +6,7 @@
+ true
true
true
true
@@ -23,6 +24,7 @@
+
diff --git a/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Microsoft.Extensions.Diagnostics.ResourceMonitoring.csproj b/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Microsoft.Extensions.Diagnostics.ResourceMonitoring.csproj
index e9ed2cd0e49..cbc5caad60a 100644
--- a/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Microsoft.Extensions.Diagnostics.ResourceMonitoring.csproj
+++ b/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Microsoft.Extensions.Diagnostics.ResourceMonitoring.csproj
@@ -7,6 +7,7 @@
true
+ true
true
true
true
@@ -32,6 +33,7 @@
+
diff --git a/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/ResourceMonitoringBuilderExtensions.cs b/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/ResourceMonitoringBuilderExtensions.cs
index ca52cf38c74..43c926cdc81 100644
--- a/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/ResourceMonitoringBuilderExtensions.cs
+++ b/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/ResourceMonitoringBuilderExtensions.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
-using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
@@ -39,10 +38,6 @@ public static IResourceMonitorBuilder ConfigureMonitor(
/// The to use for configuring .
/// The value of .
/// Either or is .
- [UnconditionalSuppressMessage(
- "Trimming",
- "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code",
- Justification = "Addressed with [DynamicDependency]")]
public static IResourceMonitorBuilder ConfigureMonitor(
this IResourceMonitorBuilder builder,
IConfigurationSection section)
diff --git a/src/Libraries/Microsoft.Extensions.Diagnostics.Testing/Logging/FakeLoggerBuilderExtensions.cs b/src/Libraries/Microsoft.Extensions.Diagnostics.Testing/Logging/FakeLoggerBuilderExtensions.cs
index 2701205a496..00f05887aba 100644
--- a/src/Libraries/Microsoft.Extensions.Diagnostics.Testing/Logging/FakeLoggerBuilderExtensions.cs
+++ b/src/Libraries/Microsoft.Extensions.Diagnostics.Testing/Logging/FakeLoggerBuilderExtensions.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
-using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
@@ -23,11 +22,6 @@ public static class FakeLoggerBuilderExtensions
/// Logging builder.
/// Configuration section that contains .
/// Logging .
- [DynamicDependency(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicParameterlessConstructor, typeof(FakeLogCollectorOptions))]
- [UnconditionalSuppressMessage(
- "Trimming",
- "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code",
- Justification = "Addressed by [DynamicDependency]")]
public static ILoggingBuilder AddFakeLogging(this ILoggingBuilder builder, IConfigurationSection section)
{
_ = Throw.IfNull(builder);
diff --git a/src/Libraries/Microsoft.Extensions.Diagnostics.Testing/Microsoft.Extensions.Diagnostics.Testing.csproj b/src/Libraries/Microsoft.Extensions.Diagnostics.Testing/Microsoft.Extensions.Diagnostics.Testing.csproj
index 9ffe5557c0c..5bd030df5e9 100644
--- a/src/Libraries/Microsoft.Extensions.Diagnostics.Testing/Microsoft.Extensions.Diagnostics.Testing.csproj
+++ b/src/Libraries/Microsoft.Extensions.Diagnostics.Testing/Microsoft.Extensions.Diagnostics.Testing.csproj
@@ -7,9 +7,11 @@
+ true
true
true
true
+ $(NoWarn);SYSLIB1100;SYSLIB1101
@@ -23,6 +25,7 @@
+
diff --git a/src/Libraries/Microsoft.Extensions.Http.Diagnostics/Latency/HttpClientLatencyTelemetryExtensions.cs b/src/Libraries/Microsoft.Extensions.Http.Diagnostics/Latency/HttpClientLatencyTelemetryExtensions.cs
index b682de95b21..309f24e1f2d 100644
--- a/src/Libraries/Microsoft.Extensions.Http.Diagnostics/Latency/HttpClientLatencyTelemetryExtensions.cs
+++ b/src/Libraries/Microsoft.Extensions.Http.Diagnostics/Latency/HttpClientLatencyTelemetryExtensions.cs
@@ -2,13 +2,11 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
-using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Http;
using Microsoft.Extensions.Http.Latency;
using Microsoft.Extensions.Http.Latency.Internal;
-using Microsoft.Extensions.Http.Logging;
using Microsoft.Shared.Diagnostics;
namespace Microsoft.Extensions.DependencyInjection;
@@ -58,10 +56,6 @@ public static IServiceCollection AddHttpClientLatencyTelemetry(this IServiceColl
/// The .
/// The to use for configuring .
/// The value of .
- [DynamicDependency(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicParameterlessConstructor, typeof(LoggingOptions))]
- [UnconditionalSuppressMessage("Trimming",
- "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code",
- Justification = "Addressed with [DynamicDependency]")]
public static IServiceCollection AddHttpClientLatencyTelemetry(this IServiceCollection services, IConfigurationSection section)
{
_ = Throw.IfNull(section);
diff --git a/src/Libraries/Microsoft.Extensions.Http.Diagnostics/Logging/HttpClientLoggingHttpClientBuilderExtensions.cs b/src/Libraries/Microsoft.Extensions.Http.Diagnostics/Logging/HttpClientLoggingHttpClientBuilderExtensions.cs
index b867a767c68..24258bab36f 100644
--- a/src/Libraries/Microsoft.Extensions.Http.Diagnostics/Logging/HttpClientLoggingHttpClientBuilderExtensions.cs
+++ b/src/Libraries/Microsoft.Extensions.Http.Diagnostics/Logging/HttpClientLoggingHttpClientBuilderExtensions.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
-using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection.Extensions;
@@ -50,10 +49,6 @@ public static IHttpClientBuilder AddExtendedHttpClientLogging(this IHttpClientBu
/// you have a way of viewing structured logs in order to view this extra information.
///
/// Any of the arguments is .
- [DynamicDependency(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicParameterlessConstructor, typeof(LoggingOptions))]
- [UnconditionalSuppressMessage("Trimming",
- "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code",
- Justification = "Addressed with [DynamicDependency]")]
public static IHttpClientBuilder AddExtendedHttpClientLogging(this IHttpClientBuilder builder, IConfigurationSection section)
{
_ = Throw.IfNull(builder);
@@ -74,10 +69,6 @@ public static IHttpClientBuilder AddExtendedHttpClientLogging(this IHttpClientBu
/// you have a way of viewing structured logs in order to view this extra information.
///
/// Any of the arguments is .
- [DynamicDependency(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicParameterlessConstructor, typeof(LoggingOptions))]
- [UnconditionalSuppressMessage("Trimming",
- "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code",
- Justification = "Addressed with [DynamicDependency]")]
public static IHttpClientBuilder AddExtendedHttpClientLogging(this IHttpClientBuilder builder, Action configure)
{
_ = Throw.IfNull(builder);
diff --git a/src/Libraries/Microsoft.Extensions.Http.Diagnostics/Logging/HttpClientLoggingServiceCollectionExtensions.cs b/src/Libraries/Microsoft.Extensions.Http.Diagnostics/Logging/HttpClientLoggingServiceCollectionExtensions.cs
index e6e39b1b54b..748cdad5366 100644
--- a/src/Libraries/Microsoft.Extensions.Http.Diagnostics/Logging/HttpClientLoggingServiceCollectionExtensions.cs
+++ b/src/Libraries/Microsoft.Extensions.Http.Diagnostics/Logging/HttpClientLoggingServiceCollectionExtensions.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
-using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection.Extensions;
@@ -58,10 +57,6 @@ public static IServiceCollection AddExtendedHttpClientLogging(this IServiceColle
/// All other loggers are removed - including the default one, registered via .
///
/// Any of the arguments is .
- [DynamicDependency(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicParameterlessConstructor, typeof(LoggingOptions))]
- [UnconditionalSuppressMessage("Trimming",
- "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code",
- Justification = "Addressed with [DynamicDependency]")]
public static IServiceCollection AddExtendedHttpClientLogging(this IServiceCollection services, IConfigurationSection section)
{
_ = Throw.IfNull(services);
diff --git a/src/Libraries/Microsoft.Extensions.Http.Diagnostics/Microsoft.Extensions.Http.Diagnostics.csproj b/src/Libraries/Microsoft.Extensions.Http.Diagnostics/Microsoft.Extensions.Http.Diagnostics.csproj
index 0ecc1a45bc3..223a370cd57 100644
--- a/src/Libraries/Microsoft.Extensions.Http.Diagnostics/Microsoft.Extensions.Http.Diagnostics.csproj
+++ b/src/Libraries/Microsoft.Extensions.Http.Diagnostics/Microsoft.Extensions.Http.Diagnostics.csproj
@@ -9,6 +9,7 @@
$(NoWarn);LA0006
+ true
true
true
false
@@ -37,6 +38,7 @@
+
diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/Hedging/StandardHedgingHandlerBuilderExtensions.cs b/src/Libraries/Microsoft.Extensions.Http.Resilience/Hedging/StandardHedgingHandlerBuilderExtensions.cs
index 65edeb046fc..7e2b87c7315 100644
--- a/src/Libraries/Microsoft.Extensions.Http.Resilience/Hedging/StandardHedgingHandlerBuilderExtensions.cs
+++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/Hedging/StandardHedgingHandlerBuilderExtensions.cs
@@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
-using System.Diagnostics.CodeAnalysis;
+using System.Linq;
using System.Net.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@@ -25,13 +25,16 @@ public static class StandardHedgingHandlerBuilderExtensions
/// The pipeline builder.
/// The section that the options will bind against.
/// The value of .
- [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(HttpStandardHedgingResilienceOptions))]
public static IStandardHedgingHandlerBuilder Configure(this IStandardHedgingHandlerBuilder builder, IConfigurationSection section)
{
_ = Throw.IfNull(builder);
_ = Throw.IfNull(section);
- var options = Throw.IfNull(section.Get());
+ if (!section.GetChildren().Any())
+ {
+ Throw.ArgumentException(nameof(section), "Configuration section cannot be empty.");
+ }
+
_ = builder.Services.Configure(builder.Name, section, o => o.ErrorOnUnknownConfiguration = true);
return builder;
diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/Microsoft.Extensions.Http.Resilience.csproj b/src/Libraries/Microsoft.Extensions.Http.Resilience/Microsoft.Extensions.Http.Resilience.csproj
index ac92ad2d833..7bf27efddb3 100644
--- a/src/Libraries/Microsoft.Extensions.Http.Resilience/Microsoft.Extensions.Http.Resilience.csproj
+++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/Microsoft.Extensions.Http.Resilience.csproj
@@ -6,6 +6,7 @@
+ true
true
true
true
@@ -29,6 +30,10 @@
+
+
+
+
diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/Resilience/HttpStandardResiliencePipelineBuilderExtensions.cs b/src/Libraries/Microsoft.Extensions.Http.Resilience/Resilience/HttpStandardResiliencePipelineBuilderExtensions.cs
index d853e38ba20..e17e975f44b 100644
--- a/src/Libraries/Microsoft.Extensions.Http.Resilience/Resilience/HttpStandardResiliencePipelineBuilderExtensions.cs
+++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/Resilience/HttpStandardResiliencePipelineBuilderExtensions.cs
@@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
-using System.Diagnostics.CodeAnalysis;
+using System.Linq;
using System.Net.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@@ -22,12 +22,15 @@ public static class HttpStandardResiliencePipelineBuilderExtensions
/// The pipeline builder.
/// The section that the options will bind against.
/// The value of .
- [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(HttpStandardResilienceOptions))]
public static IHttpStandardResiliencePipelineBuilder Configure(this IHttpStandardResiliencePipelineBuilder builder, IConfigurationSection section)
{
_ = Throw.IfNull(builder);
_ = Throw.IfNull(section);
- var options = Throw.IfNull(section.Get());
+
+ if (!section.GetChildren().Any())
+ {
+ Throw.ArgumentException(nameof(section), "Configuration section cannot be empty.");
+ }
_ = builder.Services.Configure(
builder.PipelineName,
diff --git a/src/Libraries/Microsoft.Extensions.ObjectPool.DependencyInjection/ObjectPoolServiceCollectionExtensions.cs b/src/Libraries/Microsoft.Extensions.ObjectPool.DependencyInjection/ObjectPoolServiceCollectionExtensions.cs
index 25132dd1618..749b9578311 100644
--- a/src/Libraries/Microsoft.Extensions.ObjectPool.DependencyInjection/ObjectPoolServiceCollectionExtensions.cs
+++ b/src/Libraries/Microsoft.Extensions.ObjectPool.DependencyInjection/ObjectPoolServiceCollectionExtensions.cs
@@ -78,11 +78,6 @@ public static IServiceCollection ConfigurePool(this IServiceCollection
/// The to add to.
/// The configuration section to bind.
/// The value of .
- [DynamicDependency(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicParameterlessConstructor, typeof(DependencyInjectionPoolOptions))]
- [UnconditionalSuppressMessage(
- "Trimming",
- "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code",
- Justification = "Addressed by [DynamicDependency]")]
public static IServiceCollection ConfigurePools(this IServiceCollection services, IConfigurationSection section)
{
foreach (var child in Throw.IfNull(section).GetChildren())
diff --git a/src/Libraries/Microsoft.Extensions.Telemetry/Enrichment/ApplicationEnricherServiceCollectionExtensions.cs b/src/Libraries/Microsoft.Extensions.Telemetry/Enrichment/ApplicationEnricherServiceCollectionExtensions.cs
index dac5be34bf1..75bb01c4a8b 100644
--- a/src/Libraries/Microsoft.Extensions.Telemetry/Enrichment/ApplicationEnricherServiceCollectionExtensions.cs
+++ b/src/Libraries/Microsoft.Extensions.Telemetry/Enrichment/ApplicationEnricherServiceCollectionExtensions.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
-using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Diagnostics.Enrichment;
using Microsoft.Shared.Diagnostics;
@@ -62,11 +61,6 @@ public static IServiceCollection AddServiceLogEnricher(this IServiceCollection s
.AddLogEnricherOptions(_ => { }, section);
}
- [DynamicDependency(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicParameterlessConstructor, typeof(ApplicationLogEnricherOptions))]
- [UnconditionalSuppressMessage(
- "Trimming",
- "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code",
- Justification = "Addressed by [DynamicDependency]")]
private static IServiceCollection AddLogEnricherOptions(
this IServiceCollection services,
Action configure,
diff --git a/src/Libraries/Microsoft.Extensions.Telemetry/Enrichment/ProcessEnricherServiceCollectionExtensions.cs b/src/Libraries/Microsoft.Extensions.Telemetry/Enrichment/ProcessEnricherServiceCollectionExtensions.cs
index 51d235a05af..bb987eb90bb 100644
--- a/src/Libraries/Microsoft.Extensions.Telemetry/Enrichment/ProcessEnricherServiceCollectionExtensions.cs
+++ b/src/Libraries/Microsoft.Extensions.Telemetry/Enrichment/ProcessEnricherServiceCollectionExtensions.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
-using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Diagnostics.Enrichment;
using Microsoft.Shared.Diagnostics;
@@ -64,11 +63,6 @@ public static IServiceCollection AddProcessLogEnricher(this IServiceCollection s
.AddLogEnricherOptions(_ => { }, section);
}
- [DynamicDependency(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicParameterlessConstructor, typeof(ProcessLogEnricherOptions))]
- [UnconditionalSuppressMessage(
- "Trimming",
- "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code",
- Justification = "Addressed by [DynamicDependency]")]
private static IServiceCollection AddLogEnricherOptions(
this IServiceCollection services,
Action configure,
diff --git a/src/Libraries/Microsoft.Extensions.Telemetry/Latency/LatencyConsoleExtensions.cs b/src/Libraries/Microsoft.Extensions.Telemetry/Latency/LatencyConsoleExtensions.cs
index ba69f80ed0b..aea4a79bbcf 100644
--- a/src/Libraries/Microsoft.Extensions.Telemetry/Latency/LatencyConsoleExtensions.cs
+++ b/src/Libraries/Microsoft.Extensions.Telemetry/Latency/LatencyConsoleExtensions.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
-using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Diagnostics.Latency;
@@ -56,11 +55,6 @@ public static IServiceCollection AddConsoleLatencyDataExporter(this IServiceColl
/// Configuration of .
/// The value of .
/// Either or is .
- [DynamicDependency(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicParameterlessConstructor, typeof(LatencyConsoleOptions))]
- [UnconditionalSuppressMessage(
- "Trimming",
- "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code",
- Justification = "Addressed by [DynamicDependency]")]
public static IServiceCollection AddConsoleLatencyDataExporter(this IServiceCollection services, IConfigurationSection section)
{
_ = Throw.IfNull(services);
diff --git a/src/Libraries/Microsoft.Extensions.Telemetry/Latency/LatencyContextExtensions.cs b/src/Libraries/Microsoft.Extensions.Telemetry/Latency/LatencyContextExtensions.cs
index 749b5298229..5840da785d2 100644
--- a/src/Libraries/Microsoft.Extensions.Telemetry/Latency/LatencyContextExtensions.cs
+++ b/src/Libraries/Microsoft.Extensions.Telemetry/Latency/LatencyContextExtensions.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
-using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Diagnostics.Latency;
@@ -54,11 +53,6 @@ public static IServiceCollection AddLatencyContext(this IServiceCollection servi
/// The dependency injection container.
/// The configuration of .
/// The value of .
- [DynamicDependency(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicParameterlessConstructor, typeof(LatencyContextOptions))]
- [UnconditionalSuppressMessage(
- "Trimming",
- "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code",
- Justification = "Addressed by [DynamicDependency]")]
public static IServiceCollection AddLatencyContext(this IServiceCollection services, IConfigurationSection section)
{
_ = Throw.IfNull(services);
diff --git a/src/Libraries/Microsoft.Extensions.Telemetry/Microsoft.Extensions.Telemetry.csproj b/src/Libraries/Microsoft.Extensions.Telemetry/Microsoft.Extensions.Telemetry.csproj
index 21e6baea697..95bb8c20fb2 100644
--- a/src/Libraries/Microsoft.Extensions.Telemetry/Microsoft.Extensions.Telemetry.csproj
+++ b/src/Libraries/Microsoft.Extensions.Telemetry/Microsoft.Extensions.Telemetry.csproj
@@ -14,6 +14,7 @@
true
true
true
+ true
true
@@ -31,6 +32,7 @@
+
diff --git a/test/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware.Tests/Logging/HttpLoggingServiceExtensionsTests.cs b/test/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware.Tests/Logging/HttpLoggingServiceExtensionsTests.cs
index 4f9eb15ca78..e480cefb1ed 100644
--- a/test/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware.Tests/Logging/HttpLoggingServiceExtensionsTests.cs
+++ b/test/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware.Tests/Logging/HttpLoggingServiceExtensionsTests.cs
@@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
+using Microsoft.Extensions.Compliance.Classification;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Http.Diagnostics;
@@ -50,5 +51,43 @@ public void AddHttpLogging_WhenConfiguredUsingConfigurationSection_IsCorrect()
Assert.Contains("/path0toexclude", options.ExcludePathStartsWith);
Assert.Contains("/path1toexclude", options.ExcludePathStartsWith);
}
+
+ [Fact]
+ public void AddHttpLogging_CanConfigureDataClasses()
+ {
+ var services = new ServiceCollection();
+ services.AddHttpLoggingRedaction(o =>
+ {
+ o.RouteParameterDataClasses = new Dictionary
+ {
+ { "one", new DataClassification("Taxonomy1", "Value1") },
+ };
+
+ o.RequestHeadersDataClasses = new Dictionary
+ {
+ { "two", new DataClassification("Taxonomy2", "Value2") },
+ };
+
+ o.ResponseHeadersDataClasses = new Dictionary
+ {
+ { "three", new DataClassification("Taxonomy3", "Value3") },
+ };
+ });
+
+ using var provider = services.BuildServiceProvider();
+ var options = provider.GetRequiredService>().Value;
+
+ Assert.Single(options.RouteParameterDataClasses);
+ Assert.Equal("Taxonomy1", options.RouteParameterDataClasses["one"].TaxonomyName);
+ Assert.Equal("Value1", options.RouteParameterDataClasses["one"].Value);
+
+ Assert.Single(options.RequestHeadersDataClasses);
+ Assert.Equal("Taxonomy2", options.RequestHeadersDataClasses["two"].TaxonomyName);
+ Assert.Equal("Value2", options.RequestHeadersDataClasses["two"].Value);
+
+ Assert.Single(options.ResponseHeadersDataClasses);
+ Assert.Equal("Taxonomy3", options.ResponseHeadersDataClasses["three"].TaxonomyName);
+ Assert.Equal("Value3", options.ResponseHeadersDataClasses["three"].Value);
+ }
}
#endif
diff --git a/test/Libraries/Microsoft.Extensions.Http.Resilience.Tests/Hedging/StandardHedgingTests.cs b/test/Libraries/Microsoft.Extensions.Http.Resilience.Tests/Hedging/StandardHedgingTests.cs
index cd53c4d00e2..7ded224a2e4 100644
--- a/test/Libraries/Microsoft.Extensions.Http.Resilience.Tests/Hedging/StandardHedgingTests.cs
+++ b/test/Libraries/Microsoft.Extensions.Http.Resilience.Tests/Hedging/StandardHedgingTests.cs
@@ -147,7 +147,7 @@ public void Configure_EmptyConfigurationSectionContent_ShouldThrow()
{ "dummy", "" }
}).GetSection("dummy");
- Assert.Throws(() =>
+ Assert.Throws(() =>
Builder.Configure(section));
}
@@ -156,7 +156,7 @@ public void Configure_EmptyConfigurationSection_ShouldThrow()
{
var section = ConfigurationStubFactory.CreateEmpty().GetSection(string.Empty);
- Assert.Throws(() =>
+ Assert.Throws(() =>
Builder.Configure(section));
}
diff --git a/test/Libraries/Microsoft.Extensions.Http.Resilience.Tests/Resilience/HttpClientBuilderExtensionsTests.Standard.cs b/test/Libraries/Microsoft.Extensions.Http.Resilience.Tests/Resilience/HttpClientBuilderExtensionsTests.Standard.cs
index 0ca8b521c40..567cceb6466 100644
--- a/test/Libraries/Microsoft.Extensions.Http.Resilience.Tests/Resilience/HttpClientBuilderExtensionsTests.Standard.cs
+++ b/test/Libraries/Microsoft.Extensions.Http.Resilience.Tests/Resilience/HttpClientBuilderExtensionsTests.Standard.cs
@@ -117,7 +117,7 @@ public void AddStandardResilienceHandler_NullConfigurationSectionContent_Throws(
{
var builder = new ServiceCollection().AddHttpClient("test");
- Assert.Throws(() => AddStandardResilienceHandler(mode, builder, _emptyConfigurationSection, options => { }));
+ Assert.Throws(() => AddStandardResilienceHandler(mode, builder, _emptyConfigurationSection, options => { }));
}
[InlineData(MethodArgs.Configuration)]