未验证 提交 f26c91bb 编写于 作者: M Michal Strehovský 提交者: GitHub

Allow AsLPArray test to succeed without COM (#74552)

上级 e130a89c
......@@ -13,5 +13,12 @@ public static class PlatformDetection
public static bool IsX86Process => RuntimeInformation.ProcessArchitecture == Architecture.X86;
public static bool IsNotX86Process => !IsX86Process;
public static bool IsWindows => OperatingSystem.IsWindows();
public static bool IsBuiltInComEnabled => IsWindows
&& (AppContext.TryGetSwitch("System.Runtime.InteropServices.BuiltInComInterop.IsSupported", out bool isEnabled)
? isEnabled
: true);
}
}
......@@ -3,6 +3,7 @@
using System;
using System.Runtime.InteropServices;
using TestLibrary;
using Xunit;
public class ArrayMarshal
......@@ -316,7 +317,7 @@ private static void TestMarshalByVal_NoAttributes()
Assert.True(CStyle_Array_Struct(InitStructArray(ARRAY_SIZE), ARRAY_SIZE));
Assert.True(CStyle_Array_Bool(InitBoolArray(ARRAY_SIZE), ARRAY_SIZE));
if (OperatingSystem.IsWindows())
if (PlatformDetection.IsBuiltInComEnabled)
{
object[] oArr = InitArray<object>(ARRAY_SIZE);
// Test nesting null value scenario
......@@ -349,7 +350,7 @@ private static void TestMarshalByVal_In()
Assert.True(CStyle_Array_Struct_In(InitStructArray(ARRAY_SIZE), ARRAY_SIZE));
Assert.True(CStyle_Array_Bool_In(InitBoolArray(ARRAY_SIZE), ARRAY_SIZE));
if (OperatingSystem.IsWindows())
if (PlatformDetection.IsBuiltInComEnabled)
{
object[] oArr = InitArray<object>(ARRAY_SIZE);
// Test nesting null value scenario
......@@ -556,7 +557,7 @@ private static void TestMarshalByVal_Out()
Assert.True(CStyle_Array_Bool_Out(boolArr, ARRAY_SIZE));
Assert.True(Equals<bool>(boolArr, GetExpectedOutBoolArray(ARRAY_SIZE)));
if (OperatingSystem.IsWindows())
if (PlatformDetection.IsBuiltInComEnabled)
{
object[] oArr = new object[ARRAY_SIZE];
Assert.True(CStyle_Array_Object_Out(oArr, ARRAY_SIZE));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册