Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Strehovský <MichalStrehovsky@users.noreply.github.com>2020-07-09 11:48:52 +0300
committerGitHub <noreply@github.com>2020-07-09 11:48:52 +0300
commitbaeeb1f11dd66c9b97bd0a5e49a01b97e75d496b (patch)
treefc408163530dc7a3b4579ab6b6283991536c4fca /test/Mono.Linker.Tests.Cases/Attributes.StructLayout
parent5f7a800978b67b2b089d59aa6a7a50ecc43a216d (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.cs18
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;
+ }
}
}
}