summaryrefslogtreecommitdiff
path: root/tests/src/baseservices
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/baseservices')
-rw-r--r--tests/src/baseservices/compilerservices/FixedAddressValueType/FixedAddressValueType.cs60
-rw-r--r--tests/src/baseservices/compilerservices/FixedAddressValueType/FixedAddressValueType.csproj44
-rw-r--r--tests/src/baseservices/compilerservices/RuntimeHelpers/ExecuteCodeWithGuaranteedCleanup.cs62
-rw-r--r--tests/src/baseservices/compilerservices/RuntimeHelpers/ExecuteCodeWithGuaranteedCleanup.csproj42
-rw-r--r--tests/src/baseservices/compilerservices/RuntimeWrappedException/RuntimeWrappedException.cs63
-rw-r--r--tests/src/baseservices/compilerservices/RuntimeWrappedException/RuntimeWrappedException.csproj45
-rw-r--r--tests/src/baseservices/compilerservices/RuntimeWrappedException/StringThrower.il40
-rw-r--r--tests/src/baseservices/compilerservices/RuntimeWrappedException/StringThrower.ilproj40
-rw-r--r--tests/src/baseservices/compilerservices/modulector/moduleCctor.il110
-rw-r--r--tests/src/baseservices/compilerservices/modulector/moduleCctor.ilproj40
-rw-r--r--tests/src/baseservices/compilerservices/modulector/runmoduleconstructor.cs38
-rw-r--r--tests/src/baseservices/compilerservices/modulector/runmoduleconstructor.csproj45
12 files changed, 629 insertions, 0 deletions
diff --git a/tests/src/baseservices/compilerservices/FixedAddressValueType/FixedAddressValueType.cs b/tests/src/baseservices/compilerservices/FixedAddressValueType/FixedAddressValueType.cs
new file mode 100644
index 0000000000..bf10d817e5
--- /dev/null
+++ b/tests/src/baseservices/compilerservices/FixedAddressValueType/FixedAddressValueType.cs
@@ -0,0 +1,60 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+using System;
+using System.Runtime.CompilerServices;
+
+public struct Age {
+ public int years;
+ public int months;
+}
+
+public class FreeClass
+{
+ public static Age FreeAge;
+
+ public static unsafe IntPtr AddressOfFreeAge()
+ {
+ fixed (Age* pointer = &FreeAge)
+ { return (IntPtr) pointer; }
+ }
+}
+
+public class FixedClass
+{
+ [FixedAddressValueType]
+ public static Age FixedAge;
+
+ public static unsafe IntPtr AddressOfFixedAge()
+ {
+ fixed (Age* pointer = &FixedAge)
+ { return (IntPtr) pointer; }
+ }
+}
+
+public class Example
+{
+ public static int Main()
+ {
+ // Get addresses of static Age fields.
+ IntPtr freePtr1 = FreeClass.AddressOfFreeAge();
+
+ IntPtr fixedPtr1 = FixedClass.AddressOfFixedAge();
+
+ // Garbage collection.
+ GC.Collect(3, GCCollectionMode.Forced, true, true);
+ GC.WaitForPendingFinalizers();
+
+ // Get addresses of static Age fields after garbage collection.
+ IntPtr freePtr2 = FreeClass.AddressOfFreeAge();
+ IntPtr fixedPtr2 = FixedClass.AddressOfFixedAge();
+
+ if(freePtr1 != freePtr2 && fixedPtr1 == fixedPtr2)
+ {
+ return 100;
+ }
+
+ return -1;
+ }
+}
diff --git a/tests/src/baseservices/compilerservices/FixedAddressValueType/FixedAddressValueType.csproj b/tests/src/baseservices/compilerservices/FixedAddressValueType/FixedAddressValueType.csproj
new file mode 100644
index 0000000000..19a779194f
--- /dev/null
+++ b/tests/src/baseservices/compilerservices/FixedAddressValueType/FixedAddressValueType.csproj
@@ -0,0 +1,44 @@
+<?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>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <CLRTestKind>BuildAndRun</CLRTestKind>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <GCStressIncompatible>true</GCStressIncompatible>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <!-- Add Compile Object Here -->
+ <Compile Include="FixedAddressValueType.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <NoWarn Include="42016,42020,42025,42024" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+ </PropertyGroup>
+</Project>
diff --git a/tests/src/baseservices/compilerservices/RuntimeHelpers/ExecuteCodeWithGuaranteedCleanup.cs b/tests/src/baseservices/compilerservices/RuntimeHelpers/ExecuteCodeWithGuaranteedCleanup.cs
new file mode 100644
index 0000000000..58cee3ca36
--- /dev/null
+++ b/tests/src/baseservices/compilerservices/RuntimeHelpers/ExecuteCodeWithGuaranteedCleanup.cs
@@ -0,0 +1,62 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+using System;
+using System.Runtime.CompilerServices;
+
+namespace GCD
+{
+ /// <summary>
+ /// Summary description for Class1.
+ /// </summary>
+ class GCD
+ {
+ private int _val = -2;
+ private int _exitcode = -1;
+ public GCD() {}
+ public int GetExitCode(){ return _exitcode;}
+ public void g ()
+ {
+ throw new System.Exception("TryCode test");
+ }
+ public void TryCode0 (object obj)
+ {
+ _val = (int)obj;
+ g();
+ }
+ public void CleanupCode0 (object obj, bool excpThrown)
+ {
+ if(excpThrown && ((int)obj == _val))
+ {
+ _exitcode = 100;
+ }
+ }
+ }
+
+
+ class GCDTest
+ {
+ /// <summary>
+ /// The main entry point for the application.
+ /// </summary>
+ [STAThread]
+ static int Main(string[] args)
+ {
+ GCD gcd = new GCD();
+ RuntimeHelpers.TryCode t = new RuntimeHelpers.TryCode(gcd.TryCode0);
+ RuntimeHelpers.CleanupCode c = new RuntimeHelpers.CleanupCode(gcd.CleanupCode0);
+ int val = 21;
+ try
+ {
+ RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(t, c, val);
+ }
+ catch (Exception Ex)
+ {
+
+ }
+
+ return gcd.GetExitCode();
+ }
+ }
+}
diff --git a/tests/src/baseservices/compilerservices/RuntimeHelpers/ExecuteCodeWithGuaranteedCleanup.csproj b/tests/src/baseservices/compilerservices/RuntimeHelpers/ExecuteCodeWithGuaranteedCleanup.csproj
new file mode 100644
index 0000000000..605d11b1f1
--- /dev/null
+++ b/tests/src/baseservices/compilerservices/RuntimeHelpers/ExecuteCodeWithGuaranteedCleanup.csproj
@@ -0,0 +1,42 @@
+<?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>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <CLRTestKind>BuildAndRun</CLRTestKind>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <!-- Add Compile Object Here -->
+ <Compile Include="ExecuteCodeWithGuaranteedCleanup.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <NoWarn Include="42016,42020,42025,42024" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+ </PropertyGroup>
+</Project>
diff --git a/tests/src/baseservices/compilerservices/RuntimeWrappedException/RuntimeWrappedException.cs b/tests/src/baseservices/compilerservices/RuntimeWrappedException/RuntimeWrappedException.cs
new file mode 100644
index 0000000000..29fb347ae1
--- /dev/null
+++ b/tests/src/baseservices/compilerservices/RuntimeWrappedException/RuntimeWrappedException.cs
@@ -0,0 +1,63 @@
+// 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.IO;
+using System.Runtime.CompilerServices;
+using System.Runtime.Serialization;
+
+class Test
+{
+ public static int Main(string[] args)
+ {
+ int retVal = 0;
+ var thrower = new StringThrowerClass();
+ try
+ {
+ thrower.InstanceMethod();
+ }
+
+ catch (RuntimeWrappedException ex)
+ {
+
+ if ( !ex.WrappedException.ToString().Contains("Inside StringThrower") )
+ {
+// Console.WriteLine("Incorrect exception and/or message. Expected RuntimeWrappedException: An object that does not derive "+
+// "from System.Exception has been wrapped in a RuntimeWrappedException.\n But actually got: " + ex.InnerException);
+ retVal = -1;
+ }
+
+ StreamingContext ctx;
+
+// TODO: Expose once we have access to FormatterConverter
+// var info = new SerializationInfo(typeof(RuntimeWrappedException), new FormatterConverter());
+// ex.GetObjectData(info,ctx);
+//
+ try
+ {
+ ex.GetObjectData(null,ctx);
+ }
+ catch (ArgumentNullException ex1)
+ {
+ retVal = 100;
+ }
+ catch (Exception ex1)
+ {
+ retVal = -1;
+ }
+
+
+ }
+ catch (Exception ex)
+ {
+// Console.WriteLine("Incorrect exception thrown. Expected RuntimeWrappedException, but actually got: " + ex);
+ retVal = -2;
+ }
+
+
+ return retVal;
+
+
+ }
+}
diff --git a/tests/src/baseservices/compilerservices/RuntimeWrappedException/RuntimeWrappedException.csproj b/tests/src/baseservices/compilerservices/RuntimeWrappedException/RuntimeWrappedException.csproj
new file mode 100644
index 0000000000..4b0c5cf68d
--- /dev/null
+++ b/tests/src/baseservices/compilerservices/RuntimeWrappedException/RuntimeWrappedException.csproj
@@ -0,0 +1,45 @@
+<?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>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <CLRTestKind>BuildAndRun</CLRTestKind>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <!-- Add Compile Object Here -->
+ <Compile Include="RuntimeWrappedException.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="StringThrower.ilproj" />
+ </ItemGroup>
+ <ItemGroup>
+ <NoWarn Include="42016,42020,42025,42024" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+ </PropertyGroup>
+</Project>
diff --git a/tests/src/baseservices/compilerservices/RuntimeWrappedException/StringThrower.il b/tests/src/baseservices/compilerservices/RuntimeWrappedException/StringThrower.il
new file mode 100644
index 0000000000..92c9139f7c
--- /dev/null
+++ b/tests/src/baseservices/compilerservices/RuntimeWrappedException/StringThrower.il
@@ -0,0 +1,40 @@
+// 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.
+
+.assembly extern mscorlib
+{
+ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
+ .ver 2:0:0:0
+}
+
+.assembly StringThrower {}
+
+.class public auto ansi StringThrowerClass
+ extends [mscorlib]System.Object
+{
+ .field public static int32 intStatic
+
+
+ .method public hidebysig instance void
+ InstanceMethod() cil managed noinlining
+ {
+ .maxstack 8
+
+ ldstr "Inside StringThrower"
+ throw
+ ret
+ } // end of method A::methodA
+
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+
+ .maxstack 8
+ ldarg.0
+ call instance void class [mscorlib]System.Object::.ctor()
+ ret
+ } // end of method Test1::.ctor
+
+}
diff --git a/tests/src/baseservices/compilerservices/RuntimeWrappedException/StringThrower.ilproj b/tests/src/baseservices/compilerservices/RuntimeWrappedException/StringThrower.ilproj
new file mode 100644
index 0000000000..79667cc7c6
--- /dev/null
+++ b/tests/src/baseservices/compilerservices/RuntimeWrappedException/StringThrower.ilproj
@@ -0,0 +1,40 @@
+<?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>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <AssemblyName>$(MSBuildProjectName)</AssemblyName>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <PropertyGroup>
+
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="StringThrower.il" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+ </PropertyGroup>
+</Project>
diff --git a/tests/src/baseservices/compilerservices/modulector/moduleCctor.il b/tests/src/baseservices/compilerservices/modulector/moduleCctor.il
new file mode 100644
index 0000000000..06bf6ac12c
--- /dev/null
+++ b/tests/src/baseservices/compilerservices/modulector/moduleCctor.il
@@ -0,0 +1,110 @@
+// 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.
+
+.assembly extern mscorlib
+{
+ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
+ .ver 2:0:0:0
+}
+
+.assembly moduleCctor {}
+.assembly extern FieldTypes
+{
+ .publickeytoken = (C0 30 5C 36 38 0B A4 29 ) // .0\68..)
+ .ver 0:0:0:0
+}
+
+ .method private hidebysig specialname rtspecialname static
+ void .cctor() cil managed
+ {
+ .maxstack 8
+ nop
+ ldsfld int32 IntHolder::val
+ ldc.i4.1
+ add
+ stsfld int32 IntHolder::val
+// ldstr "modCctor.txt"
+// ldstr "inside .cctor"
+// call void [mscorlib]System.IO.File::WriteAllText(string,
+// string)
+ ret
+ } // end of method Foo::.cctor
+
+
+// =============== CLASS MEMBERS DECLARATION ===================
+.class public auto ansi beforefieldinit IntHolder
+ extends [mscorlib]System.Object
+{
+ // Fields
+ .field public static int32 val
+
+ // Methods
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor () cil managed
+ {
+ // Method begins at RVA 0x2050
+ // Code size 8 (0x8)
+ .maxstack 8
+
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: nop
+ IL_0007: ret
+ } // end of method IntHolder::.ctor
+
+ .method private hidebysig specialname rtspecialname static
+ void .cctor () cil managed
+ {
+ // Method begins at RVA 0x2059
+ // Code size 7 (0x7)
+ .maxstack 8
+
+ IL_0000: ldc.i4.0
+ IL_0001: stsfld int32 IntHolder::val
+ IL_0006: ret
+ } // end of method IntHolder::.cctor
+
+ .method public hidebysig static
+ void Assign (
+ int32 arg
+ ) cil managed
+ {
+ // Method begins at RVA 0x2078
+ // Code size 8 (0x8)
+ .maxstack 8
+
+ IL_0000: nop
+ IL_0001: ldarg.0
+ IL_0002: stsfld int32 IntHolder::val
+ IL_0007: ret
+ } // end of method IntHolder::Assign
+ .method public hidebysig static
+ void Check (
+ int32 arg
+ ) cil managed
+ {
+ // Method begins at RVA 0x2050
+ // Code size 28 (0x1c)
+ .maxstack 2
+ .locals init (
+ [0] bool
+ )
+
+ IL_0000: nop
+ IL_0001: ldsfld int32 IntHolder::val
+ IL_0006: ldarg.0
+ IL_0007: ceq
+ IL_0009: ldc.i4.0
+ IL_000a: ceq
+ IL_000c: stloc.0
+ IL_000d: ldloc.0
+ IL_000e: brfalse.s IL_001b
+
+ IL_0010: ldstr "Mod Ctor did not functon correctly"
+ IL_0015: newobj instance void [mscorlib]System.Exception::.ctor(string)
+ IL_001a: throw
+
+ IL_001b: ret
+ } // end of method IntHolder::Check
+} // end of class IntHolder
diff --git a/tests/src/baseservices/compilerservices/modulector/moduleCctor.ilproj b/tests/src/baseservices/compilerservices/modulector/moduleCctor.ilproj
new file mode 100644
index 0000000000..c846e02edb
--- /dev/null
+++ b/tests/src/baseservices/compilerservices/modulector/moduleCctor.ilproj
@@ -0,0 +1,40 @@
+<?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>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <AssemblyName>$(MSBuildProjectName)</AssemblyName>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <PropertyGroup>
+
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="moduleCctor.il" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+ </PropertyGroup>
+</Project>
diff --git a/tests/src/baseservices/compilerservices/modulector/runmoduleconstructor.cs b/tests/src/baseservices/compilerservices/modulector/runmoduleconstructor.cs
new file mode 100644
index 0000000000..d1192f167a
--- /dev/null
+++ b/tests/src/baseservices/compilerservices/modulector/runmoduleconstructor.cs
@@ -0,0 +1,38 @@
+// 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.Reflection;
+using System.IO;
+using System.Runtime.Loader;
+using System.Runtime.CompilerServices;
+using System.Globalization;
+
+class RuntimeHelperTest
+{
+ public static int Main(string[] args)
+ {
+ AssemblyLoadContext resolver0 = AssemblyLoadContext.Default;
+ Assembly asm0 = resolver0.LoadFromAssemblyName(new AssemblyName("moduleCctor"));
+ Module mod = asm0.ManifestModule;
+
+ RuntimeHelpers.RunModuleConstructor(mod.ModuleHandle);
+ var oType = asm0.GetType("IntHolder",true);
+ MethodInfo check = oType.GetMethod("Check");
+ MethodInfo assign = oType.GetMethod("Assign");
+
+ object[] initial = {1};
+ object[] final = {100};
+
+ check.Invoke(null, initial);
+ assign.Invoke(null, final);
+ check.Invoke(null, final);
+ RuntimeHelpers.RunModuleConstructor(mod.ModuleHandle);
+ check.Invoke(null, final);
+
+
+ return 100;
+
+ }
+}
diff --git a/tests/src/baseservices/compilerservices/modulector/runmoduleconstructor.csproj b/tests/src/baseservices/compilerservices/modulector/runmoduleconstructor.csproj
new file mode 100644
index 0000000000..fff05ea610
--- /dev/null
+++ b/tests/src/baseservices/compilerservices/modulector/runmoduleconstructor.csproj
@@ -0,0 +1,45 @@
+<?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>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <ReferenceLocalMscorlib>true</ReferenceLocalMscorlib>
+ <CLRTestKind>BuildAndRun</CLRTestKind>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <!-- Add Compile Object Here -->
+ <Compile Include="runmoduleconstructor.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="moduleCctor.ilproj" />
+ </ItemGroup>
+ <ItemGroup>
+ <NoWarn Include="42016,42020,42025,42024" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+ </PropertyGroup>
+</Project>