Re-enable CA2200 (rethrowing exceptions in catch blocks) (dotnet/corefx#39700)
authorStephen Toub <stoub@microsoft.com>
Wed, 24 Jul 2019 11:33:20 +0000 (07:33 -0400)
committerGitHub <noreply@github.com>
Wed, 24 Jul 2019 11:33:20 +0000 (07:33 -0400)
Commit migrated from https://github.com/dotnet/corefx/commit/7b142543ce066ba684303837c2e9723b9e140d39

src/libraries/CodeAnalysis.ruleset
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/DynamicDebuggerProxy.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectEventDescriptor.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectPropertyDescriptor.cs
src/libraries/System.Data.Common/src/System/Data/DataTable.cs
src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcDataReader.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlInternalConnectionTds.cs
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Windows.cs
src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADStoreCtx.cs
src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/Principal.cs
src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryEntry.cs

index df36d7d..199a9e9 100644 (file)
@@ -61,7 +61,6 @@
     <Rule Id="CA2100" Action="None" /> <!-- Review SQL queries for security vulnerabilities -->
     <Rule Id="CA2101" Action="None" /> <!-- Specify marshaling for P/Invoke string arguments -->
     <Rule Id="CA2119" Action="None" /> <!-- Seal methods that satisfy private interfaces -->
-    <Rule Id="CA2200" Action="None" /> <!-- Rethrowing caught exception changes stack information -->
     <Rule Id="CA2207" Action="None" /> <!-- Initialize value type static fields inline -->
     <Rule Id="CA2208" Action="None" /> <!-- Instantiate exception arguments correctly -->
     <Rule Id="CA2211" Action="None" /> <!-- Non-constant fields should not be visible -->
index 6169d54..d27b382 100644 (file)
@@ -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;
         }
index 2f95b4c..ccc37b8 100644 (file)
@@ -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);
                 }
index 00fc474..8247ebf 100644 (file)
@@ -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;
                             }
                         }
                     }
index fbae328..4da54ca 100644 (file)
@@ -4438,7 +4438,7 @@ namespace System.Data
                     // deferred until after the row has been completely added.
                     if (action != DataRowAction.Add)
                     {
-                        throw exc;
+                        throw;
                     }
                     else
                     {
index a256eb8..d67bfc9 100644 (file)
@@ -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;
                         }
                     }
                 }
index 78913ac..f12abb4 100644 (file)
@@ -393,7 +393,7 @@ namespace System.Data.SqlClient
                             || _timeout.MillisecondsRemaining < transientRetryIntervalInMilliSeconds
                             || !IsTransientError(sqlex))
                         {
-                            throw sqlex;
+                            throw;
                         }
                         else
                         {
index bc84718..f8456e0 100644 (file)
@@ -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.
index f9fc0db..c98e985 100644 (file)
@@ -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;
             }
         }
 
index c1d6de4..7eb377d 100644 (file)
@@ -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;
                 }
             }
 
index 79fbb6c..0feac35 100644 (file)
@@ -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;
             }
         }