-
Notifications
You must be signed in to change notification settings - Fork 555
[illink] refactor code sharing between ILLink and MSBuild tasks #9688
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
Conversation
We already have a few trimmer steps that run under both ILLink and the `<LinkAssembliesNoShrink/>` MSBuild task: * `AddKeepAlivesStep` * `FixAbstractMethodsStep` * `FixLegacyResourceDesignerStep` We want to move various parts of the build to become new trimmer steps like above. Previously, we also had to share these steps with the Xamarin.Android linker pipeline, but that's no longer the case. We can now cleanup how these trimmer steps are shared between ILLink and MSBuild, reducing the need for `#if ILLINK` in many places. I also removed various Mono linker source code that is unused.
This reverts commit 90dfd12.
This reverts commit 24109de.
class FixLegacyResourceDesignerStep : MonoDroid.Tuner.FixLegacyResourceDesignerStep | ||
{ | ||
readonly DirectoryAssemblyResolver resolver; | ||
readonly TaskLoggingHelper logger; | ||
|
||
public FixLegacyResourceDesignerStep (DirectoryAssemblyResolver resolver, TypeDefinitionCache cache, TaskLoggingHelper logger) | ||
: base(cache) | ||
{ | ||
this.resolver = resolver; | ||
this.logger = logger; | ||
} | ||
|
||
public override void LogMessage (string message) | ||
{ | ||
logger.LogDebugMessage ("{0}", message); | ||
} | ||
|
||
public override void LogError (int code, string message) | ||
{ | ||
logger.LogCodedError ($"XA{code}", message); | ||
} | ||
|
||
public override AssemblyDefinition Resolve (AssemblyNameReference name) | ||
{ | ||
return resolver.Resolve (name); | ||
} | ||
} |
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.
Main benefit is deleting all these.
#if ILLINK | ||
protected override void Process () | ||
{ | ||
cache = Context; | ||
} | ||
#else // !ILLINK | ||
public AddKeepAlivesStep (IMetadataResolver cache) | ||
{ | ||
this.cache = cache; | ||
} | ||
|
||
readonly | ||
#endif // !ILLINK | ||
IMetadataResolver cache; | ||
|
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.
And then removing stuff like this in every shared step.
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.
This looks ok. As long as the tests pass I'm cool 😎
* main: [illink] refactor code sharing between ILLink and MSBuild tasks (#9688)
We already have a few trimmer steps that run under both ILLink and the
<LinkAssembliesNoShrink/>
MSBuild task:AddKeepAlivesStep
FixAbstractMethodsStep
FixLegacyResourceDesignerStep
We want to move various parts of the build to become new trimmer steps like above.
Previously, we also had to share these steps with the Xamarin.Android linker pipeline, but that's no longer the case. We can now cleanup how these trimmer steps are shared between ILLink and MSBuild, reducing the need for
#if ILLINK
in many places.I also removed various Mono linker source code that is unused.