From 699f6abed4f632ed2270fb3c45c8078da29c75ea Mon Sep 17 00:00:00 2001 From: Cheena Malhotra <13396919+cheenamalhotra@users.noreply.github.com> Date: Tue, 29 Oct 2024 16:56:58 -0700 Subject: [PATCH] Suppress roslyn errors and warnings (#2936) --- .../Data/SqlClient/TdsParserStateObjectNative.cs | 4 +++- .../Microsoft/Data/SqlClient/TdsParserHelperClasses.cs | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObjectNative.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObjectNative.cs index 20f578fa2f..9b18342dfd 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObjectNative.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObjectNative.cs @@ -405,11 +405,12 @@ internal override uint WaitForSSLHandShakeToComplete(out int protocolVersion) uint returnValue = SNINativeMethodWrapper.SNIWaitForSSLHandshakeToComplete(Handle, GetTimeoutRemaining(), out uint nativeProtocolVersion); var nativeProtocol = (NativeProtocols)nativeProtocolVersion; +#pragma warning disable CA5398 // Avoid hardcoded SslProtocols values if (nativeProtocol.HasFlag(NativeProtocols.SP_PROT_TLS1_2_CLIENT) || nativeProtocol.HasFlag(NativeProtocols.SP_PROT_TLS1_2_SERVER)) { protocolVersion = (int)SslProtocols.Tls12; } -#if NET6_0_OR_GREATER +#if NET6_0_OR_GREATER else if (nativeProtocol.HasFlag(NativeProtocols.SP_PROT_TLS1_3_CLIENT) || nativeProtocol.HasFlag(NativeProtocols.SP_PROT_TLS1_3_SERVER)) { /* The SslProtocols.Tls13 is supported by netcoreapp3.1 and later */ @@ -439,6 +440,7 @@ internal override uint WaitForSSLHandShakeToComplete(out int protocolVersion) { protocolVersion = (int)SslProtocols.None; } +#pragma warning restore CA5398 // Avoid hardcoded SslProtocols values return returnValue; } diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs index a5355905d3..4c33686f16 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs @@ -767,6 +767,7 @@ private static string ToFriendlyName(this SslProtocols protocol) { name = "TLS 1.3"; }*/ +#pragma warning disable CA5398 // Avoid hardcoded SslProtocols values if ((protocol & SslProtocols.Tls12) == SslProtocols.Tls12) { name = "TLS 1.2"; @@ -795,6 +796,7 @@ private static string ToFriendlyName(this SslProtocols protocol) { name = "SSL 2.0"; } +#pragma warning restore CA5398 // Avoid hardcoded SslProtocols values else { #if !NETFRAMEWORK @@ -818,9 +820,11 @@ public static string GetProtocolWarning(this SslProtocols protocol) #if NET8_0_OR_GREATER #pragma warning disable SYSLIB0039 // Type or member is obsolete: TLS 1.0 & 1.1 are deprecated #endif -#pragma warning disable CS0618 // Type or member is obsolete : SSL is depricated +#pragma warning disable CS0618 // Type or member is obsolete : SSL is deprecated +#pragma warning disable CA5398 // Do not use deprecated SslProtocols values if ((protocol & (SslProtocols.Ssl2 | SslProtocols.Ssl3 | SslProtocols.Tls | SslProtocols.Tls11)) != SslProtocols.None) -#pragma warning restore CS0618 // Type or member is obsolete : SSL is depricated +#pragma warning restore CA5398 // Do not use deprecated SslProtocols values +#pragma warning restore CS0618 // Type or member is obsolete : SSL is deprecated #if NET8_0_OR_GREATER #pragma warning restore SYSLIB0039 // Type or member is obsolete: SSL and TLS 1.0 & 1.1 is deprecated #endif