-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Make _TrimmerDefaultAction public #16140
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Why introduce a new property and force the user to understand 2 things? Why wouldn't we just introduce a new
That way I would only need to set 2 properties in my publish script instead of 3:
vs.
|
We don't expect seasonal developers to touch these settings at all. It's something that SDKs will most likely set if they need to. The settings like <TrimMode>link</TrimMode>
<TrimmerDefaultAction>copy</TrimmerDefaultAction> is also valid. |
I agree it would be a nicer UX to have a single property to make it trim everything aggressively, but I don't think there's agreement on this across my team. The That said, I still wanted to explore what it might look like to simplify this. At the implementation level, I don't think we should reuse
You can set If anything I would push for this to be supported in the command-line. Otherwise we tend to get hidden complexity in the MSBuild logic, which can simplify some user scenarios, but makes it hard to understand how the options interact. Here are two options that I could see working:
<TrimMode>link</TrimMode>
<TrimAssemblies>all</TrimAssemblies> <!-- or could be TrimAllAssemblies bool -->
<TrimMode>full</TrimMode>
|
I would suggest I don't know how often users will want to tweak this - but encouraging it to be done at the assembly level through project file action specification is preferably to a big switch that is likely to need exceptions. |
I'm still not convinced the "linkall" is a good idea. Are we expecting people to actually set that so we go the extra length to make it more convenient? If we think so I'd suggest staying from simple wording like |
Fixes dotnet#16140 Relevant for dotnet/docs#23766
* Make TrimmerDefaultAction public Fixes #16140 Relevant for dotnet/docs#23766 * Don't suppress trim warnings when default action is link * Move SuppressTrimAnalysisWarnings to targets So that the condition takes into account properties set in the project file.
Fixes dotnet#16140 Relevant for dotnet/docs#23766
* Make TrimmerDefaultAction public Fixes #16140 Relevant for dotnet/docs#23766 * Don't suppress trim warnings when default action is link * Move SuppressTrimAnalysisWarnings to targets So that the condition takes into account properties set in the project file.
In .NET 6, we are introducing
[assembly: AssemblyMetadata("IsTrimmable", "True")]
as a way to opt a library into trimming. MSBuild metadata can also be used to override this per-assembly.With this change, the linker has two global knobs to control trimming:
--trim-mode
: the trimming granularity for assemblies markedIsTrimmable
copyused
by default, but it is configurable via the propertyTrimMode
--action
: the trimming granularity for assemblies not markedIsTrimmable
copy
by default (so that assemblies which aren't markedIsTrimmable
are kept).We should expose a public MSBuild option that maps to the global
--action
(maybeTrimmerDefaultAction
), which allows developers to enable member-level trimming for the entire application by setting:When we discussed full-app trimming earlier, we were hesitant to make it too easy (see the notes under
TrimAllAssemblies
).On the other hand, the option is already there (introduced in #16094), so the real question is just whether it should be exposed to the user (and if so, what the name should be). Note that xamarin-android already has some user-facing knobs to do exactly this (
<AndroidLinkMode>Full</AndroidLinkMode>
).@marek-safar @vitek-karas @samsp-msft @eerhardt
The text was updated successfully, but these errors were encountered: