Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AOT] Fix RuntimeContext warnings #4460

Closed
wants to merge 41 commits into from
Closed
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
87cfa2a
initial commit
Yun-Ting May 9, 2023
bf8a530
Merge branch 'main' into yunl/runtimeContextEnum
Yun-Ting May 9, 2023
b133982
add custom type
Yun-Ting May 11, 2023
236a5f1
CI
Yun-Ting May 12, 2023
d4c38af
update
Yun-Ting May 12, 2023
bd2d709
update
Yun-Ting May 12, 2023
db04bd1
update
Yun-Ting May 12, 2023
260327b
fix sanity check
Yun-Ting May 12, 2023
6be9d0c
format
Yun-Ting May 12, 2023
5dae942
static ctor
Yun-Ting May 15, 2023
ebee07a
added support for ReflectionRuntimeContextSlotFactory
Yun-Ting May 16, 2023
299fc2a
sanity
Yun-Ting May 16, 2023
e93903f
Merge branch 'main' into yunl/runtimeContextEnum
Yun-Ting May 16, 2023
cc00b30
test CI
Yun-Ting May 16, 2023
99c8baa
Revert "test CI"
Yun-Ting May 17, 2023
a773917
CI
Yun-Ting May 17, 2023
fc32b25
update
Yun-Ting May 17, 2023
6ef81cd
Merge branch 'yunl/runtimeContextEnum' of https://github.com/Yun-Ting…
Yun-Ting May 17, 2023
23b77b5
comment
Yun-Ting May 17, 2023
6faf599
update
Yun-Ting May 17, 2023
e6b016c
ci
Yun-Ting May 17, 2023
44bb210
CI
Yun-Ting May 18, 2023
8d76270
preprossesor
Yun-Ting May 18, 2023
05bb4b6
fix build
Yun-Ting May 18, 2023
8586200
Add the trimming attributes to only OpenTelemetry.Api, and use #if to…
eerhardt May 18, 2023
452f6a6
CI
Yun-Ting May 18, 2023
649e39d
Adjust the folder path to the attributes.
eerhardt May 18, 2023
f0c7f44
CI
Yun-Ting May 18, 2023
f8714f9
Fix nullable warning in LoggerProviderSdk
eerhardt May 18, 2023
7956ab1
CI
Yun-Ting May 18, 2023
d2024a8
address comments
Yun-Ting May 19, 2023
b9c0b33
sanity check
Yun-Ting May 19, 2023
4120ffb
fix test
Yun-Ting May 19, 2023
633da1b
indentation
Yun-Ting May 19, 2023
7c1fde4
increased timeout and removed RS0026
Yun-Ting May 19, 2023
48d0b7f
RS0026
Yun-Ting May 19, 2023
19fce6a
CI
Yun-Ting May 19, 2023
35173c8
Fix ApiCompat for OpenTelemetry.Api's net6.0 target.
eerhardt May 22, 2023
21495bc
CI
Yun-Ting May 22, 2023
586511d
Merge branch 'main' into yunl/runtimeContextEnum
eerhardt May 22, 2023
9ba6626
fixed merge; scope down suppresion of RS0026
Yun-Ting May 24, 2023
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
4 changes: 2 additions & 2 deletions docs/logs/correlation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ corresponding `Activity`.

The good news is that, in OpenTelemetry .NET SDK, there is no user action
required to enable correlation. i.e the SDK automatically enables logs to
`Activity` correlation, by populating the fields `TraceId`, `SpanId` and
`TraceFlags` from the active activity (i.e `Activity.Current`), if
`Activity` correlation, by populating the fields `TraceId`, `SpanId`,
`TraceFlags`, `TraceState` from the active activity (i.e `Activity.Current`), if
Yun-Ting marked this conversation as resolved.
Show resolved Hide resolved
any.

The example [Program.cs](./Program.cs) shows how to emit logs within the context
Expand Down
Empty file.
220 changes: 220 additions & 0 deletions src/OpenTelemetry.Api/.publicApi/net6.0/PublicAPI.Unshipped.txt

Large diffs are not rendered by default.

64 changes: 60 additions & 4 deletions src/OpenTelemetry.Api/Context/RuntimeContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// </copyright>

using System.Collections.Concurrent;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using OpenTelemetry.Internal;

