Skip to content

Commit

Permalink
Skip MGM(Type) in MarshalInterface<T> on NAOT
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Jan 13, 2024
1 parent e841655 commit 4a89242
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/WinRT.Runtime/Marshalers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1449,19 +1449,23 @@ private static Func<T, IObjectReference> BindToAbi()

private static Func<T, IObjectReference> BindCreateMarshaler()
{
var vftblType = HelperType.FindVftblType();
Guid iid = GuidGenerator.GetIID(HelperType);
if (vftblType is not null)
{
var methodInfo = typeof(MarshalInspectable<T>).GetMethod("CreateMarshaler", new Type[] { typeof(T), typeof(Guid), typeof(bool) }).
MakeGenericMethod(vftblType);
var createMarshaler = (Func<T, Guid, bool, IObjectReference>) methodInfo.CreateDelegate(typeof(Func<T, Guid, bool, IObjectReference>));
return obj => createMarshaler(obj, iid, true);
}
else
#if NET
if (RuntimeFeature.IsDynamicCodeCompiled)
#endif
{
return obj => MarshalInspectable<T>.CreateMarshaler<IUnknownVftbl>(obj, iid, true);
var vftblType = HelperType.FindVftblType();

if (vftblType is not null)
{
var methodInfo = typeof(MarshalInspectable<T>).GetMethod("CreateMarshaler", new Type[] { typeof(T), typeof(Guid), typeof(bool) }).
MakeGenericMethod(vftblType);
var createMarshaler = (Func<T, Guid, bool, IObjectReference>)methodInfo.CreateDelegate(typeof(Func<T, Guid, bool, IObjectReference>));
return obj => createMarshaler(obj, iid, true);
}
}

return obj => MarshalInspectable<T>.CreateMarshaler<IUnknownVftbl>(obj, iid, true);
}
}

Expand Down

0 comments on commit 4a89242

Please sign in to comment.