Skip to content

Commit

Permalink
Minor trimming optimizations for authoring (#1396)
Browse files Browse the repository at this point in the history
* Remove unnecessary trimming annotation

* Stop using GuidGenerator in Make() methods

* Remove incorrect trimming annotations

* Skip managed marshaller entirely in Make() methods
  • Loading branch information
Sergio0694 authored Jan 9, 2024
1 parent 444238b commit 8bb64f5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 24 deletions.
20 changes: 0 additions & 20 deletions src/WinRT.Runtime/Marshalers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1237,11 +1237,6 @@ static class MarshalInspectable<
T>
{
public static IObjectReference CreateMarshaler<V>(
#if NET6_0_OR_GREATER
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)]
#elif NET
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
#endif
T o,
Guid iid,
bool unwrapObject = true)
Expand All @@ -1267,23 +1262,13 @@ public static IObjectReference CreateMarshaler<V>(
}

public static IObjectReference CreateMarshaler(
#if NET6_0_OR_GREATER
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)]
#elif NET
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
#endif
T o,
bool unwrapObject = true)
{
return CreateMarshaler<IInspectable.Vftbl>(o, InterfaceIIDs.IInspectable_IID, unwrapObject);
}

public static ObjectReferenceValue CreateMarshaler2(
#if NET6_0_OR_GREATER
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)]
#elif NET
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
#endif
T o,
Guid iid,
bool unwrapObject = true)
Expand All @@ -1309,11 +1294,6 @@ public static ObjectReferenceValue CreateMarshaler2(
}

public static ObjectReferenceValue CreateMarshaler2(
#if NET6_0_OR_GREATER
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)]
#elif NET
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
#endif
T o, bool unwrapObject = true) => CreateMarshaler2(o, InterfaceIIDs.IInspectable_IID, unwrapObject);

public static IntPtr GetAbi(IObjectReference objRef) =>
Expand Down
4 changes: 2 additions & 2 deletions src/WinRT.Runtime/ObjectReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public ObjectReference<T> As<

public unsafe ObjectReference<T> As<
#if NET
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicConstructors | DynamicallyAccessedMemberTypes.PublicFields)]
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicConstructors)]
#endif
T>(Guid iid)
{
Expand Down Expand Up @@ -173,7 +173,7 @@ public int TryAs<

public virtual unsafe int TryAs<
#if NET
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicConstructors | DynamicallyAccessedMemberTypes.PublicFields)]
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicConstructors)]
#endif
T>(Guid iid, out ObjectReference<T> objRef)
{
Expand Down
3 changes: 1 addition & 2 deletions src/cswinrt/code_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -9647,8 +9647,7 @@ RuntimeHelpers.RunClassConstructor(typeof(%).TypeHandle);
public static IntPtr Make()
{
using var marshaler = MarshalInspectable<%>.CreateMarshaler(_factory).As<ABI.WinRT.Interop.IActivationFactory.Vftbl>();
return marshaler.GetRef();
return MarshalInspectable<%>.CreateMarshaler2(_factory, InterfaceIIDs.IActivationFactory_IID).Detach();
}
static readonly % _factory = new %();
Expand Down

0 comments on commit 8bb64f5

Please sign in to comment.