Skip to content

Commit c32fea3

Browse files
authored
[repo] Simplify preprocessor directives after dropping support for .NET 6 (open-telemetry#2180)
1 parent 71ca622 commit c32fea3

File tree

16 files changed

+36
-38
lines changed

16 files changed

+36
-38
lines changed

src/OpenTelemetry.Exporter.OneCollector/Internal/Transports/TransportSendRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal readonly struct TransportSendRequest
1313
{
1414
public TransportSendRequest()
1515
{
16-
#if !NET8_0_OR_GREATER
16+
#if !NET
1717
// Note: This is needed because < NET7 doesn't understand required.
1818
this.ItemType = string.Empty;
1919
this.ItemStream = default!;

src/OpenTelemetry.Exporter.OneCollector/OneCollectorExporterValidationException.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright The OpenTelemetry Authors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
#if !NET8_0_OR_GREATER
4+
#if !NET
55
using System.Runtime.Serialization;
66
#endif
77

@@ -43,7 +43,7 @@ public OneCollectorExporterValidationException(string message, Exception? innerE
4343
{
4444
}
4545

46-
#if !NET8_0_OR_GREATER
46+
#if !NET
4747
private OneCollectorExporterValidationException(SerializationInfo serializationInfo, StreamingContext streamingContext)
4848
: base(serializationInfo, streamingContext)
4949
{

src/OpenTelemetry.Extensions.AWS/AWSXRayIdGenerator.net6.cs renamed to src/OpenTelemetry.Extensions.AWS/AWSXRayIdGenerator.net.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright The OpenTelemetry Authors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
#if NET6_0_OR_GREATER
4+
#if NET
55
using System.Buffers.Binary;
66
using System.Diagnostics;
77
using System.Security.Cryptography;

src/OpenTelemetry.Instrumentation.AspNetCore/AspNetCoreInstrumentationMeterProviderBuilderExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright The OpenTelemetry Authors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
#if !NET8_0_OR_GREATER
4+
#if !NET
55
using OpenTelemetry.Instrumentation.AspNetCore;
66
using OpenTelemetry.Instrumentation.AspNetCore.Implementation;
77
#endif
@@ -24,7 +24,7 @@ public static MeterProviderBuilder AddAspNetCoreInstrumentation(
2424
{
2525
Guard.ThrowIfNull(builder);
2626

27-
#if NET8_0_OR_GREATER
27+
#if NET
2828
return builder.ConfigureMeters();
2929
#else
3030
// Note: Warm-up the status code and method mapping.

src/OpenTelemetry.Instrumentation.AspNetCore/AspNetCoreMetrics.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright The OpenTelemetry Authors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
#if !NET8_0_OR_GREATER
4+
#if !NET
55
using OpenTelemetry.Instrumentation.AspNetCore.Implementation;
66

77
namespace OpenTelemetry.Instrumentation.AspNetCore;

src/OpenTelemetry.Instrumentation.ConfluentKafka/OpenTelemetryConsumerBuilderExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static class OpenTelemetryConsumerBuilderExtensions
1717
/// <typeparam name="TValue">Type of the value.</typeparam>
1818
/// <param name="consumerBuilder">The <see cref="ConsumerBuilder{TKey, TValue}"/> instance.</param>
1919
/// <returns>An <see cref="InstrumentedConsumerBuilder{TKey, TValue}"/> instance.</returns>
20-
#if !NETFRAMEWORK && !NETSTANDARD
20+
#if NET
2121
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Use 'InstrumentedConsumerBuilder<TKey, TValue>' constructor to avoid reflection.")]
2222
#endif
2323
public static InstrumentedConsumerBuilder<TKey, TValue> AsInstrumentedConsumerBuilder<TKey, TValue>(this ConsumerBuilder<TKey, TValue> consumerBuilder)

src/OpenTelemetry.Instrumentation.ConfluentKafka/OpenTelemetryProducerBuilderExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static class OpenTelemetryProducerBuilderExtensions
1717
/// <typeparam name="TValue">Type of the value.</typeparam>
1818
/// <param name="producerBuilder">The <see cref="ProducerBuilder{TKey, TValue}"/> instance.</param>
1919
/// <returns>An <see cref="InstrumentedProducerBuilder{TKey, TValue}"/> instance.</returns>
20-
#if !NETFRAMEWORK && !NETSTANDARD
20+
#if NET
2121
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Use 'InstrumentedProducerBuilder<TKey, TValue>' constructor to avoid reflection.")]
2222
#endif
2323
public static InstrumentedProducerBuilder<TKey, TValue> AsInstrumentedProducerBuilder<TKey, TValue>(this ProducerBuilder<TKey, TValue> producerBuilder)

src/OpenTelemetry.Instrumentation.Http/HttpClientInstrumentationMeterProviderBuilderExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright The OpenTelemetry Authors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
#if !NET8_0_OR_GREATER
4+
#if !NET
55
#if !NETFRAMEWORK
66
using OpenTelemetry.Instrumentation.Http;
77
#endif
@@ -27,7 +27,7 @@ public static MeterProviderBuilder AddHttpClientInstrumentation(
2727
{
2828
Guard.ThrowIfNull(builder);
2929

30-
#if NET8_0_OR_GREATER
30+
#if NET
3131
return builder
3232
.AddMeter("System.Net.Http")
3333
.AddMeter("System.Net.NameResolution");

src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ static bool TryFetchException(object? payload, [NotNullWhen(true)] out Exception
310310

311311
private static string? GetErrorType(Exception exc)
312312
{
313-
#if NET8_0_OR_GREATER
313+
#if NET
314314
// For net8.0 and above exception type can be found using HttpRequestError.
315315
// https://learn.microsoft.com/dotnet/api/system.net.http.httprequesterror?view=net-8.0
316316
if (exc is HttpRequestException httpRequestException)

src/Shared/Configuration/OpenTelemetryConfigurationExtensions.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#nullable enable
55

66
using System.Diagnostics;
7-
#if !NETFRAMEWORK && !NETSTANDARD2_0
7+
#if NET || NETSTANDARD2_1
88
using System.Diagnostics.CodeAnalysis;
99
#endif
1010
using System.Globalization;
@@ -15,15 +15,15 @@ internal static class OpenTelemetryConfigurationExtensions
1515
{
1616
public delegate bool TryParseFunc<T>(
1717
string value,
18-
#if !NETFRAMEWORK && !NETSTANDARD2_0
18+
#if NET || NETSTANDARD2_1
1919
[NotNullWhen(true)]
2020
#endif
2121
out T? parsedValue);
2222

2323
public static bool TryGetStringValue(
2424
this IConfiguration configuration,
2525
string key,
26-
#if !NETFRAMEWORK && !NETSTANDARD2_0
26+
#if NET || NETSTANDARD2_1
2727
[NotNullWhen(true)]
2828
#endif
2929
out string? value)
@@ -39,7 +39,7 @@ public static bool TryGetUriValue(
3939
this IConfiguration configuration,
4040
IConfigurationExtensionsLogger logger,
4141
string key,
42-
#if !NETFRAMEWORK && !NETSTANDARD2_0
42+
#if NET || NETSTANDARD2_1
4343
[NotNullWhen(true)]
4444
#endif
4545
out Uri? value)
@@ -112,7 +112,7 @@ public static bool TryGetValue<T>(
112112
IConfigurationExtensionsLogger logger,
113113
string key,
114114
TryParseFunc<T> tryParseFunc,
115-
#if !NETFRAMEWORK && !NETSTANDARD2_0
115+
#if NET || NETSTANDARD2_1
116116
[NotNullWhen(true)]
117117
#endif
118118
out T? value)

0 commit comments

Comments
 (0)