Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[illink] consolidate & remove hardcoded assembly names #9662

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

jonathanpeppers
Copy link
Member

@jonathanpeppers jonathanpeppers commented Jan 8, 2025

Our codebase has various notions of "framework assembly", many of which are outdated and wrong!

  • @(_SharedRuntimeAssemblies) in Xamarin.Android.Build.Tasks.targets which generates...

  • src\Xamarin.Android.Build.Tasks\obj\$(Configuration)\Profile.g.cs

  • src\Xamarin.Android.Build.Tasks\Utilities\Profile.cs

  • src\Microsoft.Android.Sdk.ILLink\Profile.cs

The new and correct way to identify a "framework assembly" is to check either:

  • %(FrameworkReferenceName) is Microsoft.Android or starts with Microsoft.NETCore.

  • %(NuGetPackageId) starts with Microsoft.NETCore.App.Runtime. or Microsoft.Android.Runtime.

I moved the new logic into MonoAndroidHelper.IsFrameworkAssembly() and MonoAndroidHelper.IsFromAKnownRuntimePack() (useful for .jar and other files).

For trimmer steps, that won't have ITaskItem, I left an implementation that just checks for: Mono.Android, Mono.Android.Export, and Java.Interop.

I deleted all other instances of Profile.cs, which simplifies how trimmer steps are shared between the <LinkAssembliesNoShrink/> MSBuild task and the trimmer (illink). In these places, we were likely just checking against a stale list of assemblies anyway, so I simply removed all these checks.

Our codebase has various notions of "framework assembly", many of
which are outdated and wrong!

* `@(_SharedRuntimeAssemblies)` in `Xamarin.Android.Build.Tasks.targets`
  which generates...

* `src\Xamarin.Android.Build.Tasks\obj\$(Configuration)\Profile.g.cs`

* src\Xamarin.Android.Build.Tasks\Utilities\Profile.cs

* `src\Microsoft.Android.Sdk.ILLink\Profile.cs`

The new and *correct* way to identify a "framework assembly" is to
check either:

* `%(FrameworkReferenceName)` is `Microsoft.Android` or starts with
  `Microsoft.NETCore.`

* `%(NuGetPackageId)` starts with `Microsoft.NETCore.App.Runtime.` or
  `Microsoft.Android.Runtime.`

I moved the new logic into `MonoAndroidHelper.IsFrameworkAssembly()`
and `MonoAndroidHelper.IsFromAKnownRuntimePack()` (useful for `.jar`
and other files).

I deleted all other instances of `Profile.cs`, which simplifies how
trimmer steps are shared between the `<LinkAssembliesNoShrink/>`
MSBuild task and the trimmer (illink). In these places, we were likely
just checking against a stale list of assemblies *anyway*, so I simply
removed all these checks.
@jonathanpeppers

This comment was marked as outdated.

This comment was marked as outdated.

@jonathanpeppers

This comment was marked as outdated.

This comment was marked as outdated.

@jonathanpeppers
Copy link
Member Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants