Skip to content

Define UX for IsTrimmable in netstandard2.1 libraries #3175

@sbomer

Description

@sbomer

Context: dotnet/aspnetcore#45879 (comment)

The change to use a TFM-versioned linker (dotnet/sdk#29441) means that the illink targets aren't available for netcoreapp2.1 (or any TFM earlier than 3.0 when trimming was introduced). Those targets include some shared logic (analyzer support, and adding an assembly-level attribute for IsTrimmable).

This is the configuration we shipped in 7.0:
When building a netstandard2.1 app, IsTrimmable turns on the assembly-level attribute. This doesn't enable the analyzer by default, but it can be turned on by EnableTrimAnalyzer. However, the framework ref assemblies aren't annotated in 2.1, so warnings will be incomplete, and library authors will need to compile in the analysis attributes if they want to annotate their own libraries (like we did in dotnet/runtime).

Marking existing APIs as trim-incompatible in a new TFM is effectively introducing a breaking change for trimmed apps/libraries. Our recommendation so far to address this is to multi-target libraries to get the latest analysis warnings. We probably need to make this more explicit in the docs. Even so, it seems easy to fall into this trap by just setting IsTrimmable in a netstandard library that's single-targeted.

The question is: what is the intended UX for this scenario?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions