From 21bebf42df132e0b5076ddefd49a416b2061e175 Mon Sep 17 00:00:00 2001 From: Edward Neal <55035479+edwardneal@users.noreply.github.com> Date: Sat, 2 Nov 2024 12:47:42 +0000 Subject: [PATCH] Conditionally compile .NET 6.0-only files InternalException, NetEventSource and the types associated with SecPkgContext_ApplicationProtocol are only used by the old .NET 6.0 target. --- .../netcore/src/Common/System/Net/InternalException.cs | 4 ++++ .../src/Common/System/Net/Logging/NetEventSource.Common.cs | 4 ++++ .../Interop.SecPkgContext_ApplicationProtocol.netcore.cs | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Common/System/Net/InternalException.cs b/src/Microsoft.Data.SqlClient/netcore/src/Common/System/Net/InternalException.cs index 6e5a64cc65..db7d05d9a6 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Common/System/Net/InternalException.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Common/System/Net/InternalException.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#if NET && !NET8_0_OR_GREATER + namespace System.Net { [Serializable] @@ -21,3 +23,5 @@ public InternalException(string message, Exception innerException) : base(messag } } } + +#endif diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Common/System/Net/Logging/NetEventSource.Common.cs b/src/Microsoft.Data.SqlClient/netcore/src/Common/System/Net/Logging/NetEventSource.Common.cs index 1e56818132..c035159e20 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Common/System/Net/Logging/NetEventSource.Common.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Common/System/Net/Logging/NetEventSource.Common.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#if NET && !NET8_0_OR_GREATER + #if DEBUG // Uncomment to enable runtime checks to help validate that NetEventSource isn't being misused // in a way that will cause performance problems, e.g. unexpected boxing of value types. @@ -771,3 +773,5 @@ private unsafe void WriteEvent(int eventId, string arg1, string arg2, string arg #endregion } } + +#endif diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/SChannel/Interop.SecPkgContext_ApplicationProtocol.netcore.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/SChannel/Interop.SecPkgContext_ApplicationProtocol.netcore.cs index 8c7537ac78..cd485ef450 100644 --- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/SChannel/Interop.SecPkgContext_ApplicationProtocol.netcore.cs +++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/SChannel/Interop.SecPkgContext_ApplicationProtocol.netcore.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#if NET +#if NET && !NET8_0_OR_GREATER using System; using System.Runtime.InteropServices;