You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Linking an empty .NET MAUI app produces inconsistent binaries #86242
Build it for MacCatalyst or iOS, eg. dotnet build -f net8.0-maccatalyst
Check the linked assemblies in obj/Debug/net8.0-maccatalyst/maccatalyst-x64/linked/.
Observations:
In Microsoft.Maui.Controls.dll the INavigation.PopToRootAsync() method is trimmed from the interface.
In Microsoft.Maui.Compatibility.dll the Microsoft.Maui.Controls.Compatibility.Platform.iOS.Platform type keeps an explicit implementation of the INavigation.PopToRootAsync() method.
Expectations:
Either the method is not trimmed from the interface, or all explicit implementations of the method are trimmed too.
I was able to reproduce the issue with the repro that you shared with @vitek-karas. Here's what's happening:
The custom step ManagedRegistrarStep sets the assembly action for Microsoft.Maui.Controls.Compatibility.dll to save (it calls AppBundleRewriter.SaveCurrentAssembly). On its own, this might have been enough to repro the issue because the fix Mark .overrides from marked methods in a copy assembly #82197 doesn't take into account save assemblies - we should probably fix that.
On top of that, MarkStep never marks the Platform implementation of INavigation.PopToRootAsync, because of the custom data DisableMarkingOfCopyAssemblies:
So even if we fix the above, it doesn't help in this case.
I don't have full context, but it seems like the action is set to save because the registrar is injecting UnmanagedCallersOnly trampoline methods for interop. Maybe we should change the behavior of DisableMarkingOfCopyAssemblies so that it doesn't also skip marking of save assemblies. @vitek-karas thoughts?
Before I reported the issue I made sure that it reproduces on stock runtime/linker/workloads. The repro I sent, however, used a new feature introduced in dotnet/macios#18268. In that case the ManagedRegistrarStep is an additional step that takes place in the linker pipeline. It does generate new code and as a consequence changes the action from Copy to Save. Unfortunately that opened a small can of worms, where the behavior of the Save action is sometimes unintuitive or broken.
I suppose that on the stock workload the issue is the use of DisableMarkingOfCopyAssemblies you described. I'll try to selectively disable that and check the output.
I suppose that on the stock workload the issue is the use of DisableMarkingOfCopyAssemblies you described. I'll try to selectively disable that and check the output.
Removing DisableMarkingOfCopyAssemblies (by setting <MarkCopiedAssemblies>true</MarkCopiedAssemblies> in the .csproj file) seems to have solved the issue even for the case with ManagedRegistrarStep.
I was not able reproduce the issue on stock workloads this time. I'm not sure if I accidentally changed something or if it's a result of Tuesday's updates (unlikely). I'll try again tomorrow.
Reacted by Sven Boemer
ghost added
in-prThere is an active PR which will close this issue when it is merged
Activity
sbomer commentedon May 18, 2023
I was able to reproduce the issue with the repro that you shared with @vitek-karas. Here's what's happening:
ManagedRegistrarStepsets the assembly action forMicrosoft.Maui.Controls.Compatibility.dlltosave(it callsAppBundleRewriter.SaveCurrentAssembly). On its own, this might have been enough to repro the issue because the fix Mark .overrides from marked methods in a copy assembly #82197 doesn't take into accountsaveassemblies - we should probably fix that.MarkStepnever marks thePlatformimplementation ofINavigation.PopToRootAsync, because of the custom dataDisableMarkingOfCopyAssemblies:runtime/src/tools/illink/src/linker/Linker.Steps/MarkStep.cs
Line 1414 in f73356c
I don't have full context, but it seems like the action is set to
savebecause the registrar is injectingUnmanagedCallersOnlytrampoline methods for interop. Maybe we should change the behavior ofDisableMarkingOfCopyAssembliesso that it doesn't also skip marking ofsaveassemblies. @vitek-karas thoughts?filipnavara commentedon May 18, 2023
Thanks for analyzing it!
Before I reported the issue I made sure that it reproduces on stock runtime/linker/workloads. The repro I sent, however, used a new feature introduced in dotnet/macios#18268. In that case the
ManagedRegistrarStepis an additional step that takes place in the linker pipeline. It does generate new code and as a consequence changes the action fromCopytoSave. Unfortunately that opened a small can of worms, where the behavior of theSaveaction is sometimes unintuitive or broken.I suppose that on the stock workload the issue is the use of
DisableMarkingOfCopyAssembliesyou described. I'll try to selectively disable that and check the output.filipnavara commentedon May 18, 2023
Removing
DisableMarkingOfCopyAssemblies(by setting<MarkCopiedAssemblies>true</MarkCopiedAssemblies>in the .csproj file) seems to have solved the issue even for the case withManagedRegistrarStep.I was not able reproduce the issue on stock workloads this time. I'm not sure if I accidentally changed something or if it's a result of Tuesday's updates (unlikely). I'll try again tomorrow.