From 1e241a533f6864dfa568d02c80ae6b01c4b3436e Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Wed, 24 Jul 2019 07:33:20 -0400 Subject: [PATCH] Re-enable CA2200 (rethrowing exceptions in catch blocks) (dotnet/corefx#39700) Commit migrated from https://github.com/dotnet/corefx/commit/7b142543ce066ba684303837c2e9723b9e140d39 --- src/libraries/CodeAnalysis.ruleset | 1 - .../src/Microsoft/CSharp/RuntimeBinder/DynamicDebuggerProxy.cs | 8 ++++---- .../src/System/ComponentModel/ReflectEventDescriptor.cs | 4 ++-- .../src/System/ComponentModel/ReflectPropertyDescriptor.cs | 10 +++++----- src/libraries/System.Data.Common/src/System/Data/DataTable.cs | 2 +- .../System.Data.Odbc/src/System/Data/Odbc/OdbcDataReader.cs | 4 ++-- .../src/System/Data/SqlClient/SqlInternalConnectionTds.cs | 2 +- .../src/System/Diagnostics/ProcessManager.Windows.cs | 2 +- .../DirectoryServices/AccountManagement/AD/ADStoreCtx.cs | 2 +- .../System/DirectoryServices/AccountManagement/Principal.cs | 2 +- .../src/System/DirectoryServices/DirectoryEntry.cs | 6 +++--- 11 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/libraries/CodeAnalysis.ruleset b/src/libraries/CodeAnalysis.ruleset index df36d7d..199a9e9 100644 --- a/src/libraries/CodeAnalysis.ruleset +++ b/src/libraries/CodeAnalysis.ruleset @@ -61,7 +61,6 @@ - diff --git a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/DynamicDebuggerProxy.cs b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/DynamicDebuggerProxy.cs index 6169d54..d27b382 100644 --- a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/DynamicDebuggerProxy.cs +++ b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/DynamicDebuggerProxy.cs @@ -398,19 +398,19 @@ namespace Microsoft.CSharp.RuntimeBinder { value = site.Target(site, obj); } - catch (DynamicBindingFailedException exp) + catch (DynamicBindingFailedException) { if (ignoreException) value = null; else - throw exp; + throw; } - catch (MissingMemberException exp) + catch (MissingMemberException) { if (ignoreException) value = SR.GetValueonWriteOnlyProperty; else - throw exp; + throw; } return value; } diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectEventDescriptor.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectEventDescriptor.cs index 2f95b4c..ccc37b8 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectEventDescriptor.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectEventDescriptor.cs @@ -160,7 +160,7 @@ namespace System.ComponentModel if (coEx == CheckoutException.Canceled) { return; } - throw coEx; + throw; } changeService.OnComponentChanging(component, this); } @@ -431,7 +431,7 @@ namespace System.ComponentModel if (coEx == CheckoutException.Canceled) { return; } - throw coEx; + throw; } changeService.OnComponentChanging(component, this); } diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectPropertyDescriptor.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectPropertyDescriptor.cs index 00fc474..8247ebf 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectPropertyDescriptor.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectPropertyDescriptor.cs @@ -564,7 +564,7 @@ namespace System.ComponentModel { return; } - throw coEx; + throw; } } @@ -612,7 +612,7 @@ namespace System.ComponentModel { return; } - throw coEx; + throw; } } @@ -1015,7 +1015,7 @@ namespace System.ComponentModel { return; } - throw coEx; + throw; } } @@ -1077,7 +1077,7 @@ namespace System.ComponentModel { return; } - throw coEx; + throw; } } @@ -1106,7 +1106,7 @@ namespace System.ComponentModel } else { - throw t; + throw; } } } diff --git a/src/libraries/System.Data.Common/src/System/Data/DataTable.cs b/src/libraries/System.Data.Common/src/System/Data/DataTable.cs index fbae328..4da54ca 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataTable.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataTable.cs @@ -4438,7 +4438,7 @@ namespace System.Data // deferred until after the row has been completely added. if (action != DataRowAction.Add) { - throw exc; + throw; } else { diff --git a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcDataReader.cs b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcDataReader.cs index a256eb8..d67bfc9 100644 --- a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcDataReader.cs +++ b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcDataReader.cs @@ -895,10 +895,10 @@ namespace System.Data.Odbc s = (string)Buffer.MarshalToManaged(0, ODBC32.SQL_C.WCHAR, ODBC32.SQL_NTS); _dataCache[i] = decimal.Parse(s, System.Globalization.CultureInfo.InvariantCulture); } - catch (OverflowException e) + catch (OverflowException) { _dataCache[i] = s; - throw e; + throw; } } } diff --git a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlInternalConnectionTds.cs b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlInternalConnectionTds.cs index 78913ac..f12abb4 100644 --- a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlInternalConnectionTds.cs +++ b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlInternalConnectionTds.cs @@ -393,7 +393,7 @@ namespace System.Data.SqlClient || _timeout.MillisecondsRemaining < transientRetryIntervalInMilliSeconds || !IsTransientError(sqlex)) { - throw sqlex; + throw; } else { diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Windows.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Windows.cs index bc84718..f8456e0 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Windows.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Windows.cs @@ -344,7 +344,7 @@ namespace System.Diagnostics } else { - throw e; + throw; } } // We don't want to call library.Close() here because that would cause us to unload all of the perflibs. diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADStoreCtx.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADStoreCtx.cs index f9fc0db..c98e985 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADStoreCtx.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADStoreCtx.cs @@ -431,7 +431,7 @@ namespace System.DirectoryServices.AccountManagement if (e is System.Runtime.InteropServices.COMException) throw ExceptionHelper.GetExceptionFromCOMException((System.Runtime.InteropServices.COMException)e); else - throw e; + throw; } } diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/Principal.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/Principal.cs index c1d6de4..7eb377d 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/Principal.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/Principal.cs @@ -434,7 +434,7 @@ namespace System.DirectoryServices.AccountManagement if (e is System.Runtime.InteropServices.COMException) throw ExceptionHelper.GetExceptionFromCOMException((System.Runtime.InteropServices.COMException)e); else - throw e; + throw; } } diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryEntry.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryEntry.cs index 79fbb6c..0feac35 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryEntry.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryEntry.cs @@ -815,7 +815,7 @@ namespace System.DirectoryServices } } - throw e; + throw; } if (result is UnsafeNativeMethods.IAds) @@ -853,7 +853,7 @@ namespace System.DirectoryServices } } - throw e; + throw; } return result; @@ -886,7 +886,7 @@ namespace System.DirectoryServices } } - throw e; + throw; } } -- 2.7.4