From dd06a1e96b8abf7e89835b6364a2099cd0f6848e Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Thu, 26 Aug 2021 19:17:31 -0700 Subject: [PATCH] Disable COM specific marshalers on Unix (#1464) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Match CoreCLR behavior and prevent compiler from crashing Co-authored-by: Michal Strehovský --- .../TypeSystem/Interop/IL/MarshalHelpers.cs | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalHelpers.cs b/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalHelpers.cs index 458b4c6a6b676e..a736d065dd8332 100644 --- a/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalHelpers.cs +++ b/src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalHelpers.cs @@ -266,7 +266,10 @@ internal static MarshallerKind GetMarshallerKind( return MarshallerKind.CBool; case NativeTypeKind.VariantBool: - return MarshallerKind.VariantBool; + if (context.Target.IsWindows) + return MarshallerKind.VariantBool; + else + return MarshallerKind.Invalid; default: return MarshallerKind.Invalid; @@ -580,12 +583,18 @@ internal static MarshallerKind GetMarshallerKind( { if (nativeType == NativeTypeKind.AsAny) return isAnsi ? MarshallerKind.AsAnyA : MarshallerKind.AsAnyW; - else if ((isField && nativeType == NativeTypeKind.Default) - || nativeType == NativeTypeKind.Intf - || nativeType == NativeTypeKind.IUnknown) - return MarshallerKind.ComInterface; else - return MarshallerKind.Variant; + if (context.Target.IsWindows) + { + if ((isField && nativeType == NativeTypeKind.Default) + || nativeType == NativeTypeKind.Intf + || nativeType == NativeTypeKind.IUnknown) + return MarshallerKind.ComInterface; + else + return MarshallerKind.Variant; + } + else + return MarshallerKind.Invalid; } else if (InteropTypes.IsStringBuilder(context, type)) { @@ -641,7 +650,10 @@ internal static MarshallerKind GetMarshallerKind( } else if (type.IsInterface) { - return MarshallerKind.ComInterface; + if (context.Target.IsWindows) + return MarshallerKind.ComInterface; + else + return MarshallerKind.Invalid; } else return MarshallerKind.Invalid;