Skip to content

Fix IL2087 trim warning in 'ObjectReferenceWithContext<T>' - #1577

Merged
Sergio Pedri (Sergio0694) merged 7 commits into
staging/AOTfrom
user/sergiopedri/fix-obj-ref-trim-warning
Apr 26, 2024
Merged

Sergio Pedri (Sergio0694) merged 7 commits into
staging/AOTfrom
user/sergiopedri/fix-obj-ref-trim-warning

Conversation

@Sergio0694

Copy link
Copy Markdown
Member

Discovered while testing #1573. This PR fixes:

ILC : Trim analysis warning IL2087: WinRT.ObjectReferenceWithContext1.<GetCurrentContext>g__CreateForCurrentContext|19_0(IntPtr): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicFields' in call to 'WinRT.GuidGenerator.GetIID(Type)'. The generic parameter 'T' of 'WinRT.ObjectReferenceWithContext1' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.

Related to: dotnet/runtime#101203.

This PR includes two changes:

  • Add the right annotations to ObjectReferenceWithContext<T>.
  • Pass an IID explicitly wherever possible.

@Sergio0694
Sergio Pedri (Sergio0694) marked this pull request as draft April 18, 2024 22:47
@Sergio0694
Sergio Pedri (Sergio0694) marked this pull request as ready for review April 18, 2024 22:57
@Sergio0694
Sergio Pedri (Sergio0694) force-pushed the user/sergiopedri/fix-obj-ref-trim-warning branch 4 times, most recently from fb6e682 to 088ff41 Compare April 24, 2024 16:45
* Skip closure allocation in ObjectReferenceWithContext<T>

* Remove even more closure allocations in ObjectReferenceWithContext<T> (#1589)

* Skip closures for 'Context.CallInContext' calls

* Use function pointers instead of delegates

* Move context lambda to FOH
@Sergio0694
Sergio Pedri (Sergio0694) force-pushed the user/sergiopedri/fix-obj-ref-trim-warning branch from b3ae801 to 849bc0c Compare April 26, 2024 15:12
@Sergio0694
Sergio Pedri (Sergio0694) merged commit 541747c into staging/AOT Apr 26, 2024
@Sergio0694
Sergio Pedri (Sergio0694) deleted the user/sergiopedri/fix-obj-ref-trim-warning branch April 26, 2024 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants