diff options
Diffstat (limited to 'tests/src/Loader/classloader/generics/Layout/General')
68 files changed, 6859 insertions, 0 deletions
diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base01a_auto.cs b/tests/src/Loader/classloader/generics/Layout/General/Base01a_auto.cs new file mode 100644 index 0000000000..5a64b9c6d9 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base01a_auto.cs @@ -0,0 +1,232 @@ +// 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.InteropServices; + + + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + + +[StructLayout(LayoutKind.Auto)] +public class GenBase<T> +{ + public T Fld10; + + public int _int0 = 0; + public double _double0 = 0; + public string _string0 = "string0"; + public Guid _Guid0 = new Guid(); + + public T Fld11; + + public int _int1 = int.MaxValue; + public double _double1 = double.MaxValue; + public string _string1 = "string1"; + public Guid _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T Fld12; + + +} + +public class GenInt : GenBase<int> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenDouble: GenBase<double> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenString : GenBase<String> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenObject : GenBase<object> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenGuid : GenBase<Guid> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenConstructedReference : GenBase<RefX1<int>> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenConstructedValue: GenBase<ValX1<string>> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +public class GenInt1DArray : GenBase<int[]> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenString2DArray : GenBase<string[,]> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenIntJaggedArray : GenBase<int[][]> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new GenInt().VerifyLayout(); + new GenDouble().VerifyLayout(); + new GenString().VerifyLayout(); + new GenObject().VerifyLayout(); + new GenGuid().VerifyLayout(); + new GenConstructedReference().VerifyLayout(); + new GenConstructedValue().VerifyLayout(); + new GenInt1DArray().VerifyLayout(); + new GenString2DArray().VerifyLayout(); + new GenIntJaggedArray().VerifyLayout(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base01a_auto.csproj b/tests/src/Loader/classloader/generics/Layout/General/Base01a_auto.csproj new file mode 100644 index 0000000000..6c248cd904 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base01a_auto.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>Base01a_auto</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="Base01a_auto.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base01a_auto_ser.cs b/tests/src/Loader/classloader/generics/Layout/General/Base01a_auto_ser.cs new file mode 100644 index 0000000000..5a64b9c6d9 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base01a_auto_ser.cs @@ -0,0 +1,232 @@ +// 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.InteropServices; + + + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + + +[StructLayout(LayoutKind.Auto)] +public class GenBase<T> +{ + public T Fld10; + + public int _int0 = 0; + public double _double0 = 0; + public string _string0 = "string0"; + public Guid _Guid0 = new Guid(); + + public T Fld11; + + public int _int1 = int.MaxValue; + public double _double1 = double.MaxValue; + public string _string1 = "string1"; + public Guid _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T Fld12; + + +} + +public class GenInt : GenBase<int> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenDouble: GenBase<double> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenString : GenBase<String> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenObject : GenBase<object> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenGuid : GenBase<Guid> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenConstructedReference : GenBase<RefX1<int>> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenConstructedValue: GenBase<ValX1<string>> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +public class GenInt1DArray : GenBase<int[]> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenString2DArray : GenBase<string[,]> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenIntJaggedArray : GenBase<int[][]> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new GenInt().VerifyLayout(); + new GenDouble().VerifyLayout(); + new GenString().VerifyLayout(); + new GenObject().VerifyLayout(); + new GenGuid().VerifyLayout(); + new GenConstructedReference().VerifyLayout(); + new GenConstructedValue().VerifyLayout(); + new GenInt1DArray().VerifyLayout(); + new GenString2DArray().VerifyLayout(); + new GenIntJaggedArray().VerifyLayout(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base01a_auto_ser.csproj b/tests/src/Loader/classloader/generics/Layout/General/Base01a_auto_ser.csproj new file mode 100644 index 0000000000..46df91d85f --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base01a_auto_ser.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>Base01a_auto_ser</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="Base01a_auto_ser.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base01a_seq.cs b/tests/src/Loader/classloader/generics/Layout/General/Base01a_seq.cs new file mode 100644 index 0000000000..fedc682b08 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base01a_seq.cs @@ -0,0 +1,232 @@ +// 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.InteropServices; + + + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + + +[StructLayout(LayoutKind.Sequential)] +public class GenBase<T> +{ + public T Fld10; + + public int _int0 = 0; + public double _double0 = 0; + public string _string0 = "string0"; + public Guid _Guid0 = new Guid(); + + public T Fld11; + + public int _int1 = int.MaxValue; + public double _double1 = double.MaxValue; + public string _string1 = "string1"; + public Guid _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T Fld12; + + +} + +public class GenInt : GenBase<int> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenDouble: GenBase<double> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenString : GenBase<String> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenObject : GenBase<object> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenGuid : GenBase<Guid> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenConstructedReference : GenBase<RefX1<int>> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenConstructedValue: GenBase<ValX1<string>> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +public class GenInt1DArray : GenBase<int[]> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenString2DArray : GenBase<string[,]> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenIntJaggedArray : GenBase<int[][]> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new GenInt().VerifyLayout(); + new GenDouble().VerifyLayout(); + new GenString().VerifyLayout(); + new GenObject().VerifyLayout(); + new GenGuid().VerifyLayout(); + new GenConstructedReference().VerifyLayout(); + new GenConstructedValue().VerifyLayout(); + new GenInt1DArray().VerifyLayout(); + new GenString2DArray().VerifyLayout(); + new GenIntJaggedArray().VerifyLayout(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base01a_seq.csproj b/tests/src/Loader/classloader/generics/Layout/General/Base01a_seq.csproj new file mode 100644 index 0000000000..dc12d9cd48 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base01a_seq.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>Base01a_seq</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="Base01a_seq.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base01a_seq_ser.cs b/tests/src/Loader/classloader/generics/Layout/General/Base01a_seq_ser.cs new file mode 100644 index 0000000000..fedc682b08 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base01a_seq_ser.cs @@ -0,0 +1,232 @@ +// 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.InteropServices; + + + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + + +[StructLayout(LayoutKind.Sequential)] +public class GenBase<T> +{ + public T Fld10; + + public int _int0 = 0; + public double _double0 = 0; + public string _string0 = "string0"; + public Guid _Guid0 = new Guid(); + + public T Fld11; + + public int _int1 = int.MaxValue; + public double _double1 = double.MaxValue; + public string _string1 = "string1"; + public Guid _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T Fld12; + + +} + +public class GenInt : GenBase<int> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenDouble: GenBase<double> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenString : GenBase<String> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenObject : GenBase<object> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenGuid : GenBase<Guid> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenConstructedReference : GenBase<RefX1<int>> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenConstructedValue: GenBase<ValX1<string>> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +public class GenInt1DArray : GenBase<int[]> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenString2DArray : GenBase<string[,]> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class GenIntJaggedArray : GenBase<int[][]> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new GenInt().VerifyLayout(); + new GenDouble().VerifyLayout(); + new GenString().VerifyLayout(); + new GenObject().VerifyLayout(); + new GenGuid().VerifyLayout(); + new GenConstructedReference().VerifyLayout(); + new GenConstructedValue().VerifyLayout(); + new GenInt1DArray().VerifyLayout(); + new GenString2DArray().VerifyLayout(); + new GenIntJaggedArray().VerifyLayout(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base01a_seq_ser.csproj b/tests/src/Loader/classloader/generics/Layout/General/Base01a_seq_ser.csproj new file mode 100644 index 0000000000..7382a93218 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base01a_seq_ser.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>Base01a_seq_ser</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="Base01a_seq_ser.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base01b_auto_ser.cs b/tests/src/Loader/classloader/generics/Layout/General/Base01b_auto_ser.cs new file mode 100644 index 0000000000..9011ac1a16 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base01b_auto_ser.cs @@ -0,0 +1,241 @@ +// 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.InteropServices; + + + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + + +[StructLayout(LayoutKind.Auto)] +public class GenBase<T> +{ + public T Fld10; + + public int _int0 = 0; + public double _double0 = 0; + public string _string0 = "string0"; + public Guid _Guid0 = new Guid(); + + public T Fld11; + + public int _int1 = int.MaxValue; + public double _double1 = double.MaxValue; + public string _string1 = "string1"; + public Guid _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T Fld12; + + +} + + +public class GenInt : GenBase<int> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +public class GenDouble: GenBase<double> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +public class GenString : GenBase<String> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +public class GenObject : GenBase<object> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +public class GenGuid : GenBase<Guid> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +public class GenConstructedReference : GenBase<RefX1<int>> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +public class GenConstructedValue: GenBase<ValX1<string>> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +public class GenInt1DArray : GenBase<int[]> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +public class GenString2DArray : GenBase<string[,]> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +public class GenIntJaggedArray : GenBase<int[][]> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new GenInt().VerifyLayout(); + new GenDouble().VerifyLayout(); + new GenString().VerifyLayout(); + new GenObject().VerifyLayout(); + new GenGuid().VerifyLayout(); + new GenConstructedReference().VerifyLayout(); + new GenConstructedValue().VerifyLayout(); + new GenInt1DArray().VerifyLayout(); + new GenString2DArray().VerifyLayout(); + new GenIntJaggedArray().VerifyLayout(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base01b_auto_ser.csproj b/tests/src/Loader/classloader/generics/Layout/General/Base01b_auto_ser.csproj new file mode 100644 index 0000000000..e5a72965f5 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base01b_auto_ser.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>Base01b_auto_ser</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="Base01b_auto_ser.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base01b_seq.cs b/tests/src/Loader/classloader/generics/Layout/General/Base01b_seq.cs new file mode 100644 index 0000000000..fbf274b9d1 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base01b_seq.cs @@ -0,0 +1,241 @@ +// 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.InteropServices; + + + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + + +[StructLayout(LayoutKind.Sequential)] +public class GenBase<T> +{ + public T Fld10; + + public int _int0 = 0; + public double _double0 = 0; + public string _string0 = "string0"; + public Guid _Guid0 = new Guid(); + + public T Fld11; + + public int _int1 = int.MaxValue; + public double _double1 = double.MaxValue; + public string _string1 = "string1"; + public Guid _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T Fld12; + + +} + +[StructLayout(LayoutKind.Sequential)] +public class GenInt : GenBase<int> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +[StructLayout(LayoutKind.Sequential)] +public class GenDouble: GenBase<double> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +[StructLayout(LayoutKind.Sequential)] +public class GenString : GenBase<String> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +[StructLayout(LayoutKind.Sequential)] +public class GenObject : GenBase<object> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +[StructLayout(LayoutKind.Sequential)] +public class GenGuid : GenBase<Guid> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +[StructLayout(LayoutKind.Sequential)] +public class GenConstructedReference : GenBase<RefX1<int>> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +[StructLayout(LayoutKind.Sequential)] +public class GenConstructedValue: GenBase<ValX1<string>> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +[StructLayout(LayoutKind.Sequential)] +public class GenInt1DArray : GenBase<int[]> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +[StructLayout(LayoutKind.Sequential)] +public class GenString2DArray : GenBase<string[,]> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +[StructLayout(LayoutKind.Sequential)] +public class GenIntJaggedArray : GenBase<int[][]> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new GenInt().VerifyLayout(); + new GenDouble().VerifyLayout(); + new GenString().VerifyLayout(); + new GenObject().VerifyLayout(); + new GenGuid().VerifyLayout(); + new GenConstructedReference().VerifyLayout(); + new GenConstructedValue().VerifyLayout(); + new GenInt1DArray().VerifyLayout(); + new GenString2DArray().VerifyLayout(); + new GenIntJaggedArray().VerifyLayout(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base01b_seq.csproj b/tests/src/Loader/classloader/generics/Layout/General/Base01b_seq.csproj new file mode 100644 index 0000000000..85171c1810 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base01b_seq.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>Base01b_seq</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="Base01b_seq.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base01b_seq_ser.cs b/tests/src/Loader/classloader/generics/Layout/General/Base01b_seq_ser.cs new file mode 100644 index 0000000000..f7ffd00170 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base01b_seq_ser.cs @@ -0,0 +1,242 @@ +// 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.InteropServices; + + + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + + +[StructLayout(LayoutKind.Sequential)] +public class GenBase<T> +{ + public T Fld10; + + public int _int0 = 0; + public double _double0 = 0; + public string _string0 = "string0"; + public Guid _Guid0 = new Guid(); + + public T Fld11; + + public int _int1 = int.MaxValue; + public double _double1 = double.MaxValue; + public string _string1 = "string1"; + public Guid _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T Fld12; + + +} + +[StructLayout(LayoutKind.Sequential)] +public class GenInt : GenBase<int> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +[StructLayout(LayoutKind.Sequential)] +public class GenDouble: GenBase<double> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +[StructLayout(LayoutKind.Sequential)] +public class GenString : GenBase<String> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +[StructLayout(LayoutKind.Sequential)] +public class GenObject : GenBase<object> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +[StructLayout(LayoutKind.Sequential)] +public class GenGuid : GenBase<Guid> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +[StructLayout(LayoutKind.Sequential)] +public class GenConstructedReference : GenBase<RefX1<int>> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +[StructLayout(LayoutKind.Sequential)] +public class GenConstructedValue: GenBase<ValX1<string>> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +[StructLayout(LayoutKind.Sequential)] +public class GenInt1DArray : GenBase<int[]> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +[StructLayout(LayoutKind.Sequential)] +public class GenString2DArray : GenBase<string[,]> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +[StructLayout(LayoutKind.Sequential)] +public class GenIntJaggedArray : GenBase<int[][]> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new GenInt().VerifyLayout(); + new GenDouble().VerifyLayout(); + new GenString().VerifyLayout(); + new GenObject().VerifyLayout(); + new GenGuid().VerifyLayout(); + new GenConstructedReference().VerifyLayout(); + new GenConstructedValue().VerifyLayout(); + new GenInt1DArray().VerifyLayout(); + new GenString2DArray().VerifyLayout(); + new GenIntJaggedArray().VerifyLayout(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base01b_seq_ser.csproj b/tests/src/Loader/classloader/generics/Layout/General/Base01b_seq_ser.csproj new file mode 100644 index 0000000000..29c8073eed --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base01b_seq_ser.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>Base01b_seq_ser</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="Base01b_seq_ser.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base01c_seq_ser.cs b/tests/src/Loader/classloader/generics/Layout/General/Base01c_seq_ser.cs new file mode 100644 index 0000000000..4a5cd36d8f --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base01c_seq_ser.cs @@ -0,0 +1,251 @@ +// 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.InteropServices; + + + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + + +[StructLayout(LayoutKind.Sequential)] +public class GenBase<T> +{ + public T Fld10; + + public int _int0 = 0; + public double _double0 = 0; + public string _string0 = "string0"; + public Guid _Guid0 = new Guid(); + + public T Fld11; + + public int _int1 = int.MaxValue; + public double _double1 = double.MaxValue; + public string _string1 = "string1"; + public Guid _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T Fld12; + + +} + + +[StructLayout(LayoutKind.Sequential)] +public class GenInt : GenBase<int> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +[StructLayout(LayoutKind.Sequential)] +public class GenDouble: GenBase<double> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +[StructLayout(LayoutKind.Sequential)] +public class GenString : GenBase<String> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +[StructLayout(LayoutKind.Sequential)] +public class GenObject : GenBase<object> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +[StructLayout(LayoutKind.Sequential)] +public class GenGuid : GenBase<Guid> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +[StructLayout(LayoutKind.Sequential)] +public class GenConstructedReference : GenBase<RefX1<int>> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +[StructLayout(LayoutKind.Sequential)] +public class GenConstructedValue: GenBase<ValX1<string>> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +[StructLayout(LayoutKind.Sequential)] +public class GenInt1DArray : GenBase<int[]> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +[StructLayout(LayoutKind.Sequential)] +public class GenString2DArray : GenBase<string[,]> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +[StructLayout(LayoutKind.Sequential)] +public class GenIntJaggedArray : GenBase<int[][]> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new GenInt().VerifyLayout(); + new GenDouble().VerifyLayout(); + new GenString().VerifyLayout(); + new GenObject().VerifyLayout(); + new GenGuid().VerifyLayout(); + new GenConstructedReference().VerifyLayout(); + new GenConstructedValue().VerifyLayout(); + new GenInt1DArray().VerifyLayout(); + new GenString2DArray().VerifyLayout(); + new GenIntJaggedArray().VerifyLayout(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base01c_seq_ser.csproj b/tests/src/Loader/classloader/generics/Layout/General/Base01c_seq_ser.csproj new file mode 100644 index 0000000000..ad448301cb --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base01c_seq_ser.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>Base01c_seq_ser</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="Base01c_seq_ser.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base01d_seq_ser.cs b/tests/src/Loader/classloader/generics/Layout/General/Base01d_seq_ser.cs new file mode 100644 index 0000000000..9407aff9a7 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base01d_seq_ser.cs @@ -0,0 +1,251 @@ +// 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.InteropServices; + + + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + + +[StructLayout(LayoutKind.Sequential)] +public class GenBase<T> +{ + public T Fld10; + + public int _int0 = 0; + public double _double0 = 0; + public string _string0 = "string0"; + public Guid _Guid0 = new Guid(); + + public T Fld11; + + public int _int1 = int.MaxValue; + public double _double1 = double.MaxValue; + public string _string1 = "string1"; + public Guid _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T Fld12; + + +} + + +[StructLayout(LayoutKind.Explicit)] +public class GenInt : GenBase<int> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +[StructLayout(LayoutKind.Explicit)] +public class GenDouble: GenBase<double> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +[StructLayout(LayoutKind.Explicit)] +public class GenString : GenBase<String> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +[StructLayout(LayoutKind.Explicit)] +public class GenObject : GenBase<object> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +[StructLayout(LayoutKind.Explicit)] +public class GenGuid : GenBase<Guid> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +[StructLayout(LayoutKind.Explicit)] +public class GenConstructedReference : GenBase<RefX1<int>> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +[StructLayout(LayoutKind.Explicit)] +public class GenConstructedValue: GenBase<ValX1<string>> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +[StructLayout(LayoutKind.Explicit)] +public class GenInt1DArray : GenBase<int[]> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +[StructLayout(LayoutKind.Explicit)] +public class GenString2DArray : GenBase<string[,]> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +[StructLayout(LayoutKind.Explicit)] +public class GenIntJaggedArray : GenBase<int[][]> +{ + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(base._string0.Equals("string0")); + Test.Eval(base._string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new GenInt().VerifyLayout(); + new GenDouble().VerifyLayout(); + new GenString().VerifyLayout(); + new GenObject().VerifyLayout(); + new GenGuid().VerifyLayout(); + new GenConstructedReference().VerifyLayout(); + new GenConstructedValue().VerifyLayout(); + new GenInt1DArray().VerifyLayout(); + new GenString2DArray().VerifyLayout(); + new GenIntJaggedArray().VerifyLayout(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base01d_seq_ser.csproj b/tests/src/Loader/classloader/generics/Layout/General/Base01d_seq_ser.csproj new file mode 100644 index 0000000000..82200ebf45 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base01d_seq_ser.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>Base01d_seq_ser</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="Base01d_seq_ser.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base02a_auto.cs b/tests/src/Loader/classloader/generics/Layout/General/Base02a_auto.cs new file mode 100644 index 0000000000..c9f4ca3aa4 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base02a_auto.cs @@ -0,0 +1,138 @@ +// 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.InteropServices; + + + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + + +[StructLayout(LayoutKind.Auto)] +public class GenBase<T> +{ + public T Fld10; + + public int _int0 = 0; + public double _double0 = 0; + public string _string0 = "string0"; + public Guid _Guid0 = new Guid(); + + public T Fld11; + + public int _int1 = int.MaxValue; + public double _double1 = double.MaxValue; + public string _string1 = "string1"; + public Guid _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T Fld12; + + public virtual void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(_string0.Equals("string0")); + Test.Eval(_string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +public class Gen<T> : GenBase<T> +{ + public T sFld10; + + public int _sint0 = 0; + public double _sdouble0 = 0; + public string _sstring0 = "string0"; + public Guid _sGuid0 = new Guid(); + + public T sFld11; + + public int _sint1 = int.MaxValue; + public double _sdouble1 = double.MaxValue; + public string _sstring1 = "string1"; + public Guid _sGuid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T sFld12; + + public override void VerifyLayout() + { + base.VerifyLayout(); + Test.Eval(_sint0 == 0); + Test.Eval(_sint1 == int.MaxValue) ; + Test.Eval(_sdouble0 == 0) ; + Test.Eval(_sdouble1 == double.MaxValue) ; + Test.Eval(_sstring0.Equals("string0")); + Test.Eval(_sstring1.Equals("string1")); + Test.Eval(_sGuid0 == new Guid()); + Test.Eval(_sGuid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } + +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new Gen<int>().VerifyLayout(); + new Gen<double>().VerifyLayout(); + new Gen<string>().VerifyLayout(); + new Gen<object>().VerifyLayout(); + new Gen<Guid>().VerifyLayout(); + + new Gen<int[]>().VerifyLayout(); + new Gen<double[,]>().VerifyLayout(); + new Gen<string[][][]>().VerifyLayout(); + new Gen<object[,,,]>().VerifyLayout(); + new Gen<Guid[][,,,][]>().VerifyLayout(); + + new Gen<RefX1<int>[]>().VerifyLayout(); + new Gen<RefX1<double>[,]>().VerifyLayout(); + new Gen<RefX1<string>[][][]>().VerifyLayout(); + new Gen<RefX1<object>[,,,]>().VerifyLayout(); + new Gen<RefX1<Guid>[][,,,][]>().VerifyLayout(); + + new Gen<ValX1<int>[]>().VerifyLayout(); + new Gen<ValX1<double>[,]>().VerifyLayout(); + new Gen<ValX1<string>[][][]>().VerifyLayout(); + new Gen<ValX1<object>[,,,]>().VerifyLayout(); + new Gen<ValX1<Guid>[][,,,][]>().VerifyLayout(); + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base02a_auto.csproj b/tests/src/Loader/classloader/generics/Layout/General/Base02a_auto.csproj new file mode 100644 index 0000000000..d137ab7b65 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base02a_auto.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>Base02a_auto</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="Base02a_auto.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base02a_auto_ser.cs b/tests/src/Loader/classloader/generics/Layout/General/Base02a_auto_ser.cs new file mode 100644 index 0000000000..c9f4ca3aa4 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base02a_auto_ser.cs @@ -0,0 +1,138 @@ +// 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.InteropServices; + + + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + + +[StructLayout(LayoutKind.Auto)] +public class GenBase<T> +{ + public T Fld10; + + public int _int0 = 0; + public double _double0 = 0; + public string _string0 = "string0"; + public Guid _Guid0 = new Guid(); + + public T Fld11; + + public int _int1 = int.MaxValue; + public double _double1 = double.MaxValue; + public string _string1 = "string1"; + public Guid _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T Fld12; + + public virtual void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(_string0.Equals("string0")); + Test.Eval(_string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +public class Gen<T> : GenBase<T> +{ + public T sFld10; + + public int _sint0 = 0; + public double _sdouble0 = 0; + public string _sstring0 = "string0"; + public Guid _sGuid0 = new Guid(); + + public T sFld11; + + public int _sint1 = int.MaxValue; + public double _sdouble1 = double.MaxValue; + public string _sstring1 = "string1"; + public Guid _sGuid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T sFld12; + + public override void VerifyLayout() + { + base.VerifyLayout(); + Test.Eval(_sint0 == 0); + Test.Eval(_sint1 == int.MaxValue) ; + Test.Eval(_sdouble0 == 0) ; + Test.Eval(_sdouble1 == double.MaxValue) ; + Test.Eval(_sstring0.Equals("string0")); + Test.Eval(_sstring1.Equals("string1")); + Test.Eval(_sGuid0 == new Guid()); + Test.Eval(_sGuid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } + +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new Gen<int>().VerifyLayout(); + new Gen<double>().VerifyLayout(); + new Gen<string>().VerifyLayout(); + new Gen<object>().VerifyLayout(); + new Gen<Guid>().VerifyLayout(); + + new Gen<int[]>().VerifyLayout(); + new Gen<double[,]>().VerifyLayout(); + new Gen<string[][][]>().VerifyLayout(); + new Gen<object[,,,]>().VerifyLayout(); + new Gen<Guid[][,,,][]>().VerifyLayout(); + + new Gen<RefX1<int>[]>().VerifyLayout(); + new Gen<RefX1<double>[,]>().VerifyLayout(); + new Gen<RefX1<string>[][][]>().VerifyLayout(); + new Gen<RefX1<object>[,,,]>().VerifyLayout(); + new Gen<RefX1<Guid>[][,,,][]>().VerifyLayout(); + + new Gen<ValX1<int>[]>().VerifyLayout(); + new Gen<ValX1<double>[,]>().VerifyLayout(); + new Gen<ValX1<string>[][][]>().VerifyLayout(); + new Gen<ValX1<object>[,,,]>().VerifyLayout(); + new Gen<ValX1<Guid>[][,,,][]>().VerifyLayout(); + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base02a_auto_ser.csproj b/tests/src/Loader/classloader/generics/Layout/General/Base02a_auto_ser.csproj new file mode 100644 index 0000000000..6997ce8acf --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base02a_auto_ser.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>Base02a_auto_ser</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="Base02a_auto_ser.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base02a_seq.cs b/tests/src/Loader/classloader/generics/Layout/General/Base02a_seq.cs new file mode 100644 index 0000000000..adb0de509a --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base02a_seq.cs @@ -0,0 +1,137 @@ +// 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.InteropServices; + + + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + +[StructLayout(LayoutKind.Sequential)] +public class GenBase<T> +{ + public T Fld10; + + public int _int0 = 0; + public double _double0 = 0; + public string _string0 = "string0"; + public Guid _Guid0 = new Guid(); + + public T Fld11; + + public int _int1 = int.MaxValue; + public double _double1 = double.MaxValue; + public string _string1 = "string1"; + public Guid _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T Fld12; + + public virtual void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(_string0.Equals("string0")); + Test.Eval(_string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +public class Gen<T> : GenBase<T> +{ + public T sFld10; + + public int _sint0 = 0; + public double _sdouble0 = 0; + public string _sstring0 = "string0"; + public Guid _sGuid0 = new Guid(); + + public T sFld11; + + public int _sint1 = int.MaxValue; + public double _sdouble1 = double.MaxValue; + public string _sstring1 = "string1"; + public Guid _sGuid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T sFld12; + + public override void VerifyLayout() + { + base.VerifyLayout(); + Test.Eval(_sint0 == 0); + Test.Eval(_sint1 == int.MaxValue) ; + Test.Eval(_sdouble0 == 0) ; + Test.Eval(_sdouble1 == double.MaxValue) ; + Test.Eval(_sstring0.Equals("string0")); + Test.Eval(_sstring1.Equals("string1")); + Test.Eval(_sGuid0 == new Guid()); + Test.Eval(_sGuid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } + +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new Gen<int>().VerifyLayout(); + new Gen<double>().VerifyLayout(); + new Gen<string>().VerifyLayout(); + new Gen<object>().VerifyLayout(); + new Gen<Guid>().VerifyLayout(); + + new Gen<int[]>().VerifyLayout(); + new Gen<double[,]>().VerifyLayout(); + new Gen<string[][][]>().VerifyLayout(); + new Gen<object[,,,]>().VerifyLayout(); + new Gen<Guid[][,,,][]>().VerifyLayout(); + + new Gen<RefX1<int>[]>().VerifyLayout(); + new Gen<RefX1<double>[,]>().VerifyLayout(); + new Gen<RefX1<string>[][][]>().VerifyLayout(); + new Gen<RefX1<object>[,,,]>().VerifyLayout(); + new Gen<RefX1<Guid>[][,,,][]>().VerifyLayout(); + + new Gen<ValX1<int>[]>().VerifyLayout(); + new Gen<ValX1<double>[,]>().VerifyLayout(); + new Gen<ValX1<string>[][][]>().VerifyLayout(); + new Gen<ValX1<object>[,,,]>().VerifyLayout(); + new Gen<ValX1<Guid>[][,,,][]>().VerifyLayout(); + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base02a_seq.csproj b/tests/src/Loader/classloader/generics/Layout/General/Base02a_seq.csproj new file mode 100644 index 0000000000..89546af6b3 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base02a_seq.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>Base02a_seq</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="Base02a_seq.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base02a_seq_ser.cs b/tests/src/Loader/classloader/generics/Layout/General/Base02a_seq_ser.cs new file mode 100644 index 0000000000..71c69bdb59 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base02a_seq_ser.cs @@ -0,0 +1,138 @@ +// 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.InteropServices; + + + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + + +[StructLayout(LayoutKind.Sequential)] +public class GenBase<T> +{ + public T Fld10; + + public int _int0 = 0; + public double _double0 = 0; + public string _string0 = "string0"; + public Guid _Guid0 = new Guid(); + + public T Fld11; + + public int _int1 = int.MaxValue; + public double _double1 = double.MaxValue; + public string _string1 = "string1"; + public Guid _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T Fld12; + + public virtual void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(_string0.Equals("string0")); + Test.Eval(_string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +public class Gen<T> : GenBase<T> +{ + public T sFld10; + + public int _sint0 = 0; + public double _sdouble0 = 0; + public string _sstring0 = "string0"; + public Guid _sGuid0 = new Guid(); + + public T sFld11; + + public int _sint1 = int.MaxValue; + public double _sdouble1 = double.MaxValue; + public string _sstring1 = "string1"; + public Guid _sGuid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T sFld12; + + public override void VerifyLayout() + { + base.VerifyLayout(); + Test.Eval(_sint0 == 0); + Test.Eval(_sint1 == int.MaxValue) ; + Test.Eval(_sdouble0 == 0) ; + Test.Eval(_sdouble1 == double.MaxValue) ; + Test.Eval(_sstring0.Equals("string0")); + Test.Eval(_sstring1.Equals("string1")); + Test.Eval(_sGuid0 == new Guid()); + Test.Eval(_sGuid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } + +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new Gen<int>().VerifyLayout(); + new Gen<double>().VerifyLayout(); + new Gen<string>().VerifyLayout(); + new Gen<object>().VerifyLayout(); + new Gen<Guid>().VerifyLayout(); + + new Gen<int[]>().VerifyLayout(); + new Gen<double[,]>().VerifyLayout(); + new Gen<string[][][]>().VerifyLayout(); + new Gen<object[,,,]>().VerifyLayout(); + new Gen<Guid[][,,,][]>().VerifyLayout(); + + new Gen<RefX1<int>[]>().VerifyLayout(); + new Gen<RefX1<double>[,]>().VerifyLayout(); + new Gen<RefX1<string>[][][]>().VerifyLayout(); + new Gen<RefX1<object>[,,,]>().VerifyLayout(); + new Gen<RefX1<Guid>[][,,,][]>().VerifyLayout(); + + new Gen<ValX1<int>[]>().VerifyLayout(); + new Gen<ValX1<double>[,]>().VerifyLayout(); + new Gen<ValX1<string>[][][]>().VerifyLayout(); + new Gen<ValX1<object>[,,,]>().VerifyLayout(); + new Gen<ValX1<Guid>[][,,,][]>().VerifyLayout(); + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base02a_seq_ser.csproj b/tests/src/Loader/classloader/generics/Layout/General/Base02a_seq_ser.csproj new file mode 100644 index 0000000000..ad0f68551e --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base02a_seq_ser.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>Base02a_seq_ser</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="Base02a_seq_ser.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base02b_auto_ser.cs b/tests/src/Loader/classloader/generics/Layout/General/Base02b_auto_ser.cs new file mode 100644 index 0000000000..c139919aaa --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base02b_auto_ser.cs @@ -0,0 +1,138 @@ +// 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.InteropServices; + + + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + + +[StructLayout(LayoutKind.Auto)] +public class GenBase<T> +{ + public T Fld10; + + public int _int0 = 0; + public double _double0 = 0; + public string _string0 = "string0"; + public Guid _Guid0 = new Guid(); + + public T Fld11; + + public int _int1 = int.MaxValue; + public double _double1 = double.MaxValue; + public string _string1 = "string1"; + public Guid _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T Fld12; + + public virtual void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(_string0.Equals("string0")); + Test.Eval(_string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +public class Gen<T> : GenBase<T> +{ + public T sFld10; + + public int _sint0 = 0; + public double _sdouble0 = 0; + public string _sstring0 = "string0"; + public Guid _sGuid0 = new Guid(); + + public T sFld11; + + public int _sint1 = int.MaxValue; + public double _sdouble1 = double.MaxValue; + public string _sstring1 = "string1"; + public Guid _sGuid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T sFld12; + + public override void VerifyLayout() + { + base.VerifyLayout(); + Test.Eval(_sint0 == 0); + Test.Eval(_sint1 == int.MaxValue) ; + Test.Eval(_sdouble0 == 0) ; + Test.Eval(_sdouble1 == double.MaxValue) ; + Test.Eval(_sstring0.Equals("string0")); + Test.Eval(_sstring1.Equals("string1")); + Test.Eval(_sGuid0 == new Guid()); + Test.Eval(_sGuid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } + +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new Gen<int>().VerifyLayout(); + new Gen<double>().VerifyLayout(); + new Gen<string>().VerifyLayout(); + new Gen<object>().VerifyLayout(); + new Gen<Guid>().VerifyLayout(); + + new Gen<int[]>().VerifyLayout(); + new Gen<double[,]>().VerifyLayout(); + new Gen<string[][][]>().VerifyLayout(); + new Gen<object[,,,]>().VerifyLayout(); + new Gen<Guid[][,,,][]>().VerifyLayout(); + + new Gen<RefX1<int>[]>().VerifyLayout(); + new Gen<RefX1<double>[,]>().VerifyLayout(); + new Gen<RefX1<string>[][][]>().VerifyLayout(); + new Gen<RefX1<object>[,,,]>().VerifyLayout(); + new Gen<RefX1<Guid>[][,,,][]>().VerifyLayout(); + + new Gen<ValX1<int>[]>().VerifyLayout(); + new Gen<ValX1<double>[,]>().VerifyLayout(); + new Gen<ValX1<string>[][][]>().VerifyLayout(); + new Gen<ValX1<object>[,,,]>().VerifyLayout(); + new Gen<ValX1<Guid>[][,,,][]>().VerifyLayout(); + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base02b_auto_ser.csproj b/tests/src/Loader/classloader/generics/Layout/General/Base02b_auto_ser.csproj new file mode 100644 index 0000000000..a82a658cc7 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base02b_auto_ser.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>Base02b_auto_ser</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="Base02b_auto_ser.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base02b_seq.cs b/tests/src/Loader/classloader/generics/Layout/General/Base02b_seq.cs new file mode 100644 index 0000000000..dee469b996 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base02b_seq.cs @@ -0,0 +1,137 @@ +// 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.InteropServices; + + + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + +[StructLayout(LayoutKind.Sequential)] +public class GenBase<T> +{ + public T Fld10; + + public int _int0 = 0; + public double _double0 = 0; + public string _string0 = "string0"; + public Guid _Guid0 = new Guid(); + + public T Fld11; + + public int _int1 = int.MaxValue; + public double _double1 = double.MaxValue; + public string _string1 = "string1"; + public Guid _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T Fld12; + + public virtual void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(_string0.Equals("string0")); + Test.Eval(_string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +[StructLayout(LayoutKind.Sequential)] +public class Gen<T> : GenBase<T> +{ + public T sFld10; + + public int _sint0 = 0; + public double _sdouble0 = 0; + public string _sstring0 = "string0"; + public Guid _sGuid0 = new Guid(); + + public T sFld11; + + public int _sint1 = int.MaxValue; + public double _sdouble1 = double.MaxValue; + public string _sstring1 = "string1"; + public Guid _sGuid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T sFld12; + + public override void VerifyLayout() + { + base.VerifyLayout(); + Test.Eval(_sint0 == 0); + Test.Eval(_sint1 == int.MaxValue) ; + Test.Eval(_sdouble0 == 0) ; + Test.Eval(_sdouble1 == double.MaxValue) ; + Test.Eval(_sstring0.Equals("string0")); + Test.Eval(_sstring1.Equals("string1")); + Test.Eval(_sGuid0 == new Guid()); + Test.Eval(_sGuid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } + +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new Gen<int>().VerifyLayout(); + new Gen<double>().VerifyLayout(); + new Gen<string>().VerifyLayout(); + new Gen<object>().VerifyLayout(); + new Gen<Guid>().VerifyLayout(); + + new Gen<int[]>().VerifyLayout(); + new Gen<double[,]>().VerifyLayout(); + new Gen<string[][][]>().VerifyLayout(); + new Gen<object[,,,]>().VerifyLayout(); + new Gen<Guid[][,,,][]>().VerifyLayout(); + + new Gen<RefX1<int>[]>().VerifyLayout(); + new Gen<RefX1<double>[,]>().VerifyLayout(); + new Gen<RefX1<string>[][][]>().VerifyLayout(); + new Gen<RefX1<object>[,,,]>().VerifyLayout(); + new Gen<RefX1<Guid>[][,,,][]>().VerifyLayout(); + + new Gen<ValX1<int>[]>().VerifyLayout(); + new Gen<ValX1<double>[,]>().VerifyLayout(); + new Gen<ValX1<string>[][][]>().VerifyLayout(); + new Gen<ValX1<object>[,,,]>().VerifyLayout(); + new Gen<ValX1<Guid>[][,,,][]>().VerifyLayout(); + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base02b_seq.csproj b/tests/src/Loader/classloader/generics/Layout/General/Base02b_seq.csproj new file mode 100644 index 0000000000..1ffbe80e1a --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base02b_seq.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>Base02b_seq</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="Base02b_seq.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base02b_seq_ser.cs b/tests/src/Loader/classloader/generics/Layout/General/Base02b_seq_ser.cs new file mode 100644 index 0000000000..aa23dba8a8 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base02b_seq_ser.cs @@ -0,0 +1,138 @@ +// 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.InteropServices; + + + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + + +[StructLayout(LayoutKind.Sequential)] +public class GenBase<T> +{ + public T Fld10; + + public int _int0 = 0; + public double _double0 = 0; + public string _string0 = "string0"; + public Guid _Guid0 = new Guid(); + + public T Fld11; + + public int _int1 = int.MaxValue; + public double _double1 = double.MaxValue; + public string _string1 = "string1"; + public Guid _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T Fld12; + + public virtual void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(_string0.Equals("string0")); + Test.Eval(_string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +public class Gen<T> : GenBase<T> +{ + public T sFld10; + + public int _sint0 = 0; + public double _sdouble0 = 0; + public string _sstring0 = "string0"; + public Guid _sGuid0 = new Guid(); + + public T sFld11; + + public int _sint1 = int.MaxValue; + public double _sdouble1 = double.MaxValue; + public string _sstring1 = "string1"; + public Guid _sGuid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T sFld12; + + public override void VerifyLayout() + { + base.VerifyLayout(); + Test.Eval(_sint0 == 0); + Test.Eval(_sint1 == int.MaxValue) ; + Test.Eval(_sdouble0 == 0) ; + Test.Eval(_sdouble1 == double.MaxValue) ; + Test.Eval(_sstring0.Equals("string0")); + Test.Eval(_sstring1.Equals("string1")); + Test.Eval(_sGuid0 == new Guid()); + Test.Eval(_sGuid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } + +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new Gen<int>().VerifyLayout(); + new Gen<double>().VerifyLayout(); + new Gen<string>().VerifyLayout(); + new Gen<object>().VerifyLayout(); + new Gen<Guid>().VerifyLayout(); + + new Gen<int[]>().VerifyLayout(); + new Gen<double[,]>().VerifyLayout(); + new Gen<string[][][]>().VerifyLayout(); + new Gen<object[,,,]>().VerifyLayout(); + new Gen<Guid[][,,,][]>().VerifyLayout(); + + new Gen<RefX1<int>[]>().VerifyLayout(); + new Gen<RefX1<double>[,]>().VerifyLayout(); + new Gen<RefX1<string>[][][]>().VerifyLayout(); + new Gen<RefX1<object>[,,,]>().VerifyLayout(); + new Gen<RefX1<Guid>[][,,,][]>().VerifyLayout(); + + new Gen<ValX1<int>[]>().VerifyLayout(); + new Gen<ValX1<double>[,]>().VerifyLayout(); + new Gen<ValX1<string>[][][]>().VerifyLayout(); + new Gen<ValX1<object>[,,,]>().VerifyLayout(); + new Gen<ValX1<Guid>[][,,,][]>().VerifyLayout(); + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base02b_seq_ser.csproj b/tests/src/Loader/classloader/generics/Layout/General/Base02b_seq_ser.csproj new file mode 100644 index 0000000000..15282a3176 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base02b_seq_ser.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>Base02b_seq_ser</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="Base02b_seq_ser.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base02c_seq_ser.cs b/tests/src/Loader/classloader/generics/Layout/General/Base02c_seq_ser.cs new file mode 100644 index 0000000000..c8515f2c40 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base02c_seq_ser.cs @@ -0,0 +1,139 @@ +// 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.InteropServices; + + + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + + +[StructLayout(LayoutKind.Sequential)] +public class GenBase<T> +{ + public T Fld10; + + public int _int0 = 0; + public double _double0 = 0; + public string _string0 = "string0"; + public Guid _Guid0 = new Guid(); + + public T Fld11; + + public int _int1 = int.MaxValue; + public double _double1 = double.MaxValue; + public string _string1 = "string1"; + public Guid _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T Fld12; + + public virtual void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(_string0.Equals("string0")); + Test.Eval(_string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + + +[StructLayout(LayoutKind.Sequential)] +public class Gen<T> : GenBase<T> +{ + public T sFld10; + + public int _sint0 = 0; + public double _sdouble0 = 0; + public string _sstring0 = "string0"; + public Guid _sGuid0 = new Guid(); + + public T sFld11; + + public int _sint1 = int.MaxValue; + public double _sdouble1 = double.MaxValue; + public string _sstring1 = "string1"; + public Guid _sGuid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T sFld12; + + public override void VerifyLayout() + { + base.VerifyLayout(); + Test.Eval(_sint0 == 0); + Test.Eval(_sint1 == int.MaxValue) ; + Test.Eval(_sdouble0 == 0) ; + Test.Eval(_sdouble1 == double.MaxValue) ; + Test.Eval(_sstring0.Equals("string0")); + Test.Eval(_sstring1.Equals("string1")); + Test.Eval(_sGuid0 == new Guid()); + Test.Eval(_sGuid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } + +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new Gen<int>().VerifyLayout(); + new Gen<double>().VerifyLayout(); + new Gen<string>().VerifyLayout(); + new Gen<object>().VerifyLayout(); + new Gen<Guid>().VerifyLayout(); + + new Gen<int[]>().VerifyLayout(); + new Gen<double[,]>().VerifyLayout(); + new Gen<string[][][]>().VerifyLayout(); + new Gen<object[,,,]>().VerifyLayout(); + new Gen<Guid[][,,,][]>().VerifyLayout(); + + new Gen<RefX1<int>[]>().VerifyLayout(); + new Gen<RefX1<double>[,]>().VerifyLayout(); + new Gen<RefX1<string>[][][]>().VerifyLayout(); + new Gen<RefX1<object>[,,,]>().VerifyLayout(); + new Gen<RefX1<Guid>[][,,,][]>().VerifyLayout(); + + new Gen<ValX1<int>[]>().VerifyLayout(); + new Gen<ValX1<double>[,]>().VerifyLayout(); + new Gen<ValX1<string>[][][]>().VerifyLayout(); + new Gen<ValX1<object>[,,,]>().VerifyLayout(); + new Gen<ValX1<Guid>[][,,,][]>().VerifyLayout(); + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base02c_seq_ser.csproj b/tests/src/Loader/classloader/generics/Layout/General/Base02c_seq_ser.csproj new file mode 100644 index 0000000000..7a8cccec35 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base02c_seq_ser.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>Base02c_seq_ser</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="Base02c_seq_ser.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base02d_seq_ser.cs b/tests/src/Loader/classloader/generics/Layout/General/Base02d_seq_ser.cs new file mode 100644 index 0000000000..18fac5559b --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base02d_seq_ser.cs @@ -0,0 +1,121 @@ +// 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. + +// regression test for 245437 + +using System; +using System.Runtime.InteropServices; + + + + +[StructLayout(LayoutKind.Sequential)] +public class GenBase<T> +{ + public T Fld10; + + public int _int0 = 0; + public double _double0 = 0; + public string _string0 = "string0"; + public Guid _Guid0 = new Guid(); + + public T Fld11; + + public int _int1 = int.MaxValue; + public double _double1 = double.MaxValue; + public string _string1 = "string1"; + public Guid _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T Fld12; + +} + + +[StructLayout(LayoutKind.Explicit)] +public class Gen<T> : GenBase<T> +{ + [FieldOffset(0)]public T sFld10; + + [FieldOffset(16)]public int _sint0 = 0; + [FieldOffset(24)]public double _sdouble0 = 0; + [FieldOffset(32)]public string _sstring0 = "string0"; + [FieldOffset(40)]public Guid _sGuid0 = new Guid(); + + [FieldOffset(56)]public T sFld11; + + [FieldOffset(72)]public int _sint1 = int.MaxValue; + [FieldOffset(80)]public double _sdouble1 = double.MaxValue; + [FieldOffset(88)]public string _sstring1 = "string1"; + [FieldOffset(96)]public Guid _sGuid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + [FieldOffset(112)]public T sFld12; + +} + +public class Test +{ + public static void RunTest1() + { + new Gen<int>(); + } + + public static void RunTest2() + { + new Gen<double>(); + } + + public static void RunTest3() + { + new Gen<string>(); + } + + public static int Main() + { + bool result = true; + try + { + RunTest1(); + result = false; + } + catch (TypeLoadException) + { + // expected + } + + try + { + RunTest2(); + result = false; + } + catch (TypeLoadException) + { + // expected + } + + + try + { + RunTest3(); + result = false; + } + catch (TypeLoadException) + { + // expected + } + + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/Base02d_seq_ser.csproj b/tests/src/Loader/classloader/generics/Layout/General/Base02d_seq_ser.csproj new file mode 100644 index 0000000000..64129e3394 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/Base02d_seq_ser.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>Base02d_seq_ser</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="Base02d_seq_ser.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/app.config b/tests/src/Loader/classloader/generics/Layout/General/app.config new file mode 100644 index 0000000000..e5622f77ad --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/app.config @@ -0,0 +1,27 @@ +<?xml version = "1.0" encoding="utf-8"?> +<configuration> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration> diff --git a/tests/src/Loader/classloader/generics/Layout/General/class01_auto.cs b/tests/src/Loader/classloader/generics/Layout/General/class01_auto.cs new file mode 100644 index 0000000000..53ecb4aa9b --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/class01_auto.cs @@ -0,0 +1,104 @@ +// 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.InteropServices; + + + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + + +[StructLayout(LayoutKind.Auto)] +public class Gen<T> +{ + public T Fld10; + + public int _int0 = 0; + public double _double0 = 0; + public string _string0 = "string0"; + public Guid _Guid0 = new Guid(); + + public T Fld11; + + public int _int1 = int.MaxValue; + public double _double1 = double.MaxValue; + public string _string1 = "string1"; + public Guid _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T Fld12; + + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(_string0.Equals("string0")); + Test.Eval(_string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new Gen<int>().VerifyLayout(); + new Gen<double>().VerifyLayout(); + new Gen<string>().VerifyLayout(); + new Gen<object>().VerifyLayout(); + new Gen<Guid>().VerifyLayout(); + + new Gen<int[]>().VerifyLayout(); + new Gen<double[,]>().VerifyLayout(); + new Gen<string[][][]>().VerifyLayout(); + new Gen<object[,,,]>().VerifyLayout(); + new Gen<Guid[][,,,][]>().VerifyLayout(); + + new Gen<RefX1<int>[]>().VerifyLayout(); + new Gen<RefX1<double>[,]>().VerifyLayout(); + new Gen<RefX1<string>[][][]>().VerifyLayout(); + new Gen<RefX1<object>[,,,]>().VerifyLayout(); + new Gen<RefX1<Guid>[][,,,][]>().VerifyLayout(); + + new Gen<ValX1<int>[]>().VerifyLayout(); + new Gen<ValX1<double>[,]>().VerifyLayout(); + new Gen<ValX1<string>[][][]>().VerifyLayout(); + new Gen<ValX1<object>[,,,]>().VerifyLayout(); + new Gen<ValX1<Guid>[][,,,][]>().VerifyLayout(); + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/class01_auto.csproj b/tests/src/Loader/classloader/generics/Layout/General/class01_auto.csproj new file mode 100644 index 0000000000..eb53fdfe8d --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/class01_auto.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>class01_auto</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="class01_auto.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/class01_auto_ser.cs b/tests/src/Loader/classloader/generics/Layout/General/class01_auto_ser.cs new file mode 100644 index 0000000000..53ecb4aa9b --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/class01_auto_ser.cs @@ -0,0 +1,104 @@ +// 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.InteropServices; + + + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + + +[StructLayout(LayoutKind.Auto)] +public class Gen<T> +{ + public T Fld10; + + public int _int0 = 0; + public double _double0 = 0; + public string _string0 = "string0"; + public Guid _Guid0 = new Guid(); + + public T Fld11; + + public int _int1 = int.MaxValue; + public double _double1 = double.MaxValue; + public string _string1 = "string1"; + public Guid _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T Fld12; + + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(_string0.Equals("string0")); + Test.Eval(_string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new Gen<int>().VerifyLayout(); + new Gen<double>().VerifyLayout(); + new Gen<string>().VerifyLayout(); + new Gen<object>().VerifyLayout(); + new Gen<Guid>().VerifyLayout(); + + new Gen<int[]>().VerifyLayout(); + new Gen<double[,]>().VerifyLayout(); + new Gen<string[][][]>().VerifyLayout(); + new Gen<object[,,,]>().VerifyLayout(); + new Gen<Guid[][,,,][]>().VerifyLayout(); + + new Gen<RefX1<int>[]>().VerifyLayout(); + new Gen<RefX1<double>[,]>().VerifyLayout(); + new Gen<RefX1<string>[][][]>().VerifyLayout(); + new Gen<RefX1<object>[,,,]>().VerifyLayout(); + new Gen<RefX1<Guid>[][,,,][]>().VerifyLayout(); + + new Gen<ValX1<int>[]>().VerifyLayout(); + new Gen<ValX1<double>[,]>().VerifyLayout(); + new Gen<ValX1<string>[][][]>().VerifyLayout(); + new Gen<ValX1<object>[,,,]>().VerifyLayout(); + new Gen<ValX1<Guid>[][,,,][]>().VerifyLayout(); + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/class01_auto_ser.csproj b/tests/src/Loader/classloader/generics/Layout/General/class01_auto_ser.csproj new file mode 100644 index 0000000000..178ec2b825 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/class01_auto_ser.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>class01_auto_ser</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="class01_auto_ser.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/class01_seq.cs b/tests/src/Loader/classloader/generics/Layout/General/class01_seq.cs new file mode 100644 index 0000000000..b90bc23cbe --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/class01_seq.cs @@ -0,0 +1,103 @@ +// 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.InteropServices; + + + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + +[StructLayout(LayoutKind.Sequential)] +public class Gen<T> +{ + public T Fld10; + + public int _int0 = 0; + public double _double0 = 0; + public string _string0 = "string0"; + public Guid _Guid0 = new Guid(); + + public T Fld11; + + public int _int1 = int.MaxValue; + public double _double1 = double.MaxValue; + public string _string1 = "string1"; + public Guid _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T Fld12; + + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(_string0.Equals("string0")); + Test.Eval(_string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new Gen<int>().VerifyLayout(); + new Gen<double>().VerifyLayout(); + new Gen<string>().VerifyLayout(); + new Gen<object>().VerifyLayout(); + new Gen<Guid>().VerifyLayout(); + + new Gen<int[]>().VerifyLayout(); + new Gen<double[,]>().VerifyLayout(); + new Gen<string[][][]>().VerifyLayout(); + new Gen<object[,,,]>().VerifyLayout(); + new Gen<Guid[][,,,][]>().VerifyLayout(); + + new Gen<RefX1<int>[]>().VerifyLayout(); + new Gen<RefX1<double>[,]>().VerifyLayout(); + new Gen<RefX1<string>[][][]>().VerifyLayout(); + new Gen<RefX1<object>[,,,]>().VerifyLayout(); + new Gen<RefX1<Guid>[][,,,][]>().VerifyLayout(); + + new Gen<ValX1<int>[]>().VerifyLayout(); + new Gen<ValX1<double>[,]>().VerifyLayout(); + new Gen<ValX1<string>[][][]>().VerifyLayout(); + new Gen<ValX1<object>[,,,]>().VerifyLayout(); + new Gen<ValX1<Guid>[][,,,][]>().VerifyLayout(); + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/class01_seq.csproj b/tests/src/Loader/classloader/generics/Layout/General/class01_seq.csproj new file mode 100644 index 0000000000..abe5f8e635 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/class01_seq.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>class01_seq</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="class01_seq.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/class01_seq_ser.cs b/tests/src/Loader/classloader/generics/Layout/General/class01_seq_ser.cs new file mode 100644 index 0000000000..c5697d38b2 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/class01_seq_ser.cs @@ -0,0 +1,104 @@ +// 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.InteropServices; + + + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + + +[StructLayout(LayoutKind.Sequential)] +public class Gen<T> +{ + public T Fld10; + + public int _int0 = 0; + public double _double0 = 0; + public string _string0 = "string0"; + public Guid _Guid0 = new Guid(); + + public T Fld11; + + public int _int1 = int.MaxValue; + public double _double1 = double.MaxValue; + public string _string1 = "string1"; + public Guid _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T Fld12; + + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(_string0.Equals("string0")); + Test.Eval(_string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new Gen<int>().VerifyLayout(); + new Gen<double>().VerifyLayout(); + new Gen<string>().VerifyLayout(); + new Gen<object>().VerifyLayout(); + new Gen<Guid>().VerifyLayout(); + + new Gen<int[]>().VerifyLayout(); + new Gen<double[,]>().VerifyLayout(); + new Gen<string[][][]>().VerifyLayout(); + new Gen<object[,,,]>().VerifyLayout(); + new Gen<Guid[][,,,][]>().VerifyLayout(); + + new Gen<RefX1<int>[]>().VerifyLayout(); + new Gen<RefX1<double>[,]>().VerifyLayout(); + new Gen<RefX1<string>[][][]>().VerifyLayout(); + new Gen<RefX1<object>[,,,]>().VerifyLayout(); + new Gen<RefX1<Guid>[][,,,][]>().VerifyLayout(); + + new Gen<ValX1<int>[]>().VerifyLayout(); + new Gen<ValX1<double>[,]>().VerifyLayout(); + new Gen<ValX1<string>[][][]>().VerifyLayout(); + new Gen<ValX1<object>[,,,]>().VerifyLayout(); + new Gen<ValX1<Guid>[][,,,][]>().VerifyLayout(); + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/class01_seq_ser.csproj b/tests/src/Loader/classloader/generics/Layout/General/class01_seq_ser.csproj new file mode 100644 index 0000000000..d43ad8ef28 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/class01_seq_ser.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>class01_seq_ser</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="class01_seq_ser.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/class02_auto.cs b/tests/src/Loader/classloader/generics/Layout/General/class02_auto.cs new file mode 100644 index 0000000000..5b909f0854 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/class02_auto.cs @@ -0,0 +1,159 @@ +// 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.InteropServices; + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + +[StructLayout(LayoutKind.Auto)] +public class Gen<T,U> +{ + public T Fld10; + + public int _int0 = 0; + public double _double0 = 0; + public string _string0 = "string0"; + public Guid _Guid0 = new Guid(); + + public U Fld20; + + public int _int1 = 1; + public double _double1 = 1; + public string _string1 = "string1"; + public Guid _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T Fld11; + public U Fld21; + + public int _int2 = int.MaxValue; + public double _double2 = double.MaxValue; + public string _string2 = "string2"; + public Guid _Guid2 = new Guid(11,21,31,41,51,61,71,81,91,101,111); + + public T Fld12; + + public int _int3 = int.MinValue; + public double _double3 = double.MinValue; + public string _string3 = "string3"; + public Guid _Guid3 = new Guid(12,22,32,42,52,62,72,82,92,102,112); + + public U Fld22; + + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == 1); + Test.Eval(_int2 == int.MaxValue) ; + Test.Eval(_int3 == int.MinValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1== 1) ; + Test.Eval(_double2 == double.MaxValue) ; + Test.Eval(_double3 == double.MinValue) ; + Test.Eval(_string0.Equals("string0")); + Test.Eval(_string1.Equals("string1")); + Test.Eval(_string2.Equals("string2")); + Test.Eval(_string3.Equals("string3")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + Test.Eval(_Guid2 == new Guid(11,21,31,41,51,61,71,81,91,101,111)); + Test.Eval(_Guid3 == new Guid(12,22,32,42,52,62,72,82,92,102,112)); + } +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new Gen<int,int>().VerifyLayout(); + new Gen<int,double>().VerifyLayout(); + new Gen<int,string>().VerifyLayout(); + new Gen<int,object>().VerifyLayout(); + new Gen<int,Guid>().VerifyLayout(); + new Gen<int,RefX1<int>>().VerifyLayout(); + new Gen<int,RefX1<string>>().VerifyLayout(); + new Gen<int,RefX1<int[][,,,][]>>().VerifyLayout(); + new Gen<int,ValX1<int>>().VerifyLayout(); + new Gen<int,ValX1<string>>().VerifyLayout(); + new Gen<int,ValX1<int[][,,,][]>>().VerifyLayout(); + + new Gen<double,int>().VerifyLayout(); + new Gen<double,double>().VerifyLayout(); + new Gen<double,string>().VerifyLayout(); + new Gen<double,object>().VerifyLayout(); + new Gen<double,Guid>().VerifyLayout(); + new Gen<double,RefX1<double>>().VerifyLayout(); + new Gen<double,RefX1<string>>().VerifyLayout(); + new Gen<double,RefX1<double[][,,,][]>>().VerifyLayout(); + new Gen<double,ValX1<double>>().VerifyLayout(); + new Gen<double,ValX1<string>>().VerifyLayout(); + new Gen<double,ValX1<double[][,,,][]>>().VerifyLayout(); + + new Gen<string,int>().VerifyLayout(); + new Gen<string,double>().VerifyLayout(); + new Gen<string,string>().VerifyLayout(); + new Gen<string,object>().VerifyLayout(); + new Gen<string,Guid>().VerifyLayout(); + new Gen<string,RefX1<string>>().VerifyLayout(); + new Gen<string,RefX1<string>>().VerifyLayout(); + new Gen<string,RefX1<string[][,,,][]>>().VerifyLayout(); + new Gen<string,ValX1<string>>().VerifyLayout(); + new Gen<string,ValX1<string>>().VerifyLayout(); + new Gen<string,ValX1<string[][,,,][]>>().VerifyLayout(); + + new Gen<object,int>().VerifyLayout(); + new Gen<object,double>().VerifyLayout(); + new Gen<object,string>().VerifyLayout(); + new Gen<object,object>().VerifyLayout(); + new Gen<object,Guid>().VerifyLayout(); + new Gen<object,RefX1<object>>().VerifyLayout(); + new Gen<object,RefX1<string>>().VerifyLayout(); + new Gen<object,RefX1<object[][,,,][]>>().VerifyLayout(); + new Gen<object,ValX1<object>>().VerifyLayout(); + new Gen<object,ValX1<string>>().VerifyLayout(); + new Gen<object,ValX1<object[][,,,][]>>().VerifyLayout(); + + new Gen<Guid,int>().VerifyLayout(); + new Gen<Guid,double>().VerifyLayout(); + new Gen<Guid,string>().VerifyLayout(); + new Gen<Guid,object>().VerifyLayout(); + new Gen<Guid,Guid>().VerifyLayout(); + new Gen<Guid,RefX1<Guid>>().VerifyLayout(); + new Gen<Guid,RefX1<string>>().VerifyLayout(); + new Gen<Guid,RefX1<Guid[][,,,][]>>().VerifyLayout(); + new Gen<Guid,ValX1<Guid>>().VerifyLayout(); + new Gen<Guid,ValX1<string>>().VerifyLayout(); + new Gen<Guid,ValX1<Guid[][,,,][]>>().VerifyLayout(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/class02_auto.csproj b/tests/src/Loader/classloader/generics/Layout/General/class02_auto.csproj new file mode 100644 index 0000000000..bb5014b76a --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/class02_auto.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>class02_auto</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="class02_auto.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/class02_auto_ser.cs b/tests/src/Loader/classloader/generics/Layout/General/class02_auto_ser.cs new file mode 100644 index 0000000000..a0d27a5bc2 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/class02_auto_ser.cs @@ -0,0 +1,160 @@ +// 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.InteropServices; + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + + +[StructLayout(LayoutKind.Auto)] +public class Gen<T,U> +{ + public T Fld10; + + public int _int0 = 0; + public double _double0 = 0; + public string _string0 = "string0"; + public Guid _Guid0 = new Guid(); + + public U Fld20; + + public int _int1 = 1; + public double _double1 = 1; + public string _string1 = "string1"; + public Guid _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T Fld11; + public U Fld21; + + public int _int2 = int.MaxValue; + public double _double2 = double.MaxValue; + public string _string2 = "string2"; + public Guid _Guid2 = new Guid(11,21,31,41,51,61,71,81,91,101,111); + + public T Fld12; + + public int _int3 = int.MinValue; + public double _double3 = double.MinValue; + public string _string3 = "string3"; + public Guid _Guid3 = new Guid(12,22,32,42,52,62,72,82,92,102,112); + + public U Fld22; + + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == 1); + Test.Eval(_int2 == int.MaxValue) ; + Test.Eval(_int3 == int.MinValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1== 1) ; + Test.Eval(_double2 == double.MaxValue) ; + Test.Eval(_double3 == double.MinValue) ; + Test.Eval(_string0.Equals("string0")); + Test.Eval(_string1.Equals("string1")); + Test.Eval(_string2.Equals("string2")); + Test.Eval(_string3.Equals("string3")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + Test.Eval(_Guid2 == new Guid(11,21,31,41,51,61,71,81,91,101,111)); + Test.Eval(_Guid3 == new Guid(12,22,32,42,52,62,72,82,92,102,112)); + } +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new Gen<int,int>().VerifyLayout(); + new Gen<int,double>().VerifyLayout(); + new Gen<int,string>().VerifyLayout(); + new Gen<int,object>().VerifyLayout(); + new Gen<int,Guid>().VerifyLayout(); + new Gen<int,RefX1<int>>().VerifyLayout(); + new Gen<int,RefX1<string>>().VerifyLayout(); + new Gen<int,RefX1<int[][,,,][]>>().VerifyLayout(); + new Gen<int,ValX1<int>>().VerifyLayout(); + new Gen<int,ValX1<string>>().VerifyLayout(); + new Gen<int,ValX1<int[][,,,][]>>().VerifyLayout(); + + new Gen<double,int>().VerifyLayout(); + new Gen<double,double>().VerifyLayout(); + new Gen<double,string>().VerifyLayout(); + new Gen<double,object>().VerifyLayout(); + new Gen<double,Guid>().VerifyLayout(); + new Gen<double,RefX1<double>>().VerifyLayout(); + new Gen<double,RefX1<string>>().VerifyLayout(); + new Gen<double,RefX1<double[][,,,][]>>().VerifyLayout(); + new Gen<double,ValX1<double>>().VerifyLayout(); + new Gen<double,ValX1<string>>().VerifyLayout(); + new Gen<double,ValX1<double[][,,,][]>>().VerifyLayout(); + + new Gen<string,int>().VerifyLayout(); + new Gen<string,double>().VerifyLayout(); + new Gen<string,string>().VerifyLayout(); + new Gen<string,object>().VerifyLayout(); + new Gen<string,Guid>().VerifyLayout(); + new Gen<string,RefX1<string>>().VerifyLayout(); + new Gen<string,RefX1<string>>().VerifyLayout(); + new Gen<string,RefX1<string[][,,,][]>>().VerifyLayout(); + new Gen<string,ValX1<string>>().VerifyLayout(); + new Gen<string,ValX1<string>>().VerifyLayout(); + new Gen<string,ValX1<string[][,,,][]>>().VerifyLayout(); + + new Gen<object,int>().VerifyLayout(); + new Gen<object,double>().VerifyLayout(); + new Gen<object,string>().VerifyLayout(); + new Gen<object,object>().VerifyLayout(); + new Gen<object,Guid>().VerifyLayout(); + new Gen<object,RefX1<object>>().VerifyLayout(); + new Gen<object,RefX1<string>>().VerifyLayout(); + new Gen<object,RefX1<object[][,,,][]>>().VerifyLayout(); + new Gen<object,ValX1<object>>().VerifyLayout(); + new Gen<object,ValX1<string>>().VerifyLayout(); + new Gen<object,ValX1<object[][,,,][]>>().VerifyLayout(); + + new Gen<Guid,int>().VerifyLayout(); + new Gen<Guid,double>().VerifyLayout(); + new Gen<Guid,string>().VerifyLayout(); + new Gen<Guid,object>().VerifyLayout(); + new Gen<Guid,Guid>().VerifyLayout(); + new Gen<Guid,RefX1<Guid>>().VerifyLayout(); + new Gen<Guid,RefX1<string>>().VerifyLayout(); + new Gen<Guid,RefX1<Guid[][,,,][]>>().VerifyLayout(); + new Gen<Guid,ValX1<Guid>>().VerifyLayout(); + new Gen<Guid,ValX1<string>>().VerifyLayout(); + new Gen<Guid,ValX1<Guid[][,,,][]>>().VerifyLayout(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/class02_auto_ser.csproj b/tests/src/Loader/classloader/generics/Layout/General/class02_auto_ser.csproj new file mode 100644 index 0000000000..d3cf3bb28e --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/class02_auto_ser.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>class02_auto_ser</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="class02_auto_ser.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/class02_seq_ser.cs b/tests/src/Loader/classloader/generics/Layout/General/class02_seq_ser.cs new file mode 100644 index 0000000000..0ab5ee3d0a --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/class02_seq_ser.cs @@ -0,0 +1,160 @@ +// 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.InteropServices; + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + + +[StructLayout(LayoutKind.Sequential)] +public class Gen<T,U> +{ + public T Fld10; + + public int _int0 = 0; + public double _double0 = 0; + public string _string0 = "string0"; + public Guid _Guid0 = new Guid(); + + public U Fld20; + + public int _int1 = 1; + public double _double1 = 1; + public string _string1 = "string1"; + public Guid _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + public T Fld11; + public U Fld21; + + public int _int2 = int.MaxValue; + public double _double2 = double.MaxValue; + public string _string2 = "string2"; + public Guid _Guid2 = new Guid(11,21,31,41,51,61,71,81,91,101,111); + + public T Fld12; + + public int _int3 = int.MinValue; + public double _double3 = double.MinValue; + public string _string3 = "string3"; + public Guid _Guid3 = new Guid(12,22,32,42,52,62,72,82,92,102,112); + + public U Fld22; + + public void VerifyLayout() + { + Test.Eval(_int0 == 0); + Test.Eval(_int1 == 1); + Test.Eval(_int2 == int.MaxValue) ; + Test.Eval(_int3 == int.MinValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1== 1) ; + Test.Eval(_double2 == double.MaxValue) ; + Test.Eval(_double3 == double.MinValue) ; + Test.Eval(_string0.Equals("string0")); + Test.Eval(_string1.Equals("string1")); + Test.Eval(_string2.Equals("string2")); + Test.Eval(_string3.Equals("string3")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + Test.Eval(_Guid2 == new Guid(11,21,31,41,51,61,71,81,91,101,111)); + Test.Eval(_Guid3 == new Guid(12,22,32,42,52,62,72,82,92,102,112)); + } +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new Gen<int,int>().VerifyLayout(); + new Gen<int,double>().VerifyLayout(); + new Gen<int,string>().VerifyLayout(); + new Gen<int,object>().VerifyLayout(); + new Gen<int,Guid>().VerifyLayout(); + new Gen<int,RefX1<int>>().VerifyLayout(); + new Gen<int,RefX1<string>>().VerifyLayout(); + new Gen<int,RefX1<int[][,,,][]>>().VerifyLayout(); + new Gen<int,ValX1<int>>().VerifyLayout(); + new Gen<int,ValX1<string>>().VerifyLayout(); + new Gen<int,ValX1<int[][,,,][]>>().VerifyLayout(); + + new Gen<double,int>().VerifyLayout(); + new Gen<double,double>().VerifyLayout(); + new Gen<double,string>().VerifyLayout(); + new Gen<double,object>().VerifyLayout(); + new Gen<double,Guid>().VerifyLayout(); + new Gen<double,RefX1<double>>().VerifyLayout(); + new Gen<double,RefX1<string>>().VerifyLayout(); + new Gen<double,RefX1<double[][,,,][]>>().VerifyLayout(); + new Gen<double,ValX1<double>>().VerifyLayout(); + new Gen<double,ValX1<string>>().VerifyLayout(); + new Gen<double,ValX1<double[][,,,][]>>().VerifyLayout(); + + new Gen<string,int>().VerifyLayout(); + new Gen<string,double>().VerifyLayout(); + new Gen<string,string>().VerifyLayout(); + new Gen<string,object>().VerifyLayout(); + new Gen<string,Guid>().VerifyLayout(); + new Gen<string,RefX1<string>>().VerifyLayout(); + new Gen<string,RefX1<string>>().VerifyLayout(); + new Gen<string,RefX1<string[][,,,][]>>().VerifyLayout(); + new Gen<string,ValX1<string>>().VerifyLayout(); + new Gen<string,ValX1<string>>().VerifyLayout(); + new Gen<string,ValX1<string[][,,,][]>>().VerifyLayout(); + + new Gen<object,int>().VerifyLayout(); + new Gen<object,double>().VerifyLayout(); + new Gen<object,string>().VerifyLayout(); + new Gen<object,object>().VerifyLayout(); + new Gen<object,Guid>().VerifyLayout(); + new Gen<object,RefX1<object>>().VerifyLayout(); + new Gen<object,RefX1<string>>().VerifyLayout(); + new Gen<object,RefX1<object[][,,,][]>>().VerifyLayout(); + new Gen<object,ValX1<object>>().VerifyLayout(); + new Gen<object,ValX1<string>>().VerifyLayout(); + new Gen<object,ValX1<object[][,,,][]>>().VerifyLayout(); + + new Gen<Guid,int>().VerifyLayout(); + new Gen<Guid,double>().VerifyLayout(); + new Gen<Guid,string>().VerifyLayout(); + new Gen<Guid,object>().VerifyLayout(); + new Gen<Guid,Guid>().VerifyLayout(); + new Gen<Guid,RefX1<Guid>>().VerifyLayout(); + new Gen<Guid,RefX1<string>>().VerifyLayout(); + new Gen<Guid,RefX1<Guid[][,,,][]>>().VerifyLayout(); + new Gen<Guid,ValX1<Guid>>().VerifyLayout(); + new Gen<Guid,ValX1<string>>().VerifyLayout(); + new Gen<Guid,ValX1<Guid[][,,,][]>>().VerifyLayout(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/class02_seq_ser.csproj b/tests/src/Loader/classloader/generics/Layout/General/class02_seq_ser.csproj new file mode 100644 index 0000000000..e4118bd5be --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/class02_seq_ser.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>class02_seq_ser</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="class02_seq_ser.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/project.json b/tests/src/Loader/classloader/generics/Layout/General/project.json new file mode 100644 index 0000000000..a2e84dc340 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/project.json @@ -0,0 +1,35 @@ +{ + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816", + "System.Collections": "4.0.10", + "System.Collections.NonGeneric": "4.0.1-rc2-23816", + "System.Collections.Specialized": "4.0.1-rc2-23816", + "System.ComponentModel": "4.0.1-rc2-23816", + "System.Console": "4.0.0-rc2-23816", + "System.Diagnostics.Process": "4.1.0-rc2-23816", + "System.Globalization": "4.0.10", + "System.Globalization.Calendars": "4.0.0", + "System.IO": "4.0.10", + "System.IO.FileSystem": "4.0.0", + "System.IO.FileSystem.Primitives": "4.0.0", + "System.Linq": "4.0.1-rc2-23816", + "System.Linq.Queryable": "4.0.1-rc2-23816", + "System.Reflection": "4.0.10", + "System.Reflection.Primitives": "4.0.0", + "System.Runtime": "4.1.0-rc2-23816", + "System.Runtime.Extensions": "4.0.10", + "System.Runtime.Handles": "4.0.0", + "System.Runtime.InteropServices": "4.1.0-rc2-23816", + "System.Runtime.Loader": "4.0.0-rc2-23816", + "System.Text.Encoding": "4.0.10", + "System.Threading": "4.0.10", + "System.Threading.Thread": "4.0.0-rc2-23816", + "System.Xml.ReaderWriter": "4.0.11-rc2-23816", + "System.Xml.XDocument": "4.0.11-rc2-23816", + "System.Xml.XmlDocument": "4.0.1-rc2-23816", + "System.Xml.XmlSerializer": "4.0.11-rc2-23816" + }, + "frameworks": { + "dnxcore50": {} + } +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/struct01_auto.cs b/tests/src/Loader/classloader/generics/Layout/General/struct01_auto.cs new file mode 100644 index 0000000000..afcfe879f6 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/struct01_auto.cs @@ -0,0 +1,114 @@ +// 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.InteropServices; + + + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + + +[StructLayout(LayoutKind.Auto)] +public struct Gen<T> +{ + public T Fld10; + + public int _int0; + public double _double0; + public string _string0; + public Guid _Guid0; + + public T Fld11; + + public int _int1; + public double _double1; + public string _string1; + public Guid _Guid1; + + public T Fld12; + + public void VerifyLayout() + { + _int0 = 0; + _double0 = 0; + _string0 = "string0"; + _Guid0 = new Guid(); + + _int1 = int.MaxValue; + _double1 = double.MaxValue; + _string1 = "string1"; + _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(_string0.Equals("string0")); + Test.Eval(_string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new Gen<int>().VerifyLayout(); + new Gen<double>().VerifyLayout(); + new Gen<string>().VerifyLayout(); + new Gen<object>().VerifyLayout(); + new Gen<Guid>().VerifyLayout(); + + new Gen<int[]>().VerifyLayout(); + new Gen<double[,]>().VerifyLayout(); + new Gen<string[][][]>().VerifyLayout(); + new Gen<object[,,,]>().VerifyLayout(); + new Gen<Guid[][,,,][]>().VerifyLayout(); + + new Gen<RefX1<int>[]>().VerifyLayout(); + new Gen<RefX1<double>[,]>().VerifyLayout(); + new Gen<RefX1<string>[][][]>().VerifyLayout(); + new Gen<RefX1<object>[,,,]>().VerifyLayout(); + new Gen<RefX1<Guid>[][,,,][]>().VerifyLayout(); + + new Gen<ValX1<int>[]>().VerifyLayout(); + new Gen<ValX1<double>[,]>().VerifyLayout(); + new Gen<ValX1<string>[][][]>().VerifyLayout(); + new Gen<ValX1<object>[,,,]>().VerifyLayout(); + new Gen<ValX1<Guid>[][,,,][]>().VerifyLayout(); + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/struct01_auto.csproj b/tests/src/Loader/classloader/generics/Layout/General/struct01_auto.csproj new file mode 100644 index 0000000000..d12f20722b --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/struct01_auto.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>struct01_auto</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="struct01_auto.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/struct01_auto_ser.cs b/tests/src/Loader/classloader/generics/Layout/General/struct01_auto_ser.cs new file mode 100644 index 0000000000..afcfe879f6 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/struct01_auto_ser.cs @@ -0,0 +1,114 @@ +// 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.InteropServices; + + + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + + +[StructLayout(LayoutKind.Auto)] +public struct Gen<T> +{ + public T Fld10; + + public int _int0; + public double _double0; + public string _string0; + public Guid _Guid0; + + public T Fld11; + + public int _int1; + public double _double1; + public string _string1; + public Guid _Guid1; + + public T Fld12; + + public void VerifyLayout() + { + _int0 = 0; + _double0 = 0; + _string0 = "string0"; + _Guid0 = new Guid(); + + _int1 = int.MaxValue; + _double1 = double.MaxValue; + _string1 = "string1"; + _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(_string0.Equals("string0")); + Test.Eval(_string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new Gen<int>().VerifyLayout(); + new Gen<double>().VerifyLayout(); + new Gen<string>().VerifyLayout(); + new Gen<object>().VerifyLayout(); + new Gen<Guid>().VerifyLayout(); + + new Gen<int[]>().VerifyLayout(); + new Gen<double[,]>().VerifyLayout(); + new Gen<string[][][]>().VerifyLayout(); + new Gen<object[,,,]>().VerifyLayout(); + new Gen<Guid[][,,,][]>().VerifyLayout(); + + new Gen<RefX1<int>[]>().VerifyLayout(); + new Gen<RefX1<double>[,]>().VerifyLayout(); + new Gen<RefX1<string>[][][]>().VerifyLayout(); + new Gen<RefX1<object>[,,,]>().VerifyLayout(); + new Gen<RefX1<Guid>[][,,,][]>().VerifyLayout(); + + new Gen<ValX1<int>[]>().VerifyLayout(); + new Gen<ValX1<double>[,]>().VerifyLayout(); + new Gen<ValX1<string>[][][]>().VerifyLayout(); + new Gen<ValX1<object>[,,,]>().VerifyLayout(); + new Gen<ValX1<Guid>[][,,,][]>().VerifyLayout(); + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/struct01_auto_ser.csproj b/tests/src/Loader/classloader/generics/Layout/General/struct01_auto_ser.csproj new file mode 100644 index 0000000000..1c05dbe6f5 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/struct01_auto_ser.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>struct01_auto_ser</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="struct01_auto_ser.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/struct01_seq.cs b/tests/src/Loader/classloader/generics/Layout/General/struct01_seq.cs new file mode 100644 index 0000000000..c3c9065542 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/struct01_seq.cs @@ -0,0 +1,114 @@ +// 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.InteropServices; + + + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + + +[StructLayout(LayoutKind.Sequential)] +public struct Gen<T> +{ + public T Fld10; + + public int _int0; + public double _double0; + public string _string0; + public Guid _Guid0; + + public T Fld11; + + public int _int1; + public double _double1; + public string _string1; + public Guid _Guid1; + + public T Fld12; + + public void VerifyLayout() + { + _int0 = 0; + _double0 = 0; + _string0 = "string0"; + _Guid0 = new Guid(); + + _int1 = int.MaxValue; + _double1 = double.MaxValue; + _string1 = "string1"; + _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + Test.Eval(_int0 == 0); + Test.Eval(_int1 == int.MaxValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1 == double.MaxValue) ; + Test.Eval(_string0.Equals("string0")); + Test.Eval(_string1.Equals("string1")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + } +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new Gen<int>().VerifyLayout(); + new Gen<double>().VerifyLayout(); + new Gen<string>().VerifyLayout(); + new Gen<object>().VerifyLayout(); + new Gen<Guid>().VerifyLayout(); + + new Gen<int[]>().VerifyLayout(); + new Gen<double[,]>().VerifyLayout(); + new Gen<string[][][]>().VerifyLayout(); + new Gen<object[,,,]>().VerifyLayout(); + new Gen<Guid[][,,,][]>().VerifyLayout(); + + new Gen<RefX1<int>[]>().VerifyLayout(); + new Gen<RefX1<double>[,]>().VerifyLayout(); + new Gen<RefX1<string>[][][]>().VerifyLayout(); + new Gen<RefX1<object>[,,,]>().VerifyLayout(); + new Gen<RefX1<Guid>[][,,,][]>().VerifyLayout(); + + new Gen<ValX1<int>[]>().VerifyLayout(); + new Gen<ValX1<double>[,]>().VerifyLayout(); + new Gen<ValX1<string>[][][]>().VerifyLayout(); + new Gen<ValX1<object>[,,,]>().VerifyLayout(); + new Gen<ValX1<Guid>[][,,,][]>().VerifyLayout(); + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/struct01_seq.csproj b/tests/src/Loader/classloader/generics/Layout/General/struct01_seq.csproj new file mode 100644 index 0000000000..e3b7b8986e --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/struct01_seq.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>struct01_seq</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="struct01_seq.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/struct01_seq_ser.cs b/tests/src/Loader/classloader/generics/Layout/General/struct01_seq_ser.cs new file mode 100644 index 0000000000..ba19050592 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/struct01_seq_ser.cs @@ -0,0 +1,180 @@ +// 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.InteropServices; + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + + +[StructLayout(LayoutKind.Sequential)] +public struct Gen<T,U> +{ + public T Fld10; + + public int _int0; + public double _double0; + public string _string0; + public Guid _Guid0; + + public U Fld20; + + public int _int1; + public double _double1; + public string _string1; + public Guid _Guid1; + + public T Fld11; + public U Fld21; + + public int _int2; + public double _double2; + public string _string2; + public Guid _Guid2; + + public T Fld12; + + public int _int3; + public double _double3; + public string _string3; + public Guid _Guid3; + + public U Fld22; + + public void VerifyLayout() + { + _int0 = 0; + _double0 = 0; + _string0 = "string0"; + _Guid0 = new Guid(); + + _int1 = 1; + _double1 = 1; + _string1 = "string1"; + _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + _int2 = int.MaxValue; + _double2 = double.MaxValue; + _string2 = "string2"; + _Guid2 = new Guid(11,21,31,41,51,61,71,81,91,101,111); + + _int3 = int.MinValue; + _double3 = double.MinValue; + _string3 = "string3"; + _Guid3 = new Guid(12,22,32,42,52,62,72,82,92,102,112); + + Test.Eval(_int0 == 0); + Test.Eval(_int1 == 1); + Test.Eval(_int2 == int.MaxValue) ; + Test.Eval(_int3 == int.MinValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1== 1) ; + Test.Eval(_double2 == double.MaxValue) ; + Test.Eval(_double3 == double.MinValue) ; + Test.Eval(_string0.Equals("string0")); + Test.Eval(_string1.Equals("string1")); + Test.Eval(_string2.Equals("string2")); + Test.Eval(_string3.Equals("string3")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + Test.Eval(_Guid2 == new Guid(11,21,31,41,51,61,71,81,91,101,111)); + Test.Eval(_Guid3 == new Guid(12,22,32,42,52,62,72,82,92,102,112)); + } +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new Gen<int,int>().VerifyLayout(); + new Gen<int,double>().VerifyLayout(); + new Gen<int,string>().VerifyLayout(); + new Gen<int,object>().VerifyLayout(); + new Gen<int,Guid>().VerifyLayout(); + new Gen<int,RefX1<int>>().VerifyLayout(); + new Gen<int,RefX1<string>>().VerifyLayout(); + new Gen<int,RefX1<int[][,,,][]>>().VerifyLayout(); + new Gen<int,ValX1<int>>().VerifyLayout(); + new Gen<int,ValX1<string>>().VerifyLayout(); + new Gen<int,ValX1<int[][,,,][]>>().VerifyLayout(); + + new Gen<double,int>().VerifyLayout(); + new Gen<double,double>().VerifyLayout(); + new Gen<double,string>().VerifyLayout(); + new Gen<double,object>().VerifyLayout(); + new Gen<double,Guid>().VerifyLayout(); + new Gen<double,RefX1<double>>().VerifyLayout(); + new Gen<double,RefX1<string>>().VerifyLayout(); + new Gen<double,RefX1<double[][,,,][]>>().VerifyLayout(); + new Gen<double,ValX1<double>>().VerifyLayout(); + new Gen<double,ValX1<string>>().VerifyLayout(); + new Gen<double,ValX1<double[][,,,][]>>().VerifyLayout(); + + new Gen<string,int>().VerifyLayout(); + new Gen<string,double>().VerifyLayout(); + new Gen<string,string>().VerifyLayout(); + new Gen<string,object>().VerifyLayout(); + new Gen<string,Guid>().VerifyLayout(); + new Gen<string,RefX1<string>>().VerifyLayout(); + new Gen<string,RefX1<string>>().VerifyLayout(); + new Gen<string,RefX1<string[][,,,][]>>().VerifyLayout(); + new Gen<string,ValX1<string>>().VerifyLayout(); + new Gen<string,ValX1<string>>().VerifyLayout(); + new Gen<string,ValX1<string[][,,,][]>>().VerifyLayout(); + + new Gen<object,int>().VerifyLayout(); + new Gen<object,double>().VerifyLayout(); + new Gen<object,string>().VerifyLayout(); + new Gen<object,object>().VerifyLayout(); + new Gen<object,Guid>().VerifyLayout(); + new Gen<object,RefX1<object>>().VerifyLayout(); + new Gen<object,RefX1<string>>().VerifyLayout(); + new Gen<object,RefX1<object[][,,,][]>>().VerifyLayout(); + new Gen<object,ValX1<object>>().VerifyLayout(); + new Gen<object,ValX1<string>>().VerifyLayout(); + new Gen<object,ValX1<object[][,,,][]>>().VerifyLayout(); + + new Gen<Guid,int>().VerifyLayout(); + new Gen<Guid,double>().VerifyLayout(); + new Gen<Guid,string>().VerifyLayout(); + new Gen<Guid,object>().VerifyLayout(); + new Gen<Guid,Guid>().VerifyLayout(); + new Gen<Guid,RefX1<Guid>>().VerifyLayout(); + new Gen<Guid,RefX1<string>>().VerifyLayout(); + new Gen<Guid,RefX1<Guid[][,,,][]>>().VerifyLayout(); + new Gen<Guid,ValX1<Guid>>().VerifyLayout(); + new Gen<Guid,ValX1<string>>().VerifyLayout(); + new Gen<Guid,ValX1<Guid[][,,,][]>>().VerifyLayout(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/struct01_seq_ser.csproj b/tests/src/Loader/classloader/generics/Layout/General/struct01_seq_ser.csproj new file mode 100644 index 0000000000..65eae4080f --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/struct01_seq_ser.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>struct01_seq_ser</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="struct01_seq_ser.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/struct02_auto.cs b/tests/src/Loader/classloader/generics/Layout/General/struct02_auto.cs new file mode 100644 index 0000000000..1a5e02d1e7 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/struct02_auto.cs @@ -0,0 +1,179 @@ +// 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.InteropServices; + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + +[StructLayout(LayoutKind.Auto)] +public struct Gen<T,U> +{ + public T Fld10; + + public int _int0; + public double _double0; + public string _string0; + public Guid _Guid0; + + public U Fld20; + + public int _int1; + public double _double1; + public string _string1; + public Guid _Guid1; + + public T Fld11; + public U Fld21; + + public int _int2; + public double _double2; + public string _string2; + public Guid _Guid2; + + public T Fld12; + + public int _int3; + public double _double3; + public string _string3; + public Guid _Guid3; + + public U Fld22; + + public void VerifyLayout() + { + _int0 = 0; + _double0 = 0; + _string0 = "string0"; + _Guid0 = new Guid(); + + _int1 = 1; + _double1 = 1; + _string1 = "string1"; + _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + _int2 = int.MaxValue; + _double2 = double.MaxValue; + _string2 = "string2"; + _Guid2 = new Guid(11,21,31,41,51,61,71,81,91,101,111); + + _int3 = int.MinValue; + _double3 = double.MinValue; + _string3 = "string3"; + _Guid3 = new Guid(12,22,32,42,52,62,72,82,92,102,112); + + Test.Eval(_int0 == 0); + Test.Eval(_int1 == 1); + Test.Eval(_int2 == int.MaxValue) ; + Test.Eval(_int3 == int.MinValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1== 1) ; + Test.Eval(_double2 == double.MaxValue) ; + Test.Eval(_double3 == double.MinValue) ; + Test.Eval(_string0.Equals("string0")); + Test.Eval(_string1.Equals("string1")); + Test.Eval(_string2.Equals("string2")); + Test.Eval(_string3.Equals("string3")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + Test.Eval(_Guid2 == new Guid(11,21,31,41,51,61,71,81,91,101,111)); + Test.Eval(_Guid3 == new Guid(12,22,32,42,52,62,72,82,92,102,112)); + } +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new Gen<int,int>().VerifyLayout(); + new Gen<int,double>().VerifyLayout(); + new Gen<int,string>().VerifyLayout(); + new Gen<int,object>().VerifyLayout(); + new Gen<int,Guid>().VerifyLayout(); + new Gen<int,RefX1<int>>().VerifyLayout(); + new Gen<int,RefX1<string>>().VerifyLayout(); + new Gen<int,RefX1<int[][,,,][]>>().VerifyLayout(); + new Gen<int,ValX1<int>>().VerifyLayout(); + new Gen<int,ValX1<string>>().VerifyLayout(); + new Gen<int,ValX1<int[][,,,][]>>().VerifyLayout(); + + new Gen<double,int>().VerifyLayout(); + new Gen<double,double>().VerifyLayout(); + new Gen<double,string>().VerifyLayout(); + new Gen<double,object>().VerifyLayout(); + new Gen<double,Guid>().VerifyLayout(); + new Gen<double,RefX1<double>>().VerifyLayout(); + new Gen<double,RefX1<string>>().VerifyLayout(); + new Gen<double,RefX1<double[][,,,][]>>().VerifyLayout(); + new Gen<double,ValX1<double>>().VerifyLayout(); + new Gen<double,ValX1<string>>().VerifyLayout(); + new Gen<double,ValX1<double[][,,,][]>>().VerifyLayout(); + + new Gen<string,int>().VerifyLayout(); + new Gen<string,double>().VerifyLayout(); + new Gen<string,string>().VerifyLayout(); + new Gen<string,object>().VerifyLayout(); + new Gen<string,Guid>().VerifyLayout(); + new Gen<string,RefX1<string>>().VerifyLayout(); + new Gen<string,RefX1<string>>().VerifyLayout(); + new Gen<string,RefX1<string[][,,,][]>>().VerifyLayout(); + new Gen<string,ValX1<string>>().VerifyLayout(); + new Gen<string,ValX1<string>>().VerifyLayout(); + new Gen<string,ValX1<string[][,,,][]>>().VerifyLayout(); + + new Gen<object,int>().VerifyLayout(); + new Gen<object,double>().VerifyLayout(); + new Gen<object,string>().VerifyLayout(); + new Gen<object,object>().VerifyLayout(); + new Gen<object,Guid>().VerifyLayout(); + new Gen<object,RefX1<object>>().VerifyLayout(); + new Gen<object,RefX1<string>>().VerifyLayout(); + new Gen<object,RefX1<object[][,,,][]>>().VerifyLayout(); + new Gen<object,ValX1<object>>().VerifyLayout(); + new Gen<object,ValX1<string>>().VerifyLayout(); + new Gen<object,ValX1<object[][,,,][]>>().VerifyLayout(); + + new Gen<Guid,int>().VerifyLayout(); + new Gen<Guid,double>().VerifyLayout(); + new Gen<Guid,string>().VerifyLayout(); + new Gen<Guid,object>().VerifyLayout(); + new Gen<Guid,Guid>().VerifyLayout(); + new Gen<Guid,RefX1<Guid>>().VerifyLayout(); + new Gen<Guid,RefX1<string>>().VerifyLayout(); + new Gen<Guid,RefX1<Guid[][,,,][]>>().VerifyLayout(); + new Gen<Guid,ValX1<Guid>>().VerifyLayout(); + new Gen<Guid,ValX1<string>>().VerifyLayout(); + new Gen<Guid,ValX1<Guid[][,,,][]>>().VerifyLayout(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/struct02_auto.csproj b/tests/src/Loader/classloader/generics/Layout/General/struct02_auto.csproj new file mode 100644 index 0000000000..abfb4bffcd --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/struct02_auto.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>struct02_auto</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="struct02_auto.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/struct02_auto_ser.cs b/tests/src/Loader/classloader/generics/Layout/General/struct02_auto_ser.cs new file mode 100644 index 0000000000..37d26f3e30 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/struct02_auto_ser.cs @@ -0,0 +1,180 @@ +// 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.InteropServices; + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + + +[StructLayout(LayoutKind.Auto)] +public struct Gen<T,U> +{ + public T Fld10; + + public int _int0; + public double _double0; + public string _string0; + public Guid _Guid0; + + public U Fld20; + + public int _int1; + public double _double1; + public string _string1; + public Guid _Guid1; + + public T Fld11; + public U Fld21; + + public int _int2; + public double _double2; + public string _string2; + public Guid _Guid2; + + public T Fld12; + + public int _int3; + public double _double3; + public string _string3; + public Guid _Guid3; + + public U Fld22; + + public void VerifyLayout() + { + _int0 = 0; + _double0 = 0; + _string0 = "string0"; + _Guid0 = new Guid(); + + _int1 = 1; + _double1 = 1; + _string1 = "string1"; + _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + _int2 = int.MaxValue; + _double2 = double.MaxValue; + _string2 = "string2"; + _Guid2 = new Guid(11,21,31,41,51,61,71,81,91,101,111); + + _int3 = int.MinValue; + _double3 = double.MinValue; + _string3 = "string3"; + _Guid3 = new Guid(12,22,32,42,52,62,72,82,92,102,112); + + Test.Eval(_int0 == 0); + Test.Eval(_int1 == 1); + Test.Eval(_int2 == int.MaxValue) ; + Test.Eval(_int3 == int.MinValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1== 1) ; + Test.Eval(_double2 == double.MaxValue) ; + Test.Eval(_double3 == double.MinValue) ; + Test.Eval(_string0.Equals("string0")); + Test.Eval(_string1.Equals("string1")); + Test.Eval(_string2.Equals("string2")); + Test.Eval(_string3.Equals("string3")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + Test.Eval(_Guid2 == new Guid(11,21,31,41,51,61,71,81,91,101,111)); + Test.Eval(_Guid3 == new Guid(12,22,32,42,52,62,72,82,92,102,112)); + } +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new Gen<int,int>().VerifyLayout(); + new Gen<int,double>().VerifyLayout(); + new Gen<int,string>().VerifyLayout(); + new Gen<int,object>().VerifyLayout(); + new Gen<int,Guid>().VerifyLayout(); + new Gen<int,RefX1<int>>().VerifyLayout(); + new Gen<int,RefX1<string>>().VerifyLayout(); + new Gen<int,RefX1<int[][,,,][]>>().VerifyLayout(); + new Gen<int,ValX1<int>>().VerifyLayout(); + new Gen<int,ValX1<string>>().VerifyLayout(); + new Gen<int,ValX1<int[][,,,][]>>().VerifyLayout(); + + new Gen<double,int>().VerifyLayout(); + new Gen<double,double>().VerifyLayout(); + new Gen<double,string>().VerifyLayout(); + new Gen<double,object>().VerifyLayout(); + new Gen<double,Guid>().VerifyLayout(); + new Gen<double,RefX1<double>>().VerifyLayout(); + new Gen<double,RefX1<string>>().VerifyLayout(); + new Gen<double,RefX1<double[][,,,][]>>().VerifyLayout(); + new Gen<double,ValX1<double>>().VerifyLayout(); + new Gen<double,ValX1<string>>().VerifyLayout(); + new Gen<double,ValX1<double[][,,,][]>>().VerifyLayout(); + + new Gen<string,int>().VerifyLayout(); + new Gen<string,double>().VerifyLayout(); + new Gen<string,string>().VerifyLayout(); + new Gen<string,object>().VerifyLayout(); + new Gen<string,Guid>().VerifyLayout(); + new Gen<string,RefX1<string>>().VerifyLayout(); + new Gen<string,RefX1<string>>().VerifyLayout(); + new Gen<string,RefX1<string[][,,,][]>>().VerifyLayout(); + new Gen<string,ValX1<string>>().VerifyLayout(); + new Gen<string,ValX1<string>>().VerifyLayout(); + new Gen<string,ValX1<string[][,,,][]>>().VerifyLayout(); + + new Gen<object,int>().VerifyLayout(); + new Gen<object,double>().VerifyLayout(); + new Gen<object,string>().VerifyLayout(); + new Gen<object,object>().VerifyLayout(); + new Gen<object,Guid>().VerifyLayout(); + new Gen<object,RefX1<object>>().VerifyLayout(); + new Gen<object,RefX1<string>>().VerifyLayout(); + new Gen<object,RefX1<object[][,,,][]>>().VerifyLayout(); + new Gen<object,ValX1<object>>().VerifyLayout(); + new Gen<object,ValX1<string>>().VerifyLayout(); + new Gen<object,ValX1<object[][,,,][]>>().VerifyLayout(); + + new Gen<Guid,int>().VerifyLayout(); + new Gen<Guid,double>().VerifyLayout(); + new Gen<Guid,string>().VerifyLayout(); + new Gen<Guid,object>().VerifyLayout(); + new Gen<Guid,Guid>().VerifyLayout(); + new Gen<Guid,RefX1<Guid>>().VerifyLayout(); + new Gen<Guid,RefX1<string>>().VerifyLayout(); + new Gen<Guid,RefX1<Guid[][,,,][]>>().VerifyLayout(); + new Gen<Guid,ValX1<Guid>>().VerifyLayout(); + new Gen<Guid,ValX1<string>>().VerifyLayout(); + new Gen<Guid,ValX1<Guid[][,,,][]>>().VerifyLayout(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/struct02_auto_ser.csproj b/tests/src/Loader/classloader/generics/Layout/General/struct02_auto_ser.csproj new file mode 100644 index 0000000000..851a133a8b --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/struct02_auto_ser.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>struct02_auto_ser</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="struct02_auto_ser.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/struct02_seq.cs b/tests/src/Loader/classloader/generics/Layout/General/struct02_seq.cs new file mode 100644 index 0000000000..d806a46fcf --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/struct02_seq.cs @@ -0,0 +1,179 @@ +// 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.InteropServices; + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + +[StructLayout(LayoutKind.Sequential)] +public struct Gen<T,U> +{ + public T Fld10; + + public int _int0; + public double _double0; + public string _string0; + public Guid _Guid0; + + public U Fld20; + + public int _int1; + public double _double1; + public string _string1; + public Guid _Guid1; + + public T Fld11; + public U Fld21; + + public int _int2; + public double _double2; + public string _string2; + public Guid _Guid2; + + public T Fld12; + + public int _int3; + public double _double3; + public string _string3; + public Guid _Guid3; + + public U Fld22; + + public void VerifyLayout() + { + _int0 = 0; + _double0 = 0; + _string0 = "string0"; + _Guid0 = new Guid(); + + _int1 = 1; + _double1 = 1; + _string1 = "string1"; + _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + _int2 = int.MaxValue; + _double2 = double.MaxValue; + _string2 = "string2"; + _Guid2 = new Guid(11,21,31,41,51,61,71,81,91,101,111); + + _int3 = int.MinValue; + _double3 = double.MinValue; + _string3 = "string3"; + _Guid3 = new Guid(12,22,32,42,52,62,72,82,92,102,112); + + Test.Eval(_int0 == 0); + Test.Eval(_int1 == 1); + Test.Eval(_int2 == int.MaxValue) ; + Test.Eval(_int3 == int.MinValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1== 1) ; + Test.Eval(_double2 == double.MaxValue) ; + Test.Eval(_double3 == double.MinValue) ; + Test.Eval(_string0.Equals("string0")); + Test.Eval(_string1.Equals("string1")); + Test.Eval(_string2.Equals("string2")); + Test.Eval(_string3.Equals("string3")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + Test.Eval(_Guid2 == new Guid(11,21,31,41,51,61,71,81,91,101,111)); + Test.Eval(_Guid3 == new Guid(12,22,32,42,52,62,72,82,92,102,112)); + } +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new Gen<int,int>().VerifyLayout(); + new Gen<int,double>().VerifyLayout(); + new Gen<int,string>().VerifyLayout(); + new Gen<int,object>().VerifyLayout(); + new Gen<int,Guid>().VerifyLayout(); + new Gen<int,RefX1<int>>().VerifyLayout(); + new Gen<int,RefX1<string>>().VerifyLayout(); + new Gen<int,RefX1<int[][,,,][]>>().VerifyLayout(); + new Gen<int,ValX1<int>>().VerifyLayout(); + new Gen<int,ValX1<string>>().VerifyLayout(); + new Gen<int,ValX1<int[][,,,][]>>().VerifyLayout(); + + new Gen<double,int>().VerifyLayout(); + new Gen<double,double>().VerifyLayout(); + new Gen<double,string>().VerifyLayout(); + new Gen<double,object>().VerifyLayout(); + new Gen<double,Guid>().VerifyLayout(); + new Gen<double,RefX1<double>>().VerifyLayout(); + new Gen<double,RefX1<string>>().VerifyLayout(); + new Gen<double,RefX1<double[][,,,][]>>().VerifyLayout(); + new Gen<double,ValX1<double>>().VerifyLayout(); + new Gen<double,ValX1<string>>().VerifyLayout(); + new Gen<double,ValX1<double[][,,,][]>>().VerifyLayout(); + + new Gen<string,int>().VerifyLayout(); + new Gen<string,double>().VerifyLayout(); + new Gen<string,string>().VerifyLayout(); + new Gen<string,object>().VerifyLayout(); + new Gen<string,Guid>().VerifyLayout(); + new Gen<string,RefX1<string>>().VerifyLayout(); + new Gen<string,RefX1<string>>().VerifyLayout(); + new Gen<string,RefX1<string[][,,,][]>>().VerifyLayout(); + new Gen<string,ValX1<string>>().VerifyLayout(); + new Gen<string,ValX1<string>>().VerifyLayout(); + new Gen<string,ValX1<string[][,,,][]>>().VerifyLayout(); + + new Gen<object,int>().VerifyLayout(); + new Gen<object,double>().VerifyLayout(); + new Gen<object,string>().VerifyLayout(); + new Gen<object,object>().VerifyLayout(); + new Gen<object,Guid>().VerifyLayout(); + new Gen<object,RefX1<object>>().VerifyLayout(); + new Gen<object,RefX1<string>>().VerifyLayout(); + new Gen<object,RefX1<object[][,,,][]>>().VerifyLayout(); + new Gen<object,ValX1<object>>().VerifyLayout(); + new Gen<object,ValX1<string>>().VerifyLayout(); + new Gen<object,ValX1<object[][,,,][]>>().VerifyLayout(); + + new Gen<Guid,int>().VerifyLayout(); + new Gen<Guid,double>().VerifyLayout(); + new Gen<Guid,string>().VerifyLayout(); + new Gen<Guid,object>().VerifyLayout(); + new Gen<Guid,Guid>().VerifyLayout(); + new Gen<Guid,RefX1<Guid>>().VerifyLayout(); + new Gen<Guid,RefX1<string>>().VerifyLayout(); + new Gen<Guid,RefX1<Guid[][,,,][]>>().VerifyLayout(); + new Gen<Guid,ValX1<Guid>>().VerifyLayout(); + new Gen<Guid,ValX1<string>>().VerifyLayout(); + new Gen<Guid,ValX1<Guid[][,,,][]>>().VerifyLayout(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/struct02_seq.csproj b/tests/src/Loader/classloader/generics/Layout/General/struct02_seq.csproj new file mode 100644 index 0000000000..2aeb171f75 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/struct02_seq.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>struct02_seq</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="struct02_seq.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/generics/Layout/General/struct02_seq_ser.cs b/tests/src/Loader/classloader/generics/Layout/General/struct02_seq_ser.cs new file mode 100644 index 0000000000..d7c60532f6 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/struct02_seq_ser.cs @@ -0,0 +1,178 @@ +// 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.InteropServices; + +public struct ValX1<T> {} +public struct ValX2<T,U> {} +public struct ValX3<T,U,V>{} +public class RefX1<T> {} +public class RefX2<T,U> {} +public class RefX3<T,U,V>{} + + +[StructLayout(LayoutKind.Sequential)] +public struct Gen<T,U> +{ + public int _int0; + public double _double0; + public string _string0; + public Guid _Guid0; + + public U Fld20; + + public int _int1; + public double _double1; + public string _string1; + public Guid _Guid1; + + public T Fld11; + public U Fld21; + + public int _int2; + public double _double2; + public string _string2; + public Guid _Guid2; + + public T Fld12; + + public int _int3; + public double _double3; + public string _string3; + public Guid _Guid3; + + public U Fld22; + + public void VerifyLayout() + { + _int0 = 0; + _double0 = 0; + _string0 = "string0"; + _Guid0 = new Guid(); + + _int1 = 1; + _double1 = 1; + _string1 = "string1"; + _Guid1 = new Guid(1,2,3,4,5,6,7,8,9,10,11); + + _int2 = int.MaxValue; + _double2 = double.MaxValue; + _string2 = "string2"; + _Guid2 = new Guid(11,21,31,41,51,61,71,81,91,101,111); + + _int3 = int.MinValue; + _double3 = double.MinValue; + _string3 = "string3"; + _Guid3 = new Guid(12,22,32,42,52,62,72,82,92,102,112); + + Test.Eval(_int0 == 0); + Test.Eval(_int1 == 1); + Test.Eval(_int2 == int.MaxValue) ; + Test.Eval(_int3 == int.MinValue) ; + Test.Eval(_double0 == 0) ; + Test.Eval(_double1== 1) ; + Test.Eval(_double2 == double.MaxValue) ; + Test.Eval(_double3 == double.MinValue) ; + Test.Eval(_string0.Equals("string0")); + Test.Eval(_string1.Equals("string1")); + Test.Eval(_string2.Equals("string2")); + Test.Eval(_string3.Equals("string3")); + Test.Eval(_Guid0 == new Guid()); + Test.Eval(_Guid1 == new Guid(1,2,3,4,5,6,7,8,9,10,11)); + Test.Eval(_Guid2 == new Guid(11,21,31,41,51,61,71,81,91,101,111)); + Test.Eval(_Guid3 == new Guid(12,22,32,42,52,62,72,82,92,102,112)); + } +} + +public class Test +{ + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + new Gen<int,int>().VerifyLayout(); + new Gen<int,double>().VerifyLayout(); + new Gen<int,string>().VerifyLayout(); + new Gen<int,object>().VerifyLayout(); + new Gen<int,Guid>().VerifyLayout(); + new Gen<int,RefX1<int>>().VerifyLayout(); + new Gen<int,RefX1<string>>().VerifyLayout(); + new Gen<int,RefX1<int[][,,,][]>>().VerifyLayout(); + new Gen<int,ValX1<int>>().VerifyLayout(); + new Gen<int,ValX1<string>>().VerifyLayout(); + new Gen<int,ValX1<int[][,,,][]>>().VerifyLayout(); + + new Gen<double,int>().VerifyLayout(); + new Gen<double,double>().VerifyLayout(); + new Gen<double,string>().VerifyLayout(); + new Gen<double,object>().VerifyLayout(); + new Gen<double,Guid>().VerifyLayout(); + new Gen<double,RefX1<double>>().VerifyLayout(); + new Gen<double,RefX1<string>>().VerifyLayout(); + new Gen<double,RefX1<double[][,,,][]>>().VerifyLayout(); + new Gen<double,ValX1<double>>().VerifyLayout(); + new Gen<double,ValX1<string>>().VerifyLayout(); + new Gen<double,ValX1<double[][,,,][]>>().VerifyLayout(); + + new Gen<string,int>().VerifyLayout(); + new Gen<string,double>().VerifyLayout(); + new Gen<string,string>().VerifyLayout(); + new Gen<string,object>().VerifyLayout(); + new Gen<string,Guid>().VerifyLayout(); + new Gen<string,RefX1<string>>().VerifyLayout(); + new Gen<string,RefX1<string>>().VerifyLayout(); + new Gen<string,RefX1<string[][,,,][]>>().VerifyLayout(); + new Gen<string,ValX1<string>>().VerifyLayout(); + new Gen<string,ValX1<string>>().VerifyLayout(); + new Gen<string,ValX1<string[][,,,][]>>().VerifyLayout(); + + new Gen<object,int>().VerifyLayout(); + new Gen<object,double>().VerifyLayout(); + new Gen<object,string>().VerifyLayout(); + new Gen<object,object>().VerifyLayout(); + new Gen<object,Guid>().VerifyLayout(); + new Gen<object,RefX1<object>>().VerifyLayout(); + new Gen<object,RefX1<string>>().VerifyLayout(); + new Gen<object,RefX1<object[][,,,][]>>().VerifyLayout(); + new Gen<object,ValX1<object>>().VerifyLayout(); + new Gen<object,ValX1<string>>().VerifyLayout(); + new Gen<object,ValX1<object[][,,,][]>>().VerifyLayout(); + + new Gen<Guid,int>().VerifyLayout(); + new Gen<Guid,double>().VerifyLayout(); + new Gen<Guid,string>().VerifyLayout(); + new Gen<Guid,object>().VerifyLayout(); + new Gen<Guid,Guid>().VerifyLayout(); + new Gen<Guid,RefX1<Guid>>().VerifyLayout(); + new Gen<Guid,RefX1<string>>().VerifyLayout(); + new Gen<Guid,RefX1<Guid[][,,,][]>>().VerifyLayout(); + new Gen<Guid,ValX1<Guid>>().VerifyLayout(); + new Gen<Guid,ValX1<string>>().VerifyLayout(); + new Gen<Guid,ValX1<Guid[][,,,][]>>().VerifyLayout(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } + +} diff --git a/tests/src/Loader/classloader/generics/Layout/General/struct02_seq_ser.csproj b/tests/src/Loader/classloader/generics/Layout/General/struct02_seq_ser.csproj new file mode 100644 index 0000000000..52678661dd --- /dev/null +++ b/tests/src/Loader/classloader/generics/Layout/General/struct02_seq_ser.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>struct02_seq_ser</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="struct02_seq_ser.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> |