Skip to content

Commit 7f91d74

Browse files
authored
[Resources.Host] Replace .NET 6 target with .NET 8 and add .NET Standard 2.0 target (open-telemetry#2168)
1 parent 9400d5c commit 7f91d74

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

src/OpenTelemetry.Resources.Host/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
* Drop support for .NET 6 as this target is no longer supported
6+
and add .NET 8/.NET Standard 2.0 targets.
7+
([#2168](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/2168))
8+
59
## 0.1.0-beta.3
610

711
Released 2024-Aug-30

src/OpenTelemetry.Resources.Host/HostDetector.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
using System.Diagnostics;
5-
#if NET
5+
#if !NETFRAMEWORK
66
using System.Runtime.InteropServices;
77
#endif
88
using System.Text;
@@ -18,7 +18,7 @@ internal sealed class HostDetector : IResourceDetector
1818
{
1919
private const string ETCMACHINEID = "/etc/machine-id";
2020
private const string ETCVARDBUSMACHINEID = "/var/lib/dbus/machine-id";
21-
#if NET
21+
#if !NETFRAMEWORK
2222
private readonly Func<OSPlatform, bool> isOsPlatform;
2323
#endif
2424
private readonly Func<IEnumerable<string>> getFilePaths;
@@ -30,7 +30,7 @@ internal sealed class HostDetector : IResourceDetector
3030
/// </summary>
3131
public HostDetector()
3232
: this(
33-
#if NET
33+
#if !NETFRAMEWORK
3434
RuntimeInformation.IsOSPlatform,
3535
#endif
3636
GetFilePaths,
@@ -39,7 +39,7 @@ public HostDetector()
3939
{
4040
}
4141

42-
#if NET
42+
#if !NETFRAMEWORK
4343
public HostDetector(
4444
Func<IEnumerable<string>> getFilePaths,
4545
Func<string?> getMacOsMachineId,
@@ -54,21 +54,21 @@ public HostDetector(
5454
#endif
5555

5656
internal HostDetector(
57-
#if NET
57+
#if !NETFRAMEWORK
5858
Func<OSPlatform, bool> isOsPlatform,
5959
#endif
6060
Func<IEnumerable<string>> getFilePaths,
6161
Func<string?> getMacOsMachineId,
6262
Func<string?> getWindowsMachineId)
6363
{
64-
#if NET
64+
#if !NETFRAMEWORK
6565
Guard.ThrowIfNull(isOsPlatform);
6666
#endif
6767
Guard.ThrowIfNull(getFilePaths);
6868
Guard.ThrowIfNull(getMacOsMachineId);
6969
Guard.ThrowIfNull(getWindowsMachineId);
7070

71-
#if NET
71+
#if !NETFRAMEWORK
7272
this.isOsPlatform = isOsPlatform;
7373
#endif
7474
this.getFilePaths = getFilePaths;
@@ -117,10 +117,10 @@ public Resource Detect()
117117

118118
foreach (var line in lines)
119119
{
120-
#if NETFRAMEWORK
121-
if (line.IndexOf("IOPlatformUUID", StringComparison.OrdinalIgnoreCase) >= 0)
122-
#else
120+
#if NET
123121
if (line.Contains("IOPlatformUUID", StringComparison.OrdinalIgnoreCase))
122+
#else
123+
if (line.IndexOf("IOPlatformUUID", StringComparison.OrdinalIgnoreCase) >= 0)
124124
#endif
125125
{
126126
var parts = line.Split('"');
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
23
<PropertyGroup>
34
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
4-
<TargetFrameworks>net6.0</TargetFrameworks>
5+
<TargetFrameworks>net8.0;$(NetStandardMinimumSupportedVersion)</TargetFrameworks>
56
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);$(NetFrameworkMinimumSupportedVersion)</TargetFrameworks>
6-
<Description>OpenTelemetry Extensions - Host Resource Detector.</Description>
7+
<Description>OpenTelemetry Resource Detectors for Host.</Description>
78
<MinVerTagPrefix>Resources.Host-</MinVerTagPrefix>
89
</PropertyGroup>
910

10-
<!--Do not run Package Baseline Validation as this package has never released a stable version.
11-
Remove this property once we have released a stable version and add PackageValidationBaselineVersion property.-->
11+
<!-- Do not run Package Baseline Validation as this package has never released a stable version.
12+
Remove this property once we have released a stable version and add PackageValidationBaselineVersion property. -->
1213
<PropertyGroup>
1314
<DisablePackageBaselineValidation>true</DisablePackageBaselineValidation>
1415
</PropertyGroup>
1516

1617
<ItemGroup>
1718
<PackageReference Include="OpenTelemetry" Version="$(OpenTelemetryCoreLatestVersion)" />
19+
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" Condition="'$(TargetFrameworkIdentifier)' == '.NETStandard'" />
1820
</ItemGroup>
1921

2022
<ItemGroup>
2123
<Compile Include="$(RepoRoot)\src\Shared\Guard.cs" Link="Includes\Guard.cs" />
2224
<Compile Include="$(RepoRoot)\src\Shared\ExceptionExtensions.cs" Link="Includes\ExceptionExtensions.cs" />
2325
</ItemGroup>
26+
2427
</Project>

test/OpenTelemetry.Resources.Host.Tests/OpenTelemetry.Resources.Host.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<Description>Unit test project for Host Detector for OpenTelemetry</Description>
54
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
6-
<TargetFrameworks>$(SupportedNetTargets)</TargetFrameworks>
5+
<TargetFrameworks>$(SupportedNetTargetsWithoutNet6)</TargetFrameworks>
76
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);$(NetFrameworkMinimumSupportedVersion)</TargetFrameworks>
7+
<Description>Unit test project for Host Detector for OpenTelemetry.</Description>
88
</PropertyGroup>
99

1010
<ItemGroup>

0 commit comments

Comments
 (0)