Skip to content

Fix trimming test exclusions for iOS/tvOS simulator CoreCLR builds#127465

Open
tarekgh wants to merge 1 commit intodotnet:mainfrom
tarekgh:fix/ios-clr-trimming-test-exclusions
Open

Fix trimming test exclusions for iOS/tvOS simulator CoreCLR builds#127465
tarekgh wants to merge 1 commit intodotnet:mainfrom
tarekgh:fix/ios-clr-trimming-test-exclusions

Conversation

@tarekgh
Copy link
Copy Markdown
Member

@tarekgh tarekgh commented Apr 27, 2026

Note

This PR was AI/Copilot-generated.

Summary

The aggressive trimming test exclusion condition in \src/libraries/tests.proj\ only checked for \ios, \ vos, and \maccatalyst\ TargetOS values, missing \iossimulator\ and \ vossimulator. This caused trimming-sensitive tests to run — and fail — on iOS CoreCLR simulator Release builds where \EnableAggressiveTrimming=true\ was recently enabled by #127054.

Root Cause

PR #127054 (April 20) enabled \EnableAggressiveTrimming=true\ for iOS CoreCLR simulator Release builds. Aggressive trimming strips EventSource reflection metadata (\ParameterInfo[]), causing \PayloadNames\ to throw \NullReferenceException\ when accessed.

The test exclusion at line 381 of \ ests.proj\ had three clauses:

  1. Non-browser AOT builds → catches Mono AOT ✅
  2. Browser/WASM AOT builds → catches WASM ✅
  3. Apple mobile with \BuildTestsOnHelix=true\ → *only checked \ios, \ vos, \maccatalyst*

For simulator builds, \TargetOS\ is \iossimulator\ or \ vossimulator\ (not \ios/\ vos), confirmed by \�ng/RuntimeIdentifier.props:61-63. So the exclusion didn't match, and 8+ trimming-sensitive tests ran and failed with NRE.

Fix

Replace the explicit TargetOS list with the \TargetsAppleMobile\ property (defined in \�ng/OSArch.props), which covers all five Apple mobile targets (\ios, \iossimulator, \ vos, \ vossimulator, \maccatalyst) and is already used elsewhere in the same file (lines 303, 337, 654, 765).

Fixes #127449
Related: #127448 (DI/Hosting failures on same build — same root cause)

The aggressive trimming test exclusion condition in tests.proj only
checked for 'ios', 'tvos', and 'maccatalyst' TargetOS values, missing
'iossimulator' and 'tvossimulator'. This caused trimming-sensitive tests
(EventSource, DI, DiagnosticSource, etc.) to run on iOS CoreCLR simulator
Release builds where EnableAggressiveTrimming=true (added by PR dotnet#127054),
resulting in NullReferenceException failures when trimmed reflection
metadata was accessed.

Replace the explicit TargetOS list with the TargetsAppleMobile property
(defined in eng/OSArch.props) which covers all five Apple mobile targets
and is already used elsewhere in the same file.

Fixes dotnet#127449

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a gap in the libraries test exclusion logic for aggressive trimming scenarios by switching from an explicit TargetOS list (ios/tvos/maccatalyst) to the broader TargetsAppleMobile predicate. This ensures CoreCLR iOS/tvOS simulator Helix builds (where TargetOS is iossimulator / tvossimulator) correctly apply the intended trimming-related project exclusions.

Changes:

  • Replace the Apple-mobile TargetOS disjunction with $(TargetsAppleMobile) == 'true' in the aggressive trimming exclusion condition.
  • Ensure trimming-sensitive test projects are excluded consistently across all Apple mobile TargetOS values (including simulators) when running on Helix.

@tarekgh tarekgh added this to the 11.0.0 milestone Apr 27, 2026
@tarekgh
Copy link
Copy Markdown
Member Author

tarekgh commented Apr 27, 2026

CC @cincuranet @rosebyte @svick

@tarekgh tarekgh added the os-ios Apple iOS label Apr 27, 2026
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to 'os-ios': @vitek-karas, @kotlarmilos, @steveisok, @akoeplinger
See info in area-owners.md if you want to be subscribed.

@tarekgh
Copy link
Copy Markdown
Member Author

tarekgh commented Apr 27, 2026

/azp run runtime-extra-platforms

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

This was referenced Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Logging.EventSource tests failing on iOS with NullReferenceException in OnEventWritten

2 participants