Skip to content

Commit 4c77bde

Browse files
Suppress TLS usage warnings (#3069)
1 parent 1998216 commit 4c77bde

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ private void ParseMultipartName()
752752
}
753753
}
754754

755-
internal static readonly MultiPartTableName Null = new MultiPartTableName(new string[] { null, null, null, null });
755+
internal static readonly MultiPartTableName Null = new(new string[] { null, null, null, null });
756756
}
757757

758758
internal static class SslProtocolsHelper
@@ -767,12 +767,13 @@ private static string ToFriendlyName(this SslProtocols protocol)
767767
{
768768
name = "TLS 1.3";
769769
}*/
770+
#pragma warning disable CA5397 // Do not use deprecated SslProtocols values
770771
#pragma warning disable CA5398 // Avoid hardcoded SslProtocols values
771772
if ((protocol & SslProtocols.Tls12) == SslProtocols.Tls12)
772773
{
773774
name = "TLS 1.2";
774775
}
775-
#if NET
776+
#if NET8_0_OR_GREATER
776777
#pragma warning disable SYSLIB0039 // Type or member is obsolete: TLS 1.0 & 1.1 are deprecated
777778
#endif
778779
else if ((protocol & SslProtocols.Tls11) == SslProtocols.Tls11)
@@ -783,7 +784,7 @@ private static string ToFriendlyName(this SslProtocols protocol)
783784
{
784785
name = "TLS 1.0";
785786
}
786-
#if NET
787+
#if NET8_0_OR_GREATER
787788
#pragma warning restore SYSLIB0039 // Type or member is obsolete: SSL and TLS 1.0 & 1.1 is deprecated
788789
#endif
789790
#pragma warning disable CS0618 // Type or member is obsolete: SSL is deprecated
@@ -796,6 +797,7 @@ private static string ToFriendlyName(this SslProtocols protocol)
796797
{
797798
name = "SSL 2.0";
798799
}
800+
#pragma warning restore CA5397 // Do not use deprecated SslProtocols values
799801
#pragma warning restore CA5398 // Avoid hardcoded SslProtocols values
800802
else
801803
{
@@ -817,17 +819,17 @@ private static string ToFriendlyName(this SslProtocols protocol)
817819
public static string GetProtocolWarning(this SslProtocols protocol)
818820
{
819821
string message = string.Empty;
820-
#if NET
822+
#if NET8_0_OR_GREATER
821823
#pragma warning disable SYSLIB0039 // Type or member is obsolete: TLS 1.0 & 1.1 are deprecated
822824
#endif
823825
#pragma warning disable CS0618 // Type or member is obsolete : SSL is deprecated
824826
#pragma warning disable CA5397 // Do not use deprecated SslProtocols values
825-
#pragma warning disable CA5398 // Do not use deprecated SslProtocols values
827+
#pragma warning disable CA5398 // Avoid hardcoded SslProtocols values
826828
if ((protocol & (SslProtocols.Ssl2 | SslProtocols.Ssl3 | SslProtocols.Tls | SslProtocols.Tls11)) != SslProtocols.None)
827-
#pragma warning restore CA5398 // Do not use deprecated SslProtocols values
829+
#pragma warning restore CA5398 // Avoid hardcoded SslProtocols values
828830
#pragma warning restore CA5397 // Do not use deprecated SslProtocols values
829831
#pragma warning restore CS0618 // Type or member is obsolete : SSL is deprecated
830-
#if NET
832+
#if NET8_0_OR_GREATER
831833
#pragma warning restore SYSLIB0039 // Type or member is obsolete: SSL and TLS 1.0 & 1.1 is deprecated
832834
#endif
833835
{

0 commit comments

Comments
 (0)