Skip to content

Commit

Permalink
Disable COM specific marshalers on Unix (dotnet#1464)
Browse files Browse the repository at this point in the history
Match CoreCLR behavior and prevent compiler from crashing

Co-authored-by: Michal Strehovský <[email protected]>
  • Loading branch information
jkotas and MichalStrehovsky authored Aug 27, 2021
1 parent 4db726e commit dd06a1e
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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))
{
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit dd06a1e

Please sign in to comment.