Skip to content
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

Epic: .NET libraries are annotated to support trimming and we provide trimming guidance for library authors #43543

Closed
3 of 6 tasks
Tracked by #5366
samsp-msft opened this issue Oct 16, 2020 · 5 comments
Assignees
Labels
area-Meta Epic Groups multiple user stories. Can be grouped under a theme. Priority:0 Work that we can't release without Team:Libraries Team:Runtime
Milestone

Comments

@samsp-msft
Copy link
Member

samsp-msft commented Oct 16, 2020

The trimming story is a journey where we are improving the capabilities release to release. With .NET 5, we have added the linker capability for trimming and started the annotation effort for the framework.

For an application to be correctly fully trimmable, we need to know all the places where dynamic code patterns such as reflection and reflection emit are used. Along with that we will provide annotations for the linker so that it knows how to find the required types so that they are not trimmed, provide a source generator equivalent, or if the functionality is inherently supportable in conjunction with trimming then to provide an error to the app developer.

Goals

  • Developers should have clarity on whether the application will be trimmable
  • Trimming should be possible for all mainline scenarios. Work with owners for each of the workloads to:
    • define the mainline scenarios
    • remove / mitigate issues in libraries for the mainline scenarios
    • supply representative apps for validation
  • Linker should produce an error for every case where trimming will fail
  • Remove "Preview" tag from the trimmer
  • Enable trimming for the following app types:
    • Blazor
    • Mobile apps
    • ASP.NET
    • Console apps
    • Ideally an additional UI framework (e.g. WinForms or WPF)

Annotating the framework

This is a recursive initiative as each layer of the onion will potentially increase the surface area that can be trimmable and uncover additional APIs that need to be annotated. Decisions on which APIs should be focused on should be driven by usage stats (if we have them).

Annotating Libraries

Most customer applications make use of libraries from third parties, commonly via NuGet, those also need to be annotated for trimming. We need to provide tooling to assist the developers in determining which of their APIs need to be annotated, and how to annotate them. The current library analysis uses hidden command line switches and needed to be augmented with custom tools created by the engineer currently working on annotations. The experience needs to be exposed in Visual Studio for both library consumers and library authors, with the ability to drill into the specifics of which API dependencies are causing issues.

We will need an outreach program for library authors, and probably have a way to filter out packages that are not trimmable from NuGet searches.

AOT annotations

All the annotations for trimming also assist in native AOT scenarios, as that has the same problem with not being able to determine dependencies when reflection is used. There are some additional limitations of native AOT that needs similar annotations to the attributes used for trimming. This should be added early so that the annotation exercise can consider both scenarios.

User Stories

Issues

Marked with image (see query)

Items not completed in .NET 6

@samsp-msft samsp-msft added area-Meta User Story A single user-facing feature. Can be grouped under an epic. labels Oct 16, 2020
@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label Oct 16, 2020
@samsp-msft
Copy link
Member Author

Tagging: @agocke, @eerhardt, @vitek-karas , @sbomer

@cathysull cathysull added this to Proposed in .NET 6.0 Oct 19, 2020
@samsp-msft samsp-msft changed the title User Story: Annotate more .NET libraries (trimming) and guidance for library authors User Story: .NET libraries are annotated to support trimming and we provide trimming guidance for library authors Oct 22, 2020
@cathysull cathysull added the Priority:0 Work that we can't release without label Oct 30, 2020
@samsp-msft
Copy link
Member Author

We should consolidate with dotnet/aspnetcore#27384, that should probably become a child?

@marek-safar marek-safar removed the untriaged New issue has not been triaged by the area owner label Nov 5, 2020
@marek-safar marek-safar self-assigned this Nov 5, 2020
@danmoseley danmoseley self-assigned this Nov 6, 2020
@samsp-msft samsp-msft changed the title User Story: .NET libraries are annotated to support trimming and we provide trimming guidance for library authors Epic: .NET libraries are annotated to support trimming and we provide trimming guidance for library authors Nov 9, 2020
@samsp-msft samsp-msft added Epic Groups multiple user stories. Can be grouped under a theme. and removed User Story A single user-facing feature. Can be grouped under an epic. labels Nov 9, 2020
@agocke agocke self-assigned this Nov 16, 2020
@vitek-karas
Copy link
Member

To support library authors we will need to have a way to run analyzers to produce the right warnings, both in the IDE (Roslyn analyzers) as well as all up (possibly even the linker in some form).
We need a mechanism to enable the analyzers in the right cases:

  • We want as many libraries to be trim compatible as possible
  • We don't want to start producing lot of warnings by just upgrading

Basically dotnet/sdk#14562 but for libraries.

This applies to other scenarios like single-file, AOT and so on as well.

@danmoseley danmoseley moved this from Proposed to Committed in .NET 6.0 Jan 5, 2021
@ghost ghost added this to Needs triage in Triage POD for Meta, Reflection, etc Jan 29, 2021
@joperezr joperezr moved this from Needs triage to Jose's triage backlog in Triage POD for Meta, Reflection, etc Feb 9, 2021
@joperezr joperezr moved this from Jose's triage backlog to v-Next in Triage POD for Meta, Reflection, etc Feb 9, 2021
@joperezr joperezr added this to the 6.0.0 milestone Feb 9, 2021
@jeffhandley
Copy link
Member

@samsp-msft I updated the description to reflect what made 6.0 and what didn't. I propose that we close this and create a new epic for .NET 7 that captures the items that are carrying over, so that we can reference what was completed in 6.0 and what was cut.

@danmoseley
Copy link
Member

Closing as we are done for 6.0.

.NET 6.0 automation moved this from Committed to Completed Sep 2, 2021
Triage POD for Meta, Reflection, etc automation moved this from Needs consultation to Done Sep 2, 2021
@dotnet dotnet locked as resolved and limited conversation to collaborators Oct 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Meta Epic Groups multiple user stories. Can be grouped under a theme. Priority:0 Work that we can't release without Team:Libraries Team:Runtime
Projects
.NET 6.0
  
Completed
Development

No branches or pull requests