From: Carol Eidt Date: Wed, 20 Jun 2018 18:02:27 +0000 (-0700) Subject: Add another test for dotnet/coreclr#17971 X-Git-Tag: submit/tizen/20210909.063632~11030^2~4554^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e25f939753608e92713ff821f24999ec4ae97956;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Add another test for dotnet/coreclr#17971 Commit migrated from https://github.com/dotnet/coreclr/commit/7f3c57cf30e80a694376e5c112cbb24b9a68886f --- diff --git a/src/coreclr/tests/src/JIT/Methodical/structs/ExplicitLayout.cs b/src/coreclr/tests/src/JIT/Methodical/structs/ExplicitLayout.cs new file mode 100644 index 0000000..c1aa79c --- /dev/null +++ b/src/coreclr/tests/src/JIT/Methodical/structs/ExplicitLayout.cs @@ -0,0 +1,57 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +class ExplicitLayout +{ + [StructLayout(LayoutKind.Explicit, Size = SIZE)] + internal unsafe struct TestStruct + { + public const int SIZE = 32; + + [FieldOffset(0)] + private fixed byte _data[SIZE]; + + [FieldOffset(0), MarshalAs(UnmanagedType.Struct, SizeConst = 16)] + public Guid Guid1; + + [FieldOffset(16), MarshalAs(UnmanagedType.Struct, SizeConst = 16)] + public Guid Guid2; + } + + internal class Program + { + private static int Main() + { + int returnVal = 100; + + TestStruct t = new TestStruct(); + t.Guid1 = Guid.NewGuid(); + t.Guid2 = t.Guid1; + + if (t.Guid1 != t.Guid2) + { + Console.WriteLine("FAIL self-copy"); + returnVal = -1; + } + + TestStruct t2 = new TestStruct(); + Guid newGuid = Guid.NewGuid(); + t2.Guid1 = newGuid; + t2.Guid2 = newGuid; + + if (t2.Guid1 != t2.Guid2) + { + Console.WriteLine("FAIL other-copy"); + returnVal = -1; + } + + return returnVal; + } + } +} diff --git a/src/coreclr/tests/src/JIT/Methodical/structs/ExplicitLayout.csproj b/src/coreclr/tests/src/JIT/Methodical/structs/ExplicitLayout.csproj new file mode 100644 index 0000000..cb869c3 --- /dev/null +++ b/src/coreclr/tests/src/JIT/Methodical/structs/ExplicitLayout.csproj @@ -0,0 +1,36 @@ + + + + + Debug + AnyCPU + 2.0 + {0B8F1AF4-9355-4307-BC68-08A2947AD3B9} + Exe + true + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + 1 + + + + + + PdbOnly + True + + + + False + + + + + + + + + + +