From 0a7c748a9b284449da86490f8dac6206480b5722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Thu, 16 May 2024 15:53:30 +0200 Subject: [PATCH] Execute SqlClient tests also on .NET Fx 4.8.1 (#3412) --- .../IntegrationTests/Helpers/RuntimeHelper.cs | 52 ------------------- .../SqlClientSystemDataTests.cs | 15 +----- 2 files changed, 1 insertion(+), 66 deletions(-) delete mode 100644 test/IntegrationTests/Helpers/RuntimeHelper.cs diff --git a/test/IntegrationTests/Helpers/RuntimeHelper.cs b/test/IntegrationTests/Helpers/RuntimeHelper.cs deleted file mode 100644 index 30d21e7b3b..0000000000 --- a/test/IntegrationTests/Helpers/RuntimeHelper.cs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#if NETFRAMEWORK - -using Microsoft.Win32; - -namespace IntegrationTests.Helpers; - -internal static class RuntimeHelper -{ - // https://learn.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed - public static string? GetRuntimeVersion() - { - const string subkey = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\"; - - using (var ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey(subkey)) - { - if (ndpKey != null && ndpKey.GetValue("Release") != null) - { - return CheckFor45PlusVersion((int)ndpKey.GetValue("Release")); - } - - return null; - } - - // Checking the version using >= enables forward compatibility. - static string CheckFor45PlusVersion(int releaseKey) - { - return releaseKey switch - { - >= 533320 => "4.8.1+", - >= 528040 => "4.8", - >= 461808 => "4.7.2", - >= 461308 => "4.7.1", - >= 460798 => "4.7", - >= 394802 => "4.6.2", - >= 394254 => "4.6.1", - >= 393295 => "4.6", - >= 379893 => "4.5.2", - >= 378675 => "4.5.1", - >= 378389 => "4.5", - _ => - // This code should never execute. A non-null release key should mean - // that 4.5 or later is installed. - "No 4.5+" - }; - } - } -} - -#endif diff --git a/test/IntegrationTests/SqlClientSystemDataTests.cs b/test/IntegrationTests/SqlClientSystemDataTests.cs index d60e5a3bfc..b3e9f63351 100644 --- a/test/IntegrationTests/SqlClientSystemDataTests.cs +++ b/test/IntegrationTests/SqlClientSystemDataTests.cs @@ -15,7 +15,7 @@ public SqlClientSystemDataTests(ITestOutputHelper output) { } - [IgnoreRunningOnNet481Fact] + [Fact] [Trait("Category", "EndToEnd")] public void SubmitTraces() { @@ -28,17 +28,4 @@ public void SubmitTraces() collector.AssertExpectations(); } } - -public sealed class IgnoreRunningOnNet481Fact : FactAttribute -{ - public IgnoreRunningOnNet481Fact() - { - var netVersion = RuntimeHelper.GetRuntimeVersion(); - if (netVersion == "4.8.1+") - { - // https://github.com/open-telemetry/opentelemetry-dotnet/issues/3901 - Skip = "NET Framework 4.8.1 is skipped due bug."; - } - } -} #endif