-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fix nested non-byref like VC with no pointer fields
- Loading branch information
1 parent
1335040
commit b1b4d63
Showing
3 changed files
with
115 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
src/tests/Loader/classloader/explicitlayout/objrefandnonobjrefoverlap/case13.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
using Xunit; | ||
|
||
public class Test | ||
{ | ||
public struct WithORefs | ||
{ | ||
public object F; | ||
} | ||
|
||
public struct WithNoORefs | ||
{ | ||
public int F; | ||
} | ||
|
||
public ref struct WithByRefs | ||
{ | ||
public ref int F; | ||
} | ||
|
||
[StructLayout(LayoutKind.Explicit)] | ||
public ref struct Explicit1 | ||
{ | ||
[FieldOffset(0)] public Inner1 Field1; | ||
public ref struct Inner1 | ||
{ | ||
public WithORefs Field2; | ||
} | ||
} | ||
|
||
[StructLayout(LayoutKind.Explicit)] | ||
public ref struct Explicit2 | ||
{ | ||
[FieldOffset(0)] public Inner2 Field1; | ||
public ref struct Inner2 | ||
{ | ||
public WithNoORefs Field2; | ||
} | ||
} | ||
|
||
[StructLayout(LayoutKind.Explicit)] | ||
public ref struct Explicit3 | ||
{ | ||
[FieldOffset(0)] public Inner3 Field1; | ||
public ref struct Inner3 | ||
{ | ||
public WithByRefs Field2; | ||
} | ||
} | ||
|
||
[Fact] | ||
public static void Validate_Explicit1() | ||
{ | ||
Load1(); | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
static string Load1() | ||
{ | ||
return typeof(Explicit1).ToString(); | ||
} | ||
} | ||
|
||
[Fact] | ||
public static void Validate_Explicit2() | ||
{ | ||
Load2(); | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
static string Load2() | ||
{ | ||
return typeof(Explicit2).ToString(); | ||
} | ||
} | ||
|
||
[Fact] | ||
public static void Validate_Explicit3() | ||
{ | ||
Load3(); | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
static string Load3() | ||
{ | ||
return typeof(Explicit3).ToString(); | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/tests/Loader/classloader/explicitlayout/objrefandnonobjrefoverlap/case13.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<OutputType>Exe</OutputType> | ||
<MonoAotIncompatible>false</MonoAotIncompatible> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="case13.cs" /> | ||
</ItemGroup> | ||
</Project> |