-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Conversation
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>
Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas Issue DetailsBackport of #92060 to release/8.0 /cc @vitek-karas Customer ImpactWithout this fix applications using some C# 12 Collection Literals or directly using TestingAdded tests for several different cases, both via collection literals as well as direct attribute usage. Verified that a repro app from a user works. RiskLow - 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:
|
@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? |
There was a problem hiding this 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)
There was a problem hiding this 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
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
, notrelease/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.