Skip to content

Commit 1ce2524

Browse files
rolfbjarneCopilot
andcommitted
[dotnet-linker] Only use the new SetTypeMapEntryAssemblyStep on .NET 10.
The step is only needed on .NET 10, so: * Condition the item group in Xamarin.Shared.Sdk.targets on the target framework version being less than 11.0. * Surround the step itself with '#if !NET11_0_OR_GREATER', so that it isn't even compiled on .NET 11+. Also revert the change to tests/common/shared-dotnet.mk, that's fixed in a separate pull request. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3f879a89-7c49-4886-93e9-e43d848c5846
1 parent 4c4ebd7 commit 1ce2524

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

‎dotnet/targets/Xamarin.Shared.Sdk.targets‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,11 +977,13 @@
977977
<_TrimmerCustomSteps Include="$(_AdditionalTaskAssembly)" Type="Xamarin.Linker.DoneStep" Condition="'$(PostProcessAssemblies)' != 'true'" />
978978
</ItemGroup>
979979

980-
<ItemGroup Condition="'$(PrepareAssemblies)' == 'true' And '$(Registrar)' == 'trimmable-static'">
980+
<ItemGroup Condition="'$(PrepareAssemblies)' == 'true' And '$(Registrar)' == 'trimmable-static' And $([MSBuild]::VersionLessThan($(TargetFrameworkVersion), '11.0'))">
981981
<!--
982982
This step must run even when all our other custom steps are disabled (which happens when both
983983
PrepareAssemblies and PostProcessAssemblies are true), because otherwise ILLink will remove the
984984
type map attributes from the type map assemblies the trimmable registrar generated before ILLink ran.
985+
986+
It's not needed on .NET 11+, because there we pass the typemap-entry-assembly argument to ILLink instead.
985987
-->
986988
<_TrimmerCustomSteps Include="$(_AdditionalTaskAssembly)" BeforeStep="MarkStep" Type="Xamarin.Linker.SetTypeMapEntryAssemblyStep" />
987989
</ItemGroup>

‎tests/common/shared-dotnet.mk‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ delete-saved-state:
199199

200200
run-bare: delete-saved-state
201201
$(Q) $(EXECUTABLE) --autostart --autoexit $(RUN_ARGUMENTS)
202-
$(Q) $(MAKE) delete-saved-state RUNTIMEIDENTIFIER= RUNTIMEIDENTIFIERS=
202+
$(Q) $(MAKE) delete-saved-state
203203

204204
# Get the list of applicable simulators, and pick the first in the list.
205205
# Make sure to have a matching simulator runtime installed, otherwise this won't work.

‎tools/dotnet-linker/Steps/SetTypeMapEntryAssemblyStep.cs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4+
// This step is only needed on .NET 10, where ILLink doesn't have the '--typemap-entry-assembly' option.
5+
#if !NET11_0_OR_GREATER
6+
47
using System.IO;
58

69
using Xamarin.Bundler;
@@ -17,8 +20,7 @@ namespace Xamarin.Linker {
1720
// type map assemblies the trimmable registrar generates, leaving the app with empty type maps at runtime.
1821
//
1922
// So tell ILLink about the entry assembly ourselves when ILLink didn't figure it out on its own (in
20-
// .NET 11+ we pass '--typemap-entry-assembly' to ILLink instead, which takes precedence over the entry
21-
// assembly, so there this step does nothing of consequence).
23+
// .NET 11+ we pass '--typemap-entry-assembly' to ILLink instead, so there this step isn't needed at all).
2224
public class SetTypeMapEntryAssemblyStep : ConfigurationAwareStep {
2325
protected override string Name { get; } = "SetTypeMapEntryAssembly";
2426
protected override int ErrorCode { get; } = 2530;
@@ -51,3 +53,5 @@ protected override void TryProcess ()
5153
}
5254
}
5355
}
56+
57+
#endif // !NET11_0_OR_GREATER

0 commit comments

Comments
 (0)