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

[release/8.0] Implement support for InlineArray in the trimmer #92107

Merged
merged 2 commits into from
Sep 15, 2023

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Sep 15, 2023

Backport of #92060 to release/8.0

/cc @vitek-karas

Customer Impact

Without this fix applications using some C# 12 Collection Literals or directly using InlineArrayAttribute may not work when trimmed.

Testing

Added tests for several different cases, both via collection literals as well as direct attribute usage. Verified that a repro app from a user works.

Risk

Low - the change modifies the trimmer to include fields on more types than before. It doesn't remove anything which was not removed before.

IMPORTANT: If this backport is for a servicing release, please verify that:

  • The PR target branch is release/X.0-staging, not release/X.0.

  • If the change touches code that ships in a NuGet package, you have added the necessary package authoring and gotten it explicitly reviewed.

vitek-karas and others added 2 commits September 15, 2023 08:48
Types annotated with `InlineArray` need to preserve all of their fields, even if otherwise this would not be the case. It's possible to have a struct with `LayoutKind.Auto` and with `InlineArray` - trimmer would normally trim fields on such struct. This leads to corruption since the field is never accessed directly.

This changes the marking to preserve all fields on a type with `InlineArray` attribute just like we would for explicit layout struct and similar other types.

Adds tests to cover both the explicit usage of `InlineArray` attribute as well as the compiler generate usage via collection literals.
…rrayDataflow.cs

Co-authored-by: Sven Boemer <sbomer@gmail.com>
@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 Sep 15, 2023
@carlossanlop carlossanlop added area-Tools-ILLink .NET linker development as well as trimming analyzers and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Sep 15, 2023
@ghost
Copy link

ghost commented Sep 15, 2023

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

Issue Details

Backport of #92060 to release/8.0

/cc @vitek-karas

Customer Impact

Without this fix applications using some C# 12 Collection Literals or directly using InlineArrayAttribute may not work when trimmed.

Testing

Added tests for several different cases, both via collection literals as well as direct attribute usage. Verified that a repro app from a user works.

Risk

Low - the change modifies the trimmer to include fields on more types than before. It doesn't remove anything which was not removed before.

IMPORTANT: If this backport is for a servicing release, please verify that:

  • The PR target branch is release/X.0-staging, not release/X.0.

  • If the change touches code that ships in a NuGet package, you have added the necessary package authoring and gotten it explicitly reviewed.

Author: github-actions[bot]
Assignees: -
Labels:

area-Tools-ILLink

Milestone: -

@carlossanlop
Copy link
Member

@agocke @sbomer can we get your code review sign-off in the backport too?

@vitek-karas are the failures related?

@jeffschwMSFT do we have your approval for this?

@carlossanlop carlossanlop added this to the 8.0.0 milestone Sep 15, 2023
Copy link
Member

@sbomer sbomer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test failure is unrelated (see discussion in #91498)

Copy link
Member

@jeffschwMSFT jeffschwMSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved. this can be merged when ready

@jeffschwMSFT jeffschwMSFT added the Servicing-approved Approved for servicing release label Sep 15, 2023
@carlossanlop carlossanlop merged commit e17d2f5 into release/8.0 Sep 15, 2023
@carlossanlop carlossanlop deleted the backport/pr-92060-to-release/8.0 branch September 15, 2023 17:23
@radical radical mentioned this pull request Sep 26, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Oct 15, 2023
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 Servicing-approved Approved for servicing release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants