From 31fb2862689afd2a4ac29e14be7fb32da81e66b9 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Thu, 10 Jan 2019 20:01:43 +0100 Subject: [PATCH] Move COMException to shared partition (dotnet/corertdotnet/coreclr#6803) * Move COMException to shared partition * Review feedback Signed-off-by: dotnet-bot Commit migrated from https://github.com/dotnet/coreclr/commit/15036527b060dccef9f3befe33af22346e6999cb --- .../System.Private.CoreLib.csproj | 1 - .../src/System.Private.CoreLib.Shared.projitems | 1 + .../System/Runtime/InteropServices/COMException.cs | 32 +++++++++++----------- 3 files changed, 17 insertions(+), 17 deletions(-) rename src/{coreclr/src => libraries}/System.Private.CoreLib/src/System/Runtime/InteropServices/COMException.cs (63%) diff --git a/src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj index 779688e..5111d69 100644 --- a/src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -252,7 +252,6 @@ - diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index df9a17e..45e8cbc 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -580,6 +580,7 @@ + diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/InteropServices/COMException.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/COMException.cs similarity index 63% rename from src/coreclr/src/System.Private.CoreLib/src/System/Runtime/InteropServices/COMException.cs rename to src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/COMException.cs index f1ddf65..0823c56 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/InteropServices/COMException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/COMException.cs @@ -2,9 +2,9 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Runtime.CompilerServices; using System.Runtime.Serialization; using System.Globalization; +using System.Text; namespace System.Runtime.InteropServices { @@ -14,7 +14,7 @@ namespace System.Runtime.InteropServices /// recognize the HResult. /// [Serializable] - [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] + [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class COMException : ExternalException { public COMException() @@ -47,28 +47,28 @@ namespace System.Runtime.InteropServices public override string ToString() { - string message = Message; - string s; - string _className = GetType().ToString(); - s = _className + " (0x" + HResult.ToString("X8", CultureInfo.InvariantCulture) + ")"; + StringBuilder s = new StringBuilder(); + + string className = GetType().ToString(); + s.Append(className).Append(" (0x").Append(HResult.ToString("X8", CultureInfo.InvariantCulture)).Append(')'); - if (!(message == null || message.Length <= 0)) + string message = Message; + if (!string.IsNullOrEmpty(message)) { - s = s + ": " + message; + s.Append(": ").Append(message); } - Exception _innerException = InnerException; - - if (_innerException != null) + Exception innerException = InnerException; + if (innerException != null) { - s = s + " ---> " + _innerException.ToString(); + s.Append(" ---> ").Append(innerException.ToString()); } + string stackTrace = StackTrace; + if (stackTrace != null) + s.Append(Environment.NewLine).Append(stackTrace); - if (StackTrace != null) - s += Environment.NewLine + StackTrace; - - return s; + return s.ToString(); } } } -- 2.7.4