From daffba6b2daf88822fc57c4d53e92d7ed6dd5092 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Thu, 9 Jun 2022 16:09:33 -0400 Subject: [PATCH] Enable IDE0110 (Remove unnecessary discard) (#70500) --- eng/CodeAnalysis.src.globalconfig | 2 +- .../src/System/Data/Odbc/OdbcParameterHelper.cs | 4 ++-- .../Net/Http/SocketsHttpHandler/Http3RequestStream.cs | 8 ++++---- .../MarshallingAttributeInfo.cs | 2 +- .../X509Certificates/StorePal.Android.AndroidKeyStore.cs | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/eng/CodeAnalysis.src.globalconfig b/eng/CodeAnalysis.src.globalconfig index a9a8f29956c..f246a7b6af4 100644 --- a/eng/CodeAnalysis.src.globalconfig +++ b/eng/CodeAnalysis.src.globalconfig @@ -1546,7 +1546,7 @@ dotnet_diagnostic.IDE0090.severity = silent dotnet_diagnostic.IDE0100.severity = suggestion # IDE0110: Remove unnecessary discard -dotnet_diagnostic.IDE0110.severity = suggestion +dotnet_diagnostic.IDE0110.severity = warning # IDE0120: Simplify LINQ expression dotnet_diagnostic.IDE0120.severity = none diff --git a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcParameterHelper.cs b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcParameterHelper.cs index 03a01c9735a..450bf1d2d56 100644 --- a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcParameterHelper.cs +++ b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcParameterHelper.cs @@ -243,8 +243,8 @@ namespace System.Data.Odbc string svalue => svalue.Length, byte[] bvalue => bvalue.Length, char[] cvalue => cvalue.Length, - byte _ => 1, - char _ => 1, + byte => 1, + char => 1, _ => 0 }; } diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3RequestStream.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3RequestStream.cs index 64a609afedb..59bf3ff97f8 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3RequestStream.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3RequestStream.cs @@ -1189,15 +1189,15 @@ namespace System.Net.Http switch (ex) { // Peer aborted the stream - case QuicStreamAbortedException _: + case QuicStreamAbortedException: // User aborted the stream - case QuicOperationAbortedException _: + case QuicOperationAbortedException: throw new IOException(SR.net_http_client_execution_error, new HttpRequestException(SR.net_http_client_execution_error, ex)); - case QuicConnectionAbortedException _: + case QuicConnectionAbortedException: // Our connection was reset. Start aborting the connection. Exception abortException = _connection.Abort(ex); throw new IOException(SR.net_http_client_execution_error, new HttpRequestException(SR.net_http_client_execution_error, abortException)); - case Http3ConnectionException _: + case Http3ConnectionException: // A connection-level protocol error has occurred on our stream. _connection.Abort(ex); throw new IOException(SR.net_http_client_execution_error, new HttpRequestException(SR.net_http_client_execution_error, ex)); diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/MarshallingAttributeInfo.cs b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/MarshallingAttributeInfo.cs index f2a98d6b246..061cb4146e6 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/MarshallingAttributeInfo.cs +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/MarshallingAttributeInfo.cs @@ -455,7 +455,7 @@ namespace Microsoft.Interop } } } - else if (_contextSymbol is INamedTypeSymbol _) + else if (_contextSymbol is INamedTypeSymbol) { // TODO: Handle when we create a struct marshalling generator // Do we want to support CountElementName pointing to only fields, or properties as well? diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/StorePal.Android.AndroidKeyStore.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/StorePal.Android.AndroidKeyStore.cs index 4a1abe1bd9a..6952881cd4d 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/StorePal.Android.AndroidKeyStore.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/StorePal.Android.AndroidKeyStore.cs @@ -56,9 +56,9 @@ namespace System.Security.Cryptography.X509Certificates // The AndroidKeyStore doesn't support adding DSA private key entries in newer versions (API 23+) // Our minimum supported version (API 21) does support it, but for simplicity, we simply block adding // certificates with DSA private keys on all versions instead of trying to support it on two versions. - SafeDsaHandle _ => throw new PlatformNotSupportedException(SR.Cryptography_X509_StoreDSAPrivateKeyNotSupported), - SafeEcKeyHandle _ => Interop.AndroidCrypto.PAL_KeyAlgorithm.EC, - SafeRsaHandle _ => Interop.AndroidCrypto.PAL_KeyAlgorithm.RSA, + SafeDsaHandle => throw new PlatformNotSupportedException(SR.Cryptography_X509_StoreDSAPrivateKeyNotSupported), + SafeEcKeyHandle => Interop.AndroidCrypto.PAL_KeyAlgorithm.EC, + SafeRsaHandle => Interop.AndroidCrypto.PAL_KeyAlgorithm.RSA, _ => throw new NotSupportedException(SR.NotSupported_KeyAlgorithm) };