From a8ff2a7420864f6fe363cf106813c6368542821a Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Wed, 16 Jan 2019 00:32:58 +0100 Subject: [PATCH] Move more COM exceptions to shared partition (dotnet/corert#6829) Signed-off-by: dotnet-bot --- .../shared/System.Private.CoreLib.Shared.projitems | 5 +++ .../InteropServices/InvalidComObjectException.cs | 41 ++++++++++++++++++ .../InvalidOleVariantTypeException.cs | 40 ++++++++++++++++++ .../System/Runtime/InteropServices/SEHException.cs | 48 ++++++++++++++++++++++ .../SafeArrayRankMismatchException.cs | 39 ++++++++++++++++++ .../SafeArrayTypeMismatchException.cs | 39 ++++++++++++++++++ 6 files changed, 212 insertions(+) create mode 100644 src/System.Private.CoreLib/shared/System/Runtime/InteropServices/InvalidComObjectException.cs create mode 100644 src/System.Private.CoreLib/shared/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs create mode 100644 src/System.Private.CoreLib/shared/System/Runtime/InteropServices/SEHException.cs create mode 100644 src/System.Private.CoreLib/shared/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs create mode 100644 src/System.Private.CoreLib/shared/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs diff --git a/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems b/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems index 5700d55..d28a53f 100644 --- a/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems +++ b/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems @@ -614,6 +614,8 @@ + + @@ -626,7 +628,10 @@ + + + diff --git a/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/InvalidComObjectException.cs b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/InvalidComObjectException.cs new file mode 100644 index 0000000..32c78e9 --- /dev/null +++ b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/InvalidComObjectException.cs @@ -0,0 +1,41 @@ +// Licensed to the .NET Foundation under one or more agreements. +// 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.Serialization; + +namespace System.Runtime.InteropServices +{ + /// + /// The exception thrown when an invalid COM object is used. This happens + /// when a the __ComObject type is used directly without having a backing + /// class factory. + /// + [Serializable] + [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] + public class InvalidComObjectException : SystemException + { + public InvalidComObjectException() + : base(SR.Arg_InvalidComObjectException) + { + HResult = HResults.COR_E_INVALIDCOMOBJECT; + } + + public InvalidComObjectException(String message) + : base(message) + { + HResult = HResults.COR_E_INVALIDCOMOBJECT; + } + + public InvalidComObjectException(String message, Exception inner) + : base(message, inner) + { + HResult = HResults.COR_E_INVALIDCOMOBJECT; + } + + protected InvalidComObjectException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + } +} diff --git a/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs new file mode 100644 index 0000000..09397dc --- /dev/null +++ b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// 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.Serialization; + +namespace System.Runtime.InteropServices +{ + /// + /// Exception thrown when the type of an OLE variant that was passed into the + /// runtime is invalid. + /// + [Serializable] + [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] + public class InvalidOleVariantTypeException : SystemException + { + public InvalidOleVariantTypeException() + : base(SR.Arg_InvalidOleVariantTypeException) + { + HResult = HResults.COR_E_INVALIDOLEVARIANTTYPE; + } + + public InvalidOleVariantTypeException(String message) + : base(message) + { + HResult = HResults.COR_E_INVALIDOLEVARIANTTYPE; + } + + public InvalidOleVariantTypeException(String message, Exception inner) + : base(message, inner) + { + HResult = HResults.COR_E_INVALIDOLEVARIANTTYPE; + } + + protected InvalidOleVariantTypeException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + } +} diff --git a/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/SEHException.cs b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/SEHException.cs new file mode 100644 index 0000000..f62f9e9 --- /dev/null +++ b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/SEHException.cs @@ -0,0 +1,48 @@ +// Licensed to the .NET Foundation under one or more agreements. +// 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.Serialization; + +namespace System.Runtime.InteropServices +{ + /// + /// Exception for Structured Exception Handler exceptions. + /// + [Serializable] + [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] + public class SEHException : ExternalException + { + public SEHException() + : base() + { + HResult = HResults.E_FAIL; + } + + public SEHException(String message) + : base(message) + { + HResult = HResults.E_FAIL; + } + + public SEHException(String message, Exception inner) + : base(message, inner) + { + HResult = HResults.E_FAIL; + } + + protected SEHException(SerializationInfo info, StreamingContext context) : base(info, context) + { + } + + // Exceptions can be resumable, meaning a filtered exception + // handler can correct the problem that caused the exception, + // and the code will continue from the point that threw the + // exception. + // + // Resumable exceptions aren't implemented in this version, + // but this method exists and always returns false. + // + public virtual bool CanResume() => false; + } +} diff --git a/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs new file mode 100644 index 0000000..95781a7 --- /dev/null +++ b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs @@ -0,0 +1,39 @@ +// Licensed to the .NET Foundation under one or more agreements. +// 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.Serialization; + +namespace System.Runtime.InteropServices +{ + /// + /// The exception is thrown when the runtime rank of a safe array is different + /// than the array rank specified in the metadata. + /// + [Serializable] + [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] + public class SafeArrayRankMismatchException : SystemException + { + public SafeArrayRankMismatchException() + : base(SR.Arg_SafeArrayRankMismatchException) + { + HResult = HResults.COR_E_SAFEARRAYRANKMISMATCH; + } + + public SafeArrayRankMismatchException(String message) + : base(message) + { + HResult = HResults.COR_E_SAFEARRAYRANKMISMATCH; + } + + public SafeArrayRankMismatchException(String message, Exception inner) + : base(message, inner) + { + HResult = HResults.COR_E_SAFEARRAYRANKMISMATCH; + } + + protected SafeArrayRankMismatchException(SerializationInfo info, StreamingContext context) : base(info, context) + { + } + } +} diff --git a/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs new file mode 100644 index 0000000..c4257dc --- /dev/null +++ b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs @@ -0,0 +1,39 @@ +// Licensed to the .NET Foundation under one or more agreements. +// 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.Serialization; + +namespace System.Runtime.InteropServices +{ + /// + /// The exception is thrown when the runtime type of an array is different + /// than the safe array sub type specified in the metadata. + /// + [Serializable] + [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] + public class SafeArrayTypeMismatchException : SystemException + { + public SafeArrayTypeMismatchException() + : base(SR.Arg_SafeArrayTypeMismatchException) + { + HResult = HResults.COR_E_SAFEARRAYTYPEMISMATCH; + } + + public SafeArrayTypeMismatchException(String message) + : base(message) + { + HResult = HResults.COR_E_SAFEARRAYTYPEMISMATCH; + } + + public SafeArrayTypeMismatchException(String message, Exception inner) + : base(message, inner) + { + HResult = HResults.COR_E_SAFEARRAYTYPEMISMATCH; + } + + protected SafeArrayTypeMismatchException(SerializationInfo info, StreamingContext context) : base(info, context) + { + } + } +} -- 2.7.4