Skip to content

Commit

Permalink
[Core] Remove netcoreapp2.1 and net5.0 targets (#40635)
Browse files Browse the repository at this point in the history
* update targets

* Update Azure.Core.Expressions.DataFactory.csproj

* remove netcoreapp2.1 preprocessor directives

* update changelog

* Update CHANGELOG.md
  • Loading branch information
m-redding authored Dec 11, 2023
1 parent c47ab4d commit 13e4829
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 685 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
<EnableClientSdkAnalyzers>true</EnableClientSdkAnalyzers>
<EnableBannedApiAnalyzers>false</EnableBannedApiAnalyzers>
<!--
netcoreapp2.1 is out of support but we'll keep is as a target for a bit
to give customers time to migrate without losing perf optimizations
-->
<NoWarn>$(NoWarn);NETSDK1138</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions sdk/core/Azure.Core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Bugs Fixed

### Other Changes
- Remove targets for .NET Core 2.1 and .NET 5 since they are out of support. Azure.Core is no longer compatible with .NET Core 2.1 after removal of target. The remaining targets are unchanged.

## 1.36.0 (2023-11-10)

Expand Down
14 changes: 2 additions & 12 deletions sdk/core/Azure.Core/src/Azure.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>This is the implementation of the Azure Client Pipeline</Description>
<AssemblyTitle>Microsoft Azure Client Pipeline</AssemblyTitle>
Expand All @@ -8,15 +8,10 @@
<PackageTags>Microsoft Azure Client Pipeline</PackageTags>
<Nullable>enable</Nullable>
<DefineConstants>$(DefineConstants);AZURE_NULLABLE;HAS_INTERNALS_VISIBLE_CORE</DefineConstants>
<TargetFrameworks>$(RequiredTargetFrameworks);net461;net472;netcoreapp2.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>$(RequiredTargetFrameworks);net461;net472;net6.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<EnableClientSdkAnalyzers>true</EnableClientSdkAnalyzers>
<EnableBannedApiAnalyzers>false</EnableBannedApiAnalyzers>
<!--
netcoreapp2.1 is out of support but we'll keep is as a target for a bit
to give customers time to migrate without losing perf optimizations
-->
<NoWarn>$(NoWarn);NETSDK1138</NoWarn>
<ApiCompatBaselineTargetFramework Condition="'$(TargetFramework)' == 'net472'">net461</ApiCompatBaselineTargetFramework>
</PropertyGroup>

Expand All @@ -34,11 +29,6 @@
<PackageReference Include="System.Memory.Data" />
</ItemGroup>

<!-- Keep System.Diagnostics.DiagnosticSource 4.6.0 for netcoreapp2.1 support. -->
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">
<PackageReference Include="System.Diagnostics.DiagnosticSource" VersionOverride="4.6.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" />
<PackageReference Include="System.Net.Http" />
Expand Down
24 changes: 0 additions & 24 deletions sdk/core/Azure.Core/src/Pipeline/Internal/RequestActivityPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ internal class RequestActivityPolicy : HttpPipelinePolicy
private const string RequestIdHeaderName = "Request-Id";

private static readonly DiagnosticListener s_diagnosticSource = new DiagnosticListener("Azure.Core");
#if NETCOREAPP2_1
private static readonly object? s_activitySource = ActivityExtensions.CreateActivitySource("Azure.Core.Http");
#else
private static readonly ActivitySource s_activitySource = new ActivitySource("Azure.Core.Http");
#endif

public RequestActivityPolicy(bool isDistributedTracingEnabled, string? resourceProviderNamespace, HttpMessageSanitizer httpMessageSanitizer)
{
Expand Down Expand Up @@ -135,11 +131,7 @@ private async ValueTask ProcessAsync(HttpMessage message, ReadOnlyMemory<HttpPip
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026", Justification = "The values being passed into Write have the commonly used properties being preserved with DynamicallyAccessedMembers.")]
private DiagnosticScope CreateDiagnosticScope<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T>(T sourceArgs)
{
#if NETCOREAPP2_1
return new DiagnosticScope("Azure.Core.Http.Request", s_diagnosticSource, sourceArgs, s_activitySource, DiagnosticScope.ActivityKind.Client, false);
#else
return new DiagnosticScope("Azure.Core.Http.Request", s_diagnosticSource, sourceArgs, s_activitySource, System.Diagnostics.ActivityKind.Client, false);
#endif
}

private static ValueTask ProcessNextAsync(HttpMessage message, ReadOnlyMemory<HttpPipelinePolicy> pipeline, bool async)
Expand All @@ -149,20 +141,12 @@ private static ValueTask ProcessNextAsync(HttpMessage message, ReadOnlyMemory<Ht
if (currentActivity != null)
{
var currentActivityId = currentActivity.Id ?? string.Empty;
#if NETCOREAPP2_1
if (currentActivity.IsW3CFormat())
#else
if (currentActivity.IdFormat == ActivityIdFormat.W3C)
#endif
{
if (!message.Request.Headers.Contains(TraceParentHeaderName))
{
message.Request.Headers.Add(TraceParentHeaderName, currentActivityId);
#if NETCOREAPP2_1
if (currentActivity.GetTraceState() is string traceStateString)
#else
if (currentActivity.TraceStateString is string traceStateString)
#endif
{
message.Request.Headers.Add(TraceStateHeaderName, traceStateString);
}
Expand Down Expand Up @@ -190,16 +174,8 @@ private static ValueTask ProcessNextAsync(HttpMessage message, ReadOnlyMemory<Ht

private bool ShouldCreateActivity =>
_isDistributedTracingEnabled &&
#if NETCOREAPP2_1
(s_diagnosticSource.IsEnabled() || ActivityExtensions.ActivitySourceHasListeners(s_activitySource));
#else
(s_diagnosticSource.IsEnabled() || IsActivitySourceEnabled);
#endif

#if NETCOREAPP2_1
private bool IsActivitySourceEnabled => _isDistributedTracingEnabled && ActivityExtensions.ActivitySourceHasListeners(s_activitySource);
#else
private bool IsActivitySourceEnabled => _isDistributedTracingEnabled && s_activitySource.HasListeners();
#endif
}
}
Loading

0 comments on commit 13e4829

Please sign in to comment.