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

Trimmer removes InternalsVisibleTo attributes for assemblies which are trimmed #92582

Closed
vitek-karas opened this issue Sep 25, 2023 · 2 comments · Fixed by #98910
Closed

Trimmer removes InternalsVisibleTo attributes for assemblies which are trimmed #92582

vitek-karas opened this issue Sep 25, 2023 · 2 comments · Fixed by #98910
Labels
area-Tools-ILLink .NET linker development as well as trimming analyzers in-pr There is an active PR which will close this issue when it is merged

Comments

@vitek-karas
Copy link
Member

Trimmer has special code to handle InternalsVisibleToAttribute. Specifically, it tries to remove those attribute instances which point to assemblies which either can't be resolved, or which are not kept in the app after trimming.

https://github.com/dotnet/runtime/blob/main/src/tools/illink/src/linker/Linker.Steps/MarkStep.cs#L295-L307

This creates an observable difference in behavior between trimmed and non-trimmed apps without getting a trim analysis warning. The app can use reflection to inspect the InternalsVisibleTo attributes and it will see a different set after trimming.

The trimmer should preserve all InternalsVisibleTo attributes, the size savings are very small.

@vitek-karas vitek-karas added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Sep 25, 2023
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Sep 25, 2023
@ghost
Copy link

ghost commented Sep 25, 2023

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

Issue Details

Trimmer has special code to handle InternalsVisibleToAttribute. Specifically, it tries to remove those attribute instances which point to assemblies which either can't be resolved, or which are not kept in the app after trimming.

https://github.com/dotnet/runtime/blob/main/src/tools/illink/src/linker/Linker.Steps/MarkStep.cs#L295-L307

This creates an observable difference in behavior between trimmed and non-trimmed apps without getting a trim analysis warning. The app can use reflection to inspect the InternalsVisibleTo attributes and it will see a different set after trimming.

The trimmer should preserve all InternalsVisibleTo attributes, the size savings are very small.

Author: vitek-karas
Assignees: -
Labels:

area-Tools-ILLink

Milestone: -

@vitek-karas
Copy link
Member Author

@agocke agocke added this to AppModel Nov 28, 2023
Xtansia added a commit to Xtansia/runtime that referenced this issue Feb 26, 2024
Removes previous special handling to only keep IVT attributes for
assemblies that were resolvable and marked at link time. This behaviour
could cause a noticeable difference in behaviour at runtime without emitting
any trim analysis warnings while providing no mechanism to retain the
attributes. The removal of these attributes provides only a neglible
size reduction.

Fixes dotnet#92582
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Feb 26, 2024
Xtansia added a commit to Xtansia/runtime that referenced this issue Feb 26, 2024
Removes previous special handling to only keep IVT attributes for
assemblies that were resolvable and marked at link time. This behaviour
could cause a noticeable difference in behaviour at runtime without emitting
any trim analysis warnings while providing no mechanism to retain the
attributes. The removal of these attributes provides only a neglible
size reduction.

Fixes dotnet#92582
Xtansia added a commit to Xtansia/runtime that referenced this issue Feb 28, 2024
Removes previous special handling to only keep IVT attributes for
assemblies that were resolvable and marked at link time. This behaviour
could cause a noticeable difference in behaviour at runtime without emitting
any trim analysis warnings while providing no mechanism to retain the
attributes. The removal of these attributes provides only a neglible
size reduction.

Fixes dotnet#92582
Xtansia added a commit to Xtansia/runtime that referenced this issue Mar 3, 2024
Removes previous special handling to only keep IVT attributes for
assemblies that were resolvable and marked at link time. This behaviour
could cause a noticeable difference in behaviour at runtime without emitting
any trim analysis warnings while providing no mechanism to retain the
attributes. The removal of these attributes provides only a neglible
size reduction.

Fixes dotnet#92582
Xtansia added a commit to Xtansia/runtime that referenced this issue Mar 11, 2024
Removes previous special handling to only keep IVT attributes for
assemblies that were resolvable and marked at link time. This behaviour
could cause a noticeable difference in behaviour at runtime without emitting
any trim analysis warnings while providing no mechanism to retain the
attributes. The removal of these attributes provides only a neglible
size reduction.

Fixes dotnet#92582
Xtansia added a commit to Xtansia/runtime that referenced this issue Apr 10, 2024
Removes previous special handling to only keep IVT attributes for
assemblies that were resolvable and marked at link time. This behaviour
could cause a noticeable difference in behaviour at runtime without emitting
any trim analysis warnings while providing no mechanism to retain the
attributes. The removal of these attributes provides only a neglible
size reduction.

Fixes dotnet#92582
Xtansia added a commit to Xtansia/runtime that referenced this issue Apr 10, 2024
Removes previous special handling to only keep IVT attributes for
assemblies that were resolvable and marked at link time. This behaviour
could cause a noticeable difference in behaviour at runtime without emitting
any trim analysis warnings while providing no mechanism to retain the
attributes. The removal of these attributes provides only a neglible
size reduction.

Fixes dotnet#92582
sbomer pushed a commit that referenced this issue Apr 15, 2024
Removes previous special handling to only keep IVT attributes for
assemblies that were resolvable and marked at link time. This behaviour
could cause a noticeable difference in behaviour at runtime without emitting
any trim analysis warnings while providing no mechanism to retain the
attributes. The removal of these attributes provides only a neglible
size reduction.

Fixes #92582
@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Apr 15, 2024
matouskozak pushed a commit to matouskozak/runtime that referenced this issue Apr 30, 2024
…98910)

Removes previous special handling to only keep IVT attributes for
assemblies that were resolvable and marked at link time. This behaviour
could cause a noticeable difference in behaviour at runtime without emitting
any trim analysis warnings while providing no mechanism to retain the
attributes. The removal of these attributes provides only a neglible
size reduction.

Fixes dotnet#92582
@github-actions github-actions bot locked and limited conversation to collaborators May 16, 2024
Ruihan-Yin pushed a commit to Ruihan-Yin/runtime that referenced this issue May 30, 2024
…98910)

Removes previous special handling to only keep IVT attributes for
assemblies that were resolvable and marked at link time. This behaviour
could cause a noticeable difference in behaviour at runtime without emitting
any trim analysis warnings while providing no mechanism to retain the
attributes. The removal of these attributes provides only a neglible
size reduction.

Fixes dotnet#92582
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 in-pr There is an active PR which will close this issue when it is merged
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant