Skip to content

Commit

Permalink
Fix IL2091 in generated ActivateInstance<T>() (#1449)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 authored Jan 19, 2024
1 parent 0dd0515 commit aff0c34
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/cswinrt/code_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -9653,10 +9653,15 @@ public static IntPtr Make()
}

static readonly % _factory = new %();
public static ObjectReference<I> ActivateInstance<I>()
public static ObjectReference<I> ActivateInstance<
#if NET5_0_OR_GREATER
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicConstructors | DynamicallyAccessedMemberTypes.PublicFields)]
#endif
I>()
{
IntPtr instance = _factory.ActivateInstance();
return ObjectReference<IInspectable.Vftbl>.Attach(ref instance).As<I>();
IntPtr instance = _factory.ActivateInstance();

return ObjectReference<IInspectable.Vftbl>.Attach(ref instance).As<I>();
}

%
Expand Down
1 change: 1 addition & 0 deletions src/cswinrt/type_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
Expand Down

0 comments on commit aff0c34

Please sign in to comment.