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

Proposal: API for fetching trimming information #109696

Closed
ChrML opened this issue Dec 13, 2023 · 3 comments
Closed

Proposal: API for fetching trimming information #109696

ChrML opened this issue Dec 13, 2023 · 3 comments
Labels
area-Tools-ILLink .NET linker development as well as trimming analyzers

Comments

@ChrML
Copy link

ChrML commented Dec 13, 2023

Background and Motivation

Per today, the C# compiler has a lot of functionality for trimming compiler output to a minimum based on static analysis. E.g. for a Native AOT project.

It's a long shot, but worth asking, would it be feasible to expose some of that functionality to the Roslyn API's? E.g. to use the semantics model to list the static dependencies of a method to other symbols: Method1 depends on Console.WriteLine, String.StartsWith and T:PublicMethods.

It's quite easy to find all symbols referenced by a method, but tracking assignments to e.g. figure out that a statically resolvable Type local needs its public properties preserved from trimming is harder.

I have to admit I have a use-case that is quite special as I've written a C# => Javascript transpiler using Roslyn that is now becoming quite functional with most features to C#11 / .NET7. Being able to use existing functionality to enable users to trim the JS output to a minimum would help :). If not, I might be able to publish it natively with trimming enabled, and enumerate the trimmed DLL symbols to find out what I should include in my JS output. But using an API for this would be cleaner.

Thanks. If there are not other impactful use-cases for this request, feel free to ignore it.

Proposed API

No concrete proposal at this point.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Dec 13, 2023
@RikkiGibson
Copy link
Contributor

Trimming is done by https://github.com/dotnet/runtime/tree/main/src/tools/illink, not in Roslyn.

@arunchndr arunchndr removed the untriaged New issue has not been triaged by the area owner label Nov 6, 2024
@jaredpar jaredpar transferred this issue from dotnet/roslyn Nov 11, 2024
@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Nov 11, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Nov 11, 2024
@jeffschwMSFT jeffschwMSFT added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Nov 11, 2024
Copy link
Contributor

Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas
See info in area-owners.md if you want to be subscribed.

@vcsjones vcsjones removed the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Nov 12, 2024
@agocke
Copy link
Member

agocke commented Nov 21, 2024

Unfortunately there's no way to use Roslyn for this. Trimming analysis requires actual IL, and it requires all the IL in the program. That's why trimming/Native AOT are post-passes that operate on self-contained apps. Trimming and Native AOT can output DGML files that contain a lot of dependency information. I don't know what more info we could provide.

@agocke agocke closed this as not planned Won't fix, can't repro, duplicate, stale Dec 6, 2024
@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Dec 6, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jan 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Tools-ILLink .NET linker development as well as trimming analyzers
Projects
Archived in project
Development

No branches or pull requests

6 participants