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

SequentialClass.cs « Attributes.StructLayout « Mono.Linker.Tests.Cases « test - github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fd92a3b6b7ac14c5061605876e7538b63eb3baa1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Runtime.InteropServices;
using Mono.Linker.Tests.Cases.Expectations.Assertions;

namespace Mono.Linker.Tests.Cases.Attributes.StructLayout
{
	[StructLayout (LayoutKind.Sequential)]
	[KeptMember (".ctor()")]
	class SequentialClassData
	{
		[Kept]
		public int never_used;
		[Kept]
		public int used;
	}

	[Kept]
	[StructLayout (LayoutKind.Sequential)]
	class UnallocatedSequentialClassData
	{
		public int never_used;
	}

	[Kept]
	[StructLayout (LayoutKind.Sequential)]
	class UnallocatedButReferencedWithReflectionSequentialClassData
	{
		[Kept]
		public int never_used;
	}

	public class SequentialClass
	{
		[Kept]
		static UnallocatedSequentialClassData _field;

		public static void Main ()
		{
			var c = new SequentialClassData ();
			c.used = 1;
			if (Marshal.SizeOf (c) != 8)
				throw new ApplicationException ();

			_field = null;

			typeof (UnallocatedButReferencedWithReflectionSequentialClassData).ToString ();
		}
	}
}