Skip to content

Commit

Permalink
Skip checking COM objects on AOT (#1662)
Browse files Browse the repository at this point in the history
* Minor optimization in 'VtableEntries'

* Minor tweak to 'IsRuntimeImplementedRCW'
  • Loading branch information
Sergio0694 authored Jul 9, 2024
1 parent faa798b commit 8576896
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/WinRT.Runtime/ComWrappersSupport.net5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -692,10 +699,9 @@ public VtableEntries()
public VtableEntries(List<ComInterfaceEntry> 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<ComInterfaceEntry>(Data, entries.Count));

Count = entries.Count;
}
}
Expand Down

0 comments on commit 8576896

Please sign in to comment.