Based on a comment at dotnet/runtime#49373 (comment). Imagine you have a struct laid out in this fashion.
[StructLayout(LayoutKind.Explicit,Size= ...)]internalstructMyStruct{[FieldOffset(...)]intSomeField;[FieldOffset(...)]intSomeUnusedField;}If SomeUnusedField is never referenced, it should be able to be safely trimmed from the application. This is because removing the unused field will not reorder other fields in the struct (since they all use FieldOffset), not will removing the field affect the overall size of the struct itself (since it has a fixed Size annotation). Currently the trimmer is not taking this opportunity to trim such unused fields.
Edit: This assumes ValueType.Equals and ValueType.GetHashCode are not being called.
Based on a comment at dotnet/runtime#49373 (comment). Imagine you have a struct laid out in this fashion.
If SomeUnusedField is never referenced, it should be able to be safely trimmed from the application. This is because removing the unused field will not reorder other fields in the struct (since they all use FieldOffset), not will removing the field affect the overall size of the struct itself (since it has a fixed Size annotation). Currently the trimmer is not taking this opportunity to trim such unused fields.
Edit: This assumes ValueType.Equals and ValueType.GetHashCode are not being called.