Exception format cleanup subset (#25185)
authorDan Moseley <danmose@microsoft.com>
Wed, 19 Jun 2019 08:28:30 +0000 (01:28 -0700)
committerGitHub <noreply@github.com>
Wed, 19 Jun 2019 08:28:30 +0000 (01:28 -0700)
* Change ArgumentException message to one line

* Disable 2 tests

* Remove duplication in AggregateException.ToString()

* Inner exceptions on new lines

* Caps letter

* Typo

src/System.Private.CoreLib/Resources/Strings.resx
src/System.Private.CoreLib/shared/System/AggregateException.cs
src/System.Private.CoreLib/shared/System/ArgumentException.cs
src/System.Private.CoreLib/shared/System/BadImageFormatException.cs
src/System.Private.CoreLib/shared/System/Exception.cs
src/System.Private.CoreLib/shared/System/IO/FileLoadException.cs
src/System.Private.CoreLib/shared/System/IO/FileNotFoundException.cs
src/System.Private.CoreLib/shared/System/Runtime/InteropServices/COMException.cs
src/System.Private.CoreLib/shared/System/Runtime/InteropServices/ExternalException.cs
tests/CoreFX/CoreFX.issues.rsp

index 48cbbcf..3bd8d5a 100644 (file)
     <value>Insufficient memory to continue the execution of the program.</value>
   </data>
   <data name="Arg_ParamName_Name" xml:space="preserve">
-    <value>Parameter name: {0}</value>
+    <value>(Parameter '{0}')</value>
   </data>
   <data name="Arg_ParmArraySize" xml:space="preserve">
     <value>Must specify one or more parameters.</value>
index 08cda7c..d19a70e 100644 (file)
@@ -451,8 +451,10 @@ namespace System
 
             for (int i = 0; i < m_innerExceptions.Count; i++)
             {
-                text.AppendLine();
-                text.Append("---> ");
+                if (m_innerExceptions[i] == InnerException)
+                    continue; // Already logged in base.ToString()
+
+                text.Append(Environment.NewLine).Append(InnerExceptionPrefix);
                 text.AppendFormat(CultureInfo.InvariantCulture, SR.AggregateException_InnerException, i);
                 text.Append(m_innerExceptions[i].ToString());
                 text.Append("<---");
index 6e38c7b..a803b1a 100644 (file)
@@ -81,11 +81,10 @@ namespace System
                 string s = base.Message;
                 if (!string.IsNullOrEmpty(_paramName))
                 {
-                    string resourceString = SR.Format(SR.Arg_ParamName_Name, _paramName);
-                    return s + Environment.NewLine + resourceString;
+                    s += " " + SR.Format(SR.Arg_ParamName_Name, _paramName);
                 }
-                else
-                    return s;
+
+                return s;
             }
         }
 
index 23aa564..913e2b9 100644 (file)
@@ -104,7 +104,7 @@ namespace System
                 s += Environment.NewLine + SR.Format(SR.IO_FileName_Name, _fileName);
 
             if (InnerException != null)
-                s = s + " ---> " + InnerException.ToString();
+                s = s + InnerExceptionPrefix + InnerException.ToString();
 
             if (StackTrace != null)
                 s += Environment.NewLine + StackTrace;
index 2f07ca2..30b808d 100644 (file)
@@ -11,6 +11,8 @@ namespace System
     [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
     public partial class Exception : ISerializable
     {
+        internal protected const string InnerExceptionPrefix = " ---> ";
+
         public Exception()
         {
             _HResult = HResults.COR_E_EXCEPTION;
@@ -151,7 +153,7 @@ namespace System
 
             if (_innerException != null)
             {
-                s = s + " ---> " + _innerException.ToString() + Environment.NewLine +
+                s = s + Environment.NewLine + InnerExceptionPrefix + _innerException.ToString() + Environment.NewLine +
                 "   " + SR.Exception_EndOfInnerExceptionStack;
             }
 
index 729d480..30f0278 100644 (file)
@@ -64,7 +64,7 @@ namespace System.IO
                 s += Environment.NewLine + SR.Format(SR.IO_FileName_Name, FileName);
 
             if (InnerException != null)
-                s = s + " ---> " + InnerException.ToString();
+                s = s + Environment.NewLine + InnerExceptionPrefix + InnerException.ToString();
 
             if (StackTrace != null)
                 s += Environment.NewLine + StackTrace;
index 0ce1c74..334325b 100644 (file)
@@ -78,7 +78,7 @@ namespace System.IO
                 s += Environment.NewLine + SR.Format(SR.IO_FileName_Name, FileName);
 
             if (InnerException != null)
-                s = s + " ---> " + InnerException.ToString();
+                s = s + Environment.NewLine + InnerExceptionPrefix + InnerException.ToString();
 
             if (StackTrace != null)
                 s += Environment.NewLine + StackTrace;
index 2dec6b8..1b66bb6 100644 (file)
@@ -48,7 +48,7 @@ namespace System.Runtime.InteropServices
         public override string ToString()
         {
             StringBuilder s = new StringBuilder();
-            
+
             string className = GetType().ToString();
             s.Append(className).Append(" (0x").Append(HResult.ToString("X8", CultureInfo.InvariantCulture)).Append(')');
 
@@ -61,7 +61,7 @@ namespace System.Runtime.InteropServices
             Exception? innerException = InnerException;
             if (innerException != null)
             {
-                s.Append(" ---> ").Append(innerException.ToString());
+                s.Append(Environment.NewLine).Append(InnerExceptionPrefix).Append(innerException.ToString());
             }
 
             string? stackTrace = StackTrace;
index d587d82..9028288 100644 (file)
@@ -75,7 +75,7 @@ namespace System.Runtime.InteropServices
             Exception? innerException = InnerException;
             if (innerException != null)
             {
-                s = s + " ---> " + innerException.ToString();
+                s = s + Environment.NewLine + InnerExceptionPrefix + innerException.ToString();
             }
 
             if (StackTrace != null)
index 8a35ea3..40c0fd4 100644 (file)
 # Assert: https://github.com/dotnet/coreclr/issues/25050
 -nonamespace System.Data.Common.Tests
 
+# requires corefx test updates
+-nomethod System.Data.Tests.Common.DbConnectionStringBuilderTest.Add_Keyword_Invalid
+-nomethod System.Data.Tests.Common.DbConnectionStringBuilderTest.Indexer_Keyword_Invalid
+
 # requires corefx test updates https://github.com/dotnet/corefx/pull/38452
 -nomethod System.SpanTests.ReadOnlySpanTests.ZeroLengthIndexOfAny_ManyInteger
 -nomethod System.SpanTests.ReadOnlySpanTests.ZeroLengthIndexOfAny_ManyString