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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

using System.Diagnostics;
#if NET || EXPOSE_EXPERIMENTAL_FEATURES
#if EXPOSE_EXPERIMENTAL_FEATURES
using System.Diagnostics.CodeAnalysis;
#endif
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -240,15 +240,6 @@ private static ILoggingBuilder AddOpenTelemetryInternal(
// Since currently this class only contains primitive properties this is OK. The top level properties are kept
// because the first generic argument of RegisterProviderOptions below is annotated with
// DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All) so it will preserve everything on the OpenTelemetryLoggerOptions.
// But it would not work recursively into complex property values;
// This should be fully fixed with the introduction of Configuration binder source generator in .NET 8
// and then there should be a way to do this without any warnings.
// The correctness of these suppressions is verified by a test which validates that all properties of OpenTelemetryLoggerOptions
// are of a primitive type.
#if NET
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "OpenTelemetryLoggerOptions contains only primitive properties.")]
[UnconditionalSuppressMessage("AOT", "IL3050", Justification = "OpenTelemetryLoggerOptions contains only primitive properties.")]
#endif
static void RegisterLoggerProviderOptions(IServiceCollection services)
{
LoggerProviderOptions.RegisterProviderOptions<OpenTelemetryLoggerOptions, OpenTelemetryLoggerProvider>(services);
Expand Down
5 changes: 5 additions & 0 deletions src/OpenTelemetry/OpenTelemetry.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<NoWarn>$(NoWarn);CA1815</NoWarn> <!-- CA1815: Override equals and operator equals on value types - https://github.com/open-telemetry/opentelemetry-dotnet/issues/6278 -->
</PropertyGroup>

<!-- Enabled for native AoT compatibility in .NET 8+ -->
<PropertyGroup>
<EnableConfigurationBindingGenerator>true</EnableConfigurationBindingGenerator>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Diagnostics.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" />
Expand Down
Loading