Skip to content

[mobile] Fix IL2007 in System.Runtime.Loader.Tests on non-iOS apple-mobile targets#128186

Closed
kotlarmilos wants to merge 1 commit into
dotnet:mainfrom
kotlarmilos:fix/system-runtime-loader-il2007-maccatalyst
Closed

[mobile] Fix IL2007 in System.Runtime.Loader.Tests on non-iOS apple-mobile targets#128186
kotlarmilos wants to merge 1 commit into
dotnet:mainfrom
kotlarmilos:fix/system-runtime-loader-il2007-maccatalyst

Conversation

@kotlarmilos
Copy link
Copy Markdown
Member

Note

This PR description was drafted with assistance from GitHub Copilot.

Description

Fixes IL2007 build failure in System.Runtime.Loader.Tests on every Apple-mobile target except iOS/tvOS device:

src/libraries/System.Runtime.Loader/tests/ILLink.Descriptors.xml(5,4):
  error IL2007: Could not resolve assembly 'System.Runtime.Loader.Test.Assembly'.
src/libraries/System.Runtime.Loader/tests/ILLink.Descriptors.xml(6,4):
  error IL2007: Could not resolve assembly 'System.Runtime.Loader.Test.Assembly2'.

Reproduces in runtime-extra-platforms legs Build maccatalyst-arm64 Release AllSubsets_CoreCLR, maccatalyst-x64 Release AllSubsets_CoreCLR, iossimulator-arm64/x64 Release AllSubsets_CoreCLR, tvos-arm64 Release AllSubsets_CoreCLR_RuntimeTests. First reproduction on main: build 1403076 (commit 8f854afd60, Apr 30); the build immediately before — 1401195 (9a6034a3ea) — was clean.

Cause

#127058 added two <assembly> entries to the shared ILLink.Descriptors.xml:

<assembly fullname="System.Runtime.Loader.Test.Assembly" />
<assembly fullname="System.Runtime.Loader.Test.Assembly2" />

But the corresponding ProjectReference in System.Runtime.Loader.Tests.csproj only deploys those two assemblies as separate files on iOS/tvOS:

<ProjectReference Condition="'$(TargetOS)' != 'ios' and '$(TargetOS)' != 'tvos'"
                  Include="System.Runtime.Loader.Test.Assembly\..."
                  ReferenceOutputAssembly="false" OutputItemType="EmbeddedResource" />
<ProjectReference Condition="'$(TargetOS)' == 'ios' or '$(TargetOS)' == 'tvos'"
                  Include="System.Runtime.Loader.Test.Assembly\..." />

On every other platform they are embedded resources, so ILLink can't resolve them as standalone assemblies and fails with IL2007 whenever the descriptor is included (i.e. with aggressive trimming).

Fix

Split the two iOS/tvOS-only entries into a sibling ILLink.Descriptors.AppleDevice.xml and <TrimmerRootDescriptor> it only on (TargetOS == 'ios' or TargetOS == 'tvos') && EnableAggressiveTrimming && !UseNativeAotRuntime.

Copilot AI review requested due to automatic review settings May 14, 2026 09:59
@github-actions github-actions Bot added the area-AssemblyLoader-coreclr only use for closed issues label May 14, 2026
@dotnet-policy-service dotnet-policy-service Bot added the linkable-framework Issues associated with delivering a linker friendly framework label May 14, 2026
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

Fixes IL2007 build errors in System.Runtime.Loader.Tests on Apple-mobile targets other than iOS/tvOS device (Mac Catalyst, iOS simulator, tvOS simulator) introduced by #127058. The shared ILLink.Descriptors.xml referenced System.Runtime.Loader.Test.Assembly{,2} as standalone assemblies, but those projects are only deployed as separate files on iOS/tvOS — elsewhere they are embedded resources, so ILLink cannot resolve them.

Changes:

  • Remove the two iOS/tvOS-only entries from the shared ILLink.Descriptors.xml.
  • Add a new ILLink.Descriptors.AppleDevice.xml containing those two entries.
  • Reference the new descriptor from the csproj only on (ios|tvos) && EnableAggressiveTrimming && !UseNativeAotRuntime, matching the ProjectReference deployment conditions.
Show a summary per file
File Description
src/libraries/System.Runtime.Loader/tests/ILLink.Descriptors.xml Removes the two iOS/tvOS-only assembly entries that caused IL2007 elsewhere.
src/libraries/System.Runtime.Loader/tests/ILLink.Descriptors.AppleDevice.xml New descriptor file preserving the two test assemblies under aggressive trimming on iOS/tvOS.
src/libraries/System.Runtime.Loader/tests/System.Runtime.Loader.Tests.csproj Conditionally includes the new descriptor for iOS/tvOS with aggressive trimming (non-NativeAOT).

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 0

@kotlarmilos kotlarmilos force-pushed the fix/system-runtime-loader-il2007-maccatalyst branch from 0020f7c to b0ebf03 Compare May 14, 2026 10:00
…es to iOS/tvOS

These two assemblies are only deployed as separate files on iOS/tvOS
(see csproj ProjectReference conditions); on every other platform
they are embedded resources of the main test assembly. Including
their <assembly> entries in the shared ILLink.Descriptors.xml caused
ILLink to fail with IL2007: 'Could not resolve assembly' on
maccatalyst, iossimulator, and any other target with aggressive
trimming. Move them to a sibling AppleDevice descriptor that is only
included when ProjectReference matches.

Regression from dotnet#127058 (commit d101f76).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-AssemblyLoader-coreclr only use for closed issues linkable-framework Issues associated with delivering a linker friendly framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants