Skip to content

Conversation

@vitek-karas
Copy link
Member

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.

This should resolve the trimming part of #92022
And it also adds tests for #88684

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.
@vitek-karas vitek-karas added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Sep 14, 2023
@vitek-karas vitek-karas self-assigned this Sep 14, 2023
@ghost
Copy link

ghost commented Sep 14, 2023

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

Issue Details

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.

This should resolve the trimming part of #92022
And it also adds tests for #88684

Author: vitek-karas
Assignees: vitek-karas
Labels:

area-Tools-ILLink

Milestone: -

Copy link
Member

@agocke agocke left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

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.

LGTM, thanks!

@vitek-karas
Copy link
Member Author

/backport to release/8.0

@github-actions
Copy link
Contributor

@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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants