-
Notifications
You must be signed in to change notification settings - Fork 566
Move FixLegacyResourceDesignerStep to post-trim pipeline #11059
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| using Microsoft.Android.Build.Tasks; | ||
| using Microsoft.Build.Framework; | ||
| using Mono.Cecil; | ||
| using Mono.Linker; | ||
| using MonoDroid.Tuner; | ||
|
|
||
| namespace Xamarin.Android.Tasks; | ||
|
|
@@ -34,6 +35,8 @@ public class PostTrimmingPipeline : AndroidTask | |
|
|
||
| public bool Deterministic { get; set; } | ||
|
|
||
| public bool UseDesignerAssembly { get; set; } | ||
|
|
||
| public override bool RunTask () | ||
| { | ||
| using var resolver = new DirectoryAssemblyResolver ( | ||
|
|
@@ -70,6 +73,15 @@ public override bool RunTask () | |
| }, | ||
| (msg) => Log.LogDebugMessage (msg))); | ||
| } | ||
| if (UseDesignerAssembly) { | ||
| // Create an MSBuildLinkContext so FixLegacyResourceDesignerStep can resolve assemblies | ||
| // and log messages. The resolver is owned by the outer 'using' block, so we intentionally | ||
| // do not dispose this context (LinkContext.Dispose would double-dispose the resolver). | ||
| var linkContext = new MSBuildLinkContext (resolver, Log); | ||
| var fixLegacyStep = new FixLegacyResourceDesignerStep (); | ||
| fixLegacyStep.Initialize (linkContext); | ||
| steps.Add (new PostTrimmingFixLegacyResourceDesignerStep (fixLegacyStep)); | ||
| } | ||
|
Comment on lines
+76
to
+84
|
||
| if (AndroidLinkResources) { | ||
| var allAssemblies = new List<AssemblyDefinition> (Assemblies.Length); | ||
| foreach (var item in Assemblies) { | ||
|
|
@@ -96,3 +108,24 @@ public override bool RunTask () | |
| return !Log.HasLoggedErrors; | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Thin wrapper around <see cref="FixLegacyResourceDesignerStep"/> for the post-trimming pipeline. | ||
| /// Calls <see cref="FixLegacyResourceDesignerStep.ProcessAssemblyDesigner"/> directly, matching the | ||
| /// behavior of the former ILLink path which processed all assemblies without StepContext flag filtering. | ||
| /// Assemblies without a resource designer are skipped internally by ProcessAssemblyDesigner. | ||
| /// </summary> | ||
| class PostTrimmingFixLegacyResourceDesignerStep : IAssemblyModifierPipelineStep | ||
| { | ||
| readonly FixLegacyResourceDesignerStep _inner; | ||
|
|
||
| public PostTrimmingFixLegacyResourceDesignerStep (FixLegacyResourceDesignerStep inner) | ||
| { | ||
| _inner = inner; | ||
| } | ||
|
|
||
| public void ProcessAssembly (AssemblyDefinition assembly, StepContext context) | ||
| { | ||
| context.IsAssemblyModified |= _inner.ProcessAssemblyDesigner (assembly); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using Mono.Linker;appears to be unused in this file (the only Mono.Linker types used are referenced indirectly viaMSBuildLinkContext, which is inXamarin.Android.Tasks). With analyzers enabled, this can surface as IDE0005; consider removing the unused using to keep the file warning-clean.