Expand All @@ -27,10 +28,66 @@ public static class RuntimeContext
{
private static readonly ConcurrentDictionary<string, object> Slots = new();

private static Type contextSlotType;

private static RuntimeContextSlotFactory runtimeContextSlotFactory;

[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The AsyncLocalRuntimeContextSlot type is handled without using Reflection.")]
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL3050:RequiresDynamicCode", Justification = "The AsyncLocalRuntimeContextSlot type is handled without using Reflection.")]
static RuntimeContext()
{
ContextSlotType = typeof(AsyncLocalRuntimeContextSlot<>);
}

/// <summary>
/// Gets or sets the actual context carrier implementation.
/// </summary>
public static Type ContextSlotType { get; set; } = typeof(AsyncLocalRuntimeContextSlot<>);
public static Type ContextSlotType
{
get
{
return contextSlotType;
}

[RequiresUnreferencedCode("Setting a custom ContextSlotType requires using Reflection to initialize the context slot.")]
[RequiresDynamicCode("Setting a custom ContextSlotType requires using MakeGenericType to initialize the context slot. The native code for the generic type might not be available at runtime.")]
set
{
Guard.ThrowIfNull(value, nameof(value));
if (!value.IsGenericType || !value.IsGenericTypeDefinition || value.GetGenericArguments().Length != 1)
{
throw new NotSupportedException($"Type '{value}' must be generic with a single generic type argument.");
}

if (value == typeof(AsyncLocalRuntimeContextSlot<>))
{
runtimeContextSlotFactory = new RuntimeContextSlotFactory.AsyncLocalRuntimeContextSlotFactory();
}
else if (value == typeof(ThreadLocalRuntimeContextSlot<>))
{
runtimeContextSlotFactory = new RuntimeContextSlotFactory.ThreadLocalRuntimeContextSlotFactory();
}
#if NETFRAMEWORK
else if (value == typeof(RemotingRuntimeContextSlot<>))
{
runtimeContextSlotFactory = new RuntimeContextSlotFactory.RemotingRuntimeContextSlotFactory();
}
#endif
else
{
#if NETSTANDARD2_1_OR_GREATER || NET6_OR_GREATER
if (!RuntimeFeature.IsDynamicCodeSupported)
{
throw new NotSupportedException($"Custom RuntimeContextSlot type '{value}' cannot be used because dynamic code is not supported");
}
#endif

runtimeContextSlotFactory = new RuntimeContextSlotFactory.ReflectionRuntimeContextSlotFactory(contextSlotType);
}

contextSlotType = value;
}
}

/// <summary>
/// Register a named context slot.
Expand All @@ -49,9 +106,8 @@ public static RuntimeContextSlot<T> RegisterSlot<T>(string slotName)
throw new InvalidOperationException($"Context slot already registered: '{slotName}'");
}

var type = ContextSlotType.MakeGenericType(typeof(T));
var ctor = type.GetConstructor(new Type[] { typeof(string) });
var slot = (RuntimeContextSlot<T>)ctor.Invoke(new object[] { slotName });
var slot = runtimeContextSlotFactory.Create<T>(slotName);
utpilla marked this conversation as resolved.
Show resolved Hide resolved
utpilla marked this conversation as resolved.
Show resolved Hide resolved

Slots[slotName] = slot;
return slot;
}
Expand Down
66 changes: 66 additions & 0 deletions src/OpenTelemetry.Api/Context/RuntimeContextSlotFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// <copyright file="RuntimeContextSlotFactory.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

#nullable enable

using System.Diagnostics.CodeAnalysis;

namespace OpenTelemetry.Context
{
internal abstract class RuntimeContextSlotFactory
{
public abstract RuntimeContextSlot<T> Create<T>(string name);

public sealed class AsyncLocalRuntimeContextSlotFactory : RuntimeContextSlotFactory
{
public override RuntimeContextSlot<T> Create<T>(string name)
=> new AsyncLocalRuntimeContextSlot<T>(name);
}

#if NETFRAMEWORK
public sealed class RemotingRuntimeContextSlotFactory : RuntimeContextSlotFactory
{
public override RuntimeContextSlot<T> Create<T>(string name)
=> new RemotingRuntimeContextSlot<T>(name);
}
#endif

public sealed class ThreadLocalRuntimeContextSlotFactory : RuntimeContextSlotFactory
{
public override RuntimeContextSlot<T> Create<T>(string name)
=> new ThreadLocalRuntimeContextSlot<T>(name);
}

[RequiresUnreferencedCode("ReflectionRuntimeContextSlotFactory is trimmer unsafe.")]
[RequiresDynamicCode("ReflectionRuntimeContextSlotFactory requires the ability to generate new code at runtime.")]
public sealed class ReflectionRuntimeContextSlotFactory : RuntimeContextSlotFactory
{
private readonly Type runtimeContextSlotType;

public ReflectionRuntimeContextSlotFactory(Type runtimeContextSlotType)
{
this.runtimeContextSlotType = runtimeContextSlotType;
}

public override RuntimeContextSlot<T> Create<T>(string name)
{
var type = this.runtimeContextSlotType.MakeGenericType(typeof(T));
var ctor = type.GetConstructor(new Type[] { typeof(string) })!;
return (RuntimeContextSlot<T>)ctor.Invoke(new object[] { name })!;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// <copyright file="RequiresDynamicCodeAttribute.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

#nullable enable
#if !NET7_0_OR_GREATER
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need a net7.0 target for this to work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This attribute is in the runtime of .net7.0 and .net8.0: https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.codeanalysis.requiresdynamiccodeattribute?view=net-7.0

Therefore, we will only need to compile this file if it is not net7.0 or greater.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's basically future proofing the code. That way if/when we add a net7.0+ target, this code doesn't get compiled for it. Yes it isn't strictly necessary now, but it is saving some effort/confusion for a future dev who adds a new TFM.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kind of forces us to always add the new target to the API project as well. If in the future, the SDK project also ends up using this attribute, we wouldn't be able to add a net7.0+ target only to the SDK project as it would complain about the attribute existing in both OpenTelemetry.Api (because of InternalsVisible) and System.Runtime.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a recommendation to resolve this? The only other option I could imagine is to #if NET7_OR_GREATER where we need to use this attribute AND add a net7.0 target now in order to use the attribute.

This kind of forces us to always add the new target to the API project as well

Using InternalsVisibleTo across separate NuGet packages isn't recommended, since the package versions can get out of sync and users will see errors.

In general, matching TFMs across these packages is preferrable. It makes maintenance much easier. It is how we manage our packages we ship out of dotnet/runtime. They all have a consistent set of targets. For the 8.0-* packages it is: net6.0;net7.0;net8.0;netstandard2.0;net462. For example see https://www.nuget.org/packages/System.Collections.Immutable/8.0.0-preview.4.23259.5#dependencies-body-tab:

image

namespace System.Diagnostics.CodeAnalysis
{
/// <summary>
/// Indicates that the specified method requires the ability to generate new code at runtime,
/// for example through <see cref="Reflection"/>.
/// </summary>
/// <remarks>
/// This allows tools to understand which methods are unsafe to call when compiling ahead of time.
/// </remarks>
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Class, Inherited = false)]
internal sealed class RequiresDynamicCodeAttribute : Attribute
{
/// <summary>
/// Initializes a new instance of the <see cref="RequiresDynamicCodeAttribute"/> class
/// with the specified message.
/// </summary>
/// <param name="message">
/// A message that contains information about the usage of dynamic code.
/// </param>
public RequiresDynamicCodeAttribute(string message)
{
this.Message = message;
}

/// <summary>
/// Gets a message that contains information about the usage of dynamic code.
/// </summary>
public string Message { get; }

/// <summary>
/// Gets or sets an optional URL that contains more information about the method,
/// why it requires dynamic code, and what options a consumer has to deal with it.
/// </summary>
public string? Url { get; set; }
}
}
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// <copyright file="RequiresUnreferencedCodeAttribute.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

#nullable enable
#if NETFRAMEWORK || NETSTANDARD2_0_OR_GREATER
namespace System.Diagnostics.CodeAnalysis
alanwest marked this conversation as resolved.
Show resolved Hide resolved
{
/// <summary>
/// Indicates that the specified method requires dynamic access to code that is not referenced
/// statically, for example through <see cref="Reflection"/>.
/// </summary>
/// <remarks>
/// This allows tools to understand which methods are unsafe to call when removing unreferenced
/// code from an application.
/// </remarks>
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Class, Inherited = false)]
internal sealed class RequiresUnreferencedCodeAttribute : Attribute
{
/// <summary>
/// Initializes a new instance of the <see cref="RequiresUnreferencedCodeAttribute"/> class
/// with the specified message.
/// </summary>
/// <param name="message">
/// A message that contains information about the usage of unreferenced code.
/// </param>
public RequiresUnreferencedCodeAttribute(string message)
{
this.Message = message;
}

/// <summary>
/// Gets a message that contains information about the usage of unreferenced code.
/// </summary>
public string Message { get; }

/// <summary>
/// Gets or sets an optional URL that contains more information about the method,
/// why it requires unreferenced code, and what options a consumer has to deal with it.
/// </summary>
public string? Url { get; set; }
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License.
// </copyright>
#nullable enable

#if NETFRAMEWORK || NETSTANDARD2_0_OR_GREATER
namespace System.Diagnostics.CodeAnalysis
{
/// <summary>
Expand Down Expand Up @@ -97,3 +97,4 @@ public UnconditionalSuppressMessageAttribute(string category, string checkId)
public string? Justification { get; set; }
}
}
#endif
15 changes: 13 additions & 2 deletions src/OpenTelemetry.Api/OpenTelemetry.Api.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
<TargetFrameworks>net6.0;netstandard2.0;net462</TargetFrameworks>
<Description>OpenTelemetry .NET API</Description>
<RootNamespace>OpenTelemetry</RootNamespace>

<NoWarn>$(NoWarn),CS0618</NoWarn>
<NoWarn>$(NoWarn),CS0618,RS0026</NoWarn>
<MinVerTagPrefix>core-</MinVerTagPrefix>

<!-- this is temporary. will remove in future PR. -->
Expand All @@ -15,4 +15,15 @@
<ItemGroup>
<PackageReference Include="System.Diagnostics.DiagnosticSource" />
</ItemGroup>

<!--
v1.4.0 doesn't contain a net6.0 target, so we can't run ApiCompat against it.
Instead, run net6.0's ApiCompat check against netstandard2.0.
Remove this once 1.5.0 is released.
-->
<ItemGroup Condition="'$(CheckAPICompatibility)' == 'true' and '$(TargetFramework)' == 'net6.0'">
<ResolvedMatchingContract Remove="$(RepoRoot)\build\LastMajorVersionBinaries\$(AssemblyName)\$(OTelPreviousStableVer)\lib\$(TargetFramework)\$(AssemblyName).dll" />
<ResolvedMatchingContract Include="$(RepoRoot)\build\LastMajorVersionBinaries\$(AssemblyName)\$(OTelPreviousStableVer)\lib\netstandard2.0\$(AssemblyName).dll" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Api\Internal\ExceptionExtensions.cs" Link="Includes\ExceptionExtensions.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Api\Internal\Guard.cs" Link="Includes\Guard.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Api\Internal\SpanAttributeConstants.cs" Link="Includes\SpanAttributeConstants.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Internal\Shims\UnconditionalSuppressMessageAttribute.cs" Link="Includes\UnconditionalSuppressMessageAttribute.cs" Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Api\Internal\Shims\UnconditionalSuppressMessageAttribute.cs" Link="Includes\UnconditionalSuppressMessageAttribute.cs" Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Internal\PeerServiceResolver.cs" Link="Includes\PeerServiceResolver.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Internal\ResourceSemanticConventions.cs" Link="Includes\ResourceSemanticConventions.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Internal\TagTransformer.cs" Link="Includes\TagTransformer.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Internal\Shims\UnconditionalSuppressMessageAttribute.cs" Link ="Includes\UnconditionalSuppressMessageAttribute.cs" Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Api\Internal\Shims\UnconditionalSuppressMessageAttribute.cs" Link ="Includes\UnconditionalSuppressMessageAttribute.cs" Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Threading.Tasks.Extensions" Condition="'$(TargetFramework)' != 'netstandard2.1'" />
<PackageReference Include="System.Text.Encodings.Web" Condition="'$(TargetFramework)' != 'net6.0'" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Internal\ResourceSemanticConventions.cs" Link="Includes\ResourceSemanticConventions.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Internal\TagTransformer.cs" Link="Includes\TagTransformer.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Internal\TagAndValueTransformer.cs" Link="Includes\TagAndValueTransformer.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Internal\Shims\UnconditionalSuppressMessageAttribute.cs" Link ="Includes\UnconditionalSuppressMessageAttribute.cs" Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Api\Internal\Shims\UnconditionalSuppressMessageAttribute.cs" Link ="Includes\UnconditionalSuppressMessageAttribute.cs" Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Internal\PeerServiceResolver.cs" Link="Includes\PeerServiceResolver.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Internal\ResourceSemanticConventions.cs" Link="Includes\ResourceSemanticConventions.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Internal\TagTransformer.cs" Link="Includes\TagTransformer.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Internal\Shims\UnconditionalSuppressMessageAttribute.cs" Link ="Includes\UnconditionalSuppressMessageAttribute.cs" Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Api\Internal\Shims\UnconditionalSuppressMessageAttribute.cs" Link ="Includes\UnconditionalSuppressMessageAttribute.cs" Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 9 additions & 1 deletion src/OpenTelemetry/Logs/LoggerProviderSdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
#nullable enable

using System.Diagnostics;
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
using System.Diagnostics.CodeAnalysis;
#endif
using System.Text;
using Microsoft.Extensions.DependencyInjection;
using OpenTelemetry.Internal;
Expand Down Expand Up @@ -201,7 +204,12 @@ public bool ContainsBatchProcessor(BaseProcessor<LogRecord> processor)
}

/// <inheritdoc />
protected override bool TryCreateLogger(string? name, out Logger? logger)
protected override bool TryCreateLogger(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string? name,
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
[NotNullWhen(true)]
#endif
out Logger? logger)
{
logger = new LoggerSdk(this, name);
return true;
Expand Down
4 changes: 0 additions & 4 deletions src/OpenTelemetry/OpenTelemetry.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,4 @@
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Api.ProviderBuilderExtensions\OpenTelemetry.Api.ProviderBuilderExtensions.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Remove="Internal\Shims\UnconditionalSuppressMessageAttribute.cs" Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'" />
</ItemGroup>

</Project>
Loading