Skip to content

Enable EnableTrimAnalyzer by default #21293

@rolfbjarne

Description

@rolfbjarne

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).

CC @jonathanpeppers

Metadata

Metadata

Assignees

Labels

enhancementThe issue or pull request is an enhancement

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions