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
The idea is to set EnableTrimAnalyzers=true by default in our targets somewhere, so that customers get trimmer warnings by default in all configurations (even if they've disabled linking in some configurations).
There are a few thoughts here:
Our end goal is a fully trimmable world (100% trimmable won't happen, but we want to get as close as we can).
Mobile projects have been trimmed for many years, and as such mobile developers are more accustomed to trimming than desktop developers. Mobile code base is also often more trimmable than desktop code, for the same reason.
In theory we'd like the trim analyzers to only be enabled when the project trims in any configuration, but we can't reliably detect whether the trimmer is fully enabled (TrimMode=full) in any configuration, any logic to try to reason about this or compute an accurate value is bound to not work for someone, and as the complexity grows, it'll be harder to reason about when the trim analyzers are enabled.
So the proposal is to just set EnableTrimAnalyzers=true by default.
It's very simple.
It's easy to override in a customer's project (set EnableTrimAnalyzers=false).
It hopefully moves us towards a fully trimmable world.
In order to minimize impact, we could enable it early on for .NET 10 to capture feedback. If it turns out too disruptive, we can also back the change out again (which is easy, because it's a very simple change).
So, the project template will have TrimMode=full for both Debug & Release, you get the same warnings on both, and we keep the default behavior of no trimming in Debug mode.
A customer could remove TrimMode=full to get the behavior from .NET 8 or older.
Do we set SuppressTrimAnalysisWarnings to true anywhere - that will effectively disable the analyzer even if EnableTrimAnalyzer is set to true since it will not produce any warnings due to the suppression.
Do we set SuppressTrimAnalysisWarnings to true anywhere - that will effectively disable the analyzer even if EnableTrimAnalyzer is set to true since it will not produce any warnings due to the suppression.
No we don't set SuppressTrimAnalysisWarnings (minor caveat: when building for NativeAOT, we set it to true when running ILLink, and then back to the user's value when running NativeAOT).
Activity
dalexsoto commentedon Sep 24, 2024
Agreed, we should enable this in the early previews of .NET 10 and get feedback if any 👍
jonathanpeppers commentedon Sep 24, 2024
For Android, I think we will have this change in .NET 9 RC 2 (if merged in time):
TrimMode=fullin debug mode, should enable analyzers android#9320So, the project template will have
TrimMode=fullfor both Debug & Release, you get the same warnings on both, and we keep the default behavior of no trimming in Debug mode.A customer could remove
TrimMode=fullto get the behavior from .NET 8 or older.ivanpovazan commentedon Sep 24, 2024
/cc: @vitek-karas @simonrozsival
vitek-karas commentedon Sep 25, 2024
Do we set
SuppressTrimAnalysisWarningsto true anywhere - that will effectively disable the analyzer even ifEnableTrimAnalyzeris set to true since it will not produce any warnings due to the suppression.rolfbjarne commentedon Sep 25, 2024
No we don't set
SuppressTrimAnalysisWarnings(minor caveat: when building for NativeAOT, we set it totruewhen running ILLink, and then back to the user's value when running NativeAOT).[dotnet] Stop suppressing trim analysis warnings. Fixes #21293.
[dotnet] Stop suppressing trim analysis warnings. Fixes #21293. (#21351)
rolfbjarne commentedon Oct 24, 2024
Fixed in .NET 10.