diff --git a/src/WinRT.Runtime/ComWrappersSupport.net5.cs b/src/WinRT.Runtime/ComWrappersSupport.net5.cs index 6842d843f..3374a8bda 100644 --- a/src/WinRT.Runtime/ComWrappersSupport.net5.cs +++ b/src/WinRT.Runtime/ComWrappersSupport.net5.cs @@ -572,6 +572,13 @@ static unsafe DefaultComWrappers() private static unsafe bool IsRuntimeImplementedRCW(Type objType) { + // Built-in COM interop isn't supported in AOT environments, + // so this method can only ever return false. Just inline it. + if (!RuntimeFeature.IsDynamicCodeCompiled) + { + return false; + } + bool isRcw = objType.IsCOMObject; if (objType.IsGenericType) { @@ -692,10 +699,9 @@ public VtableEntries() public VtableEntries(List entries, Type type) { Data = (ComInterfaceEntry*)RuntimeHelpers.AllocateTypeAssociatedMemory(type, sizeof(ComInterfaceEntry) * entries.Count); - for (int i = 0; i < entries.Count; i++) - { - Data[i] = entries[i]; - } + + CollectionsMarshal.AsSpan(entries).CopyTo(new Span(Data, entries.Count)); + Count = entries.Count; } }