diff options
author | Michal Strehovský <MichalStrehovsky@users.noreply.github.com> | 2020-07-09 11:48:52 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-09 11:48:52 +0300 |
commit | baeeb1f11dd66c9b97bd0a5e49a01b97e75d496b (patch) | |
tree | fc408163530dc7a3b4579ab6b6283991536c4fca /test/Mono.Linker.Tests.Cases/Attributes.StructLayout | |
parent | 5f7a800978b67b2b089d59aa6a7a50ecc43a216d (diff) |
Keep all fields on sequential/explicit layout classes if a field was kept (#1330)
Should fix the issue observed in CoreLib where `RawData` class is used with `Unsafe.As` to break type safety and linker stripped its fields because it's not seen as instantiated.
Diffstat (limited to 'test/Mono.Linker.Tests.Cases/Attributes.StructLayout')
-rw-r--r-- | test/Mono.Linker.Tests.Cases/Attributes.StructLayout/SequentialClass.cs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/Mono.Linker.Tests.Cases/Attributes.StructLayout/SequentialClass.cs b/test/Mono.Linker.Tests.Cases/Attributes.StructLayout/SequentialClass.cs index fd92a3b6b..f0a4c0072 100644 --- a/test/Mono.Linker.Tests.Cases/Attributes.StructLayout/SequentialClass.cs +++ b/test/Mono.Linker.Tests.Cases/Attributes.StructLayout/SequentialClass.cs @@ -29,11 +29,25 @@ namespace Mono.Linker.Tests.Cases.Attributes.StructLayout public int never_used; } + [Kept] + [StructLayout (LayoutKind.Sequential)] + class UnallocatedButWithSingleFieldUsedSequentialClassData + { + [Kept] + public int never_used; + + [Kept] + public int used; + } + public class SequentialClass { [Kept] static UnallocatedSequentialClassData _field; + [Kept] + static UnallocatedButWithSingleFieldUsedSequentialClassData _otherField; + public static void Main () { var c = new SequentialClassData (); @@ -44,6 +58,10 @@ namespace Mono.Linker.Tests.Cases.Attributes.StructLayout _field = null; typeof (UnallocatedButReferencedWithReflectionSequentialClassData).ToString (); + + if (string.Empty.Length > 0) { + _otherField.used = 123; + } } } } |