Skip to content

Build failure in net10.0 branch: UITests NativeAOT sample - IL2112 errors with reflection and DynamicallyAccessedMembersAttribute #31222

@rmarinho

Description

@rmarinho

Description

When attempting to build the UITests NativeAOT sample in the net10.0 branch, the build fails with multiple IL2112 errors related to the use of the DynamicallyAccessedMembersAttribute on Maui.Controls.Sample.TestCases.TestCaseScreen. The errors indicate that several fields (such as _filterBugzilla, _filterNone, _filterGitHub, _filterManual, _filter, _issues, _exemptNames) require unreferenced code and are accessed via reflection for test case discovery, which is not compatible with NativeAOT trimming. There is also an IL2111 error for a lambda expression with DynamicallyAccessedMembersAttribute used via reflection.

This blocking issue is preventing UITests NativeAOT sample from building successfully on net10.0.

Example error message:

Error IL2112: 'DynamicallyAccessedMembersAttribute' on 'Maui.Controls.Sample.TestCases.TestCaseScreen' or one of its base types references 'Maui.Controls.Sample.TestCases.TestCaseScreen._filterBugzilla' which requires unreferenced code.  TestCaseScreen uses reflection for test case discovery.

Full error log and additional details are in the build output above.

Steps to Reproduce

  1. Checkout the net10.0 branch.
  2. Build the UITests NativeAOT sample (src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj) for net10.0-ios.
  3. Observe build errors related to IL2112 and IL2111.

Expected: Build should succeed.
Actual: Build fails with trimming/reflection errors.

Link to public reproduction project repository

No response

Version with bug

10.0.0-preview.7

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

net10.0-ios

Did you find any workaround?

None found yet. The issue blocks NativeAOT UITests building in net10.0.

Relevant log output

See error logs in issue description for full details of the IL2112 and IL2111 errors during build.

Metadata

Metadata

Type

Projects

Status

Todo

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions