diff options
author | Tijoy Tom Kalathiparambil <tijoytk@microsoft.com> | 2016-04-05 13:04:42 -0700 |
---|---|---|
committer | Tijoy Tom Kalathiparambil <tijoytk@microsoft.com> | 2016-04-05 13:04:42 -0700 |
commit | 476dd472311aaeaef8b898e1971989c75f387fcd (patch) | |
tree | cbe95dffa6574b52d3666c922aa07504dd8e9ca8 /tests/src | |
parent | c957dc17ff20cb3e3d14e84b1c62973598543104 (diff) | |
parent | caa979f987c90be2075183a9a819ae110957a2ee (diff) | |
download | coreclr-476dd472311aaeaef8b898e1971989c75f387fcd.tar.gz coreclr-476dd472311aaeaef8b898e1971989c75f387fcd.tar.bz2 coreclr-476dd472311aaeaef8b898e1971989c75f387fcd.zip |
Merge branch 'master' of https://github.com/dotnet/coreclr
Diffstat (limited to 'tests/src')
58 files changed, 2680 insertions, 614 deletions
diff --git a/tests/src/CLRTest.Execute.Bash.targets b/tests/src/CLRTest.Execute.Bash.targets index 08fe48063a..d4bef47283 100644 --- a/tests/src/CLRTest.Execute.Bash.targets +++ b/tests/src/CLRTest.Execute.Bash.targets @@ -19,9 +19,9 @@ WARNING: When setting properties based on their current state (for example: <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup> - <CLRTestBashEnvironmentVariable Condition="'$(CrossGen)' == 'true'" Include="complus_zaprequire=2" /> - <CLRTestBashEnvironmentVariable Condition="'$(CrossGen)' == 'true'" Include="complus_zaprequireexcludelist=corerun" /> - <CLRTestBashEnvironmentVariable Condition="'$(GCStressLevel)' != '' and '$(GCStressLevel)' != '0'" Include="complus_gcstress=$(GCStressLevel)" /> + <CLRTestBashEnvironmentVariable Condition="'$(CrossGen)' == 'true'" Include="export complus_zaprequire=2" /> + <CLRTestBashEnvironmentVariable Condition="'$(CrossGen)' == 'true'" Include="export complus_zaprequireexcludelist=corerun" /> + <CLRTestBashEnvironmentVariable Condition="'$(GCStressLevel)' != '' and '$(GCStressLevel)' != '0'" Include="export complus_gcstress=$(GCStressLevel)" /> </ItemGroup> <!-- @@ -38,7 +38,13 @@ WARNING: When setting properties based on their current state (for example: <CrossgenBashScript Condition="'$(CLRTestKind)' == 'RunOnly'"> <![CDATA[ if [ ! -f $([MSBuild]::MakeRelative($(OutputPath), $(_CLRTestToRunFileFullPath)).Replace("\","/").Replace(".exe", ".ni.exe")) ]; then - "$CORE_ROOT/crossgen.exe" /Platform_Assemblies_Paths $CORE_ROOT%3B. $([MSBuild]::MakeRelative($(OutputPath), $(_CLRTestToRunFileFullPath)).Replace("\","/")) + "$CORE_ROOT/crossgen" /Platform_Assemblies_Paths $CORE_ROOT%3A$PWD $([MSBuild]::MakeRelative($(OutputPath), $(_CLRTestToRunFileFullPath)).Replace("\","/")) + __cgExitCode=$? + if [ ! $__cgExitCode == 0 ] + then + echo Crossgen failed with exitcode: $__cgExitCode + exit 1 + fi fi ]]> </CrossgenBashScript> @@ -46,7 +52,14 @@ fi <CrossgenBashScript Condition="'$(CLRTestKind)' == 'BuildAndRun'"> <![CDATA[ if [ ! -f $(MSBuildProjectName).ni.exe ]; then - "$CORE_ROOT/crossgen" /Platform_Assemblies_Paths $CORE_ROOT%3B$PWD $(MSBuildProjectName).exe + echo "$CORE_ROOT/crossgen" /Platform_Assemblies_Paths $CORE_ROOT%3A$PWD $(MSBuildProjectName).exe + "$CORE_ROOT/crossgen" /Platform_Assemblies_Paths $CORE_ROOT%3A$PWD $(MSBuildProjectName).exe + __cgExitCode=$? + if [ ! $__cgExitCode == 0 ] + then + echo Crossgen failed with exitcode: $__cgExitCode + exit 1 + fi fi ]]> </CrossgenBashScript> diff --git a/tests/src/CLRTest.Execute.Batch.targets b/tests/src/CLRTest.Execute.Batch.targets index 4d0f6959d1..03fb5b73e1 100644 --- a/tests/src/CLRTest.Execute.Batch.targets +++ b/tests/src/CLRTest.Execute.Batch.targets @@ -36,12 +36,25 @@ WARNING: When setting properties based on their current state (for example: <!-- CrossGen will create output if it needs to crossgen. Otherwise there will be silence. --> <CrossgenBatchScript Condition="'$(CLRTestKind)' == 'RunOnly'"> <![CDATA[ -if not exist "$([MSBuild]::MakeRelative($(OutputPath), $(_CLRTestToRunFileFullPath)).Replace(".exe", ".ni.exe"))""%CORE_ROOT%\crossgen.exe" /Platform_Assemblies_Paths %CORE_ROOT%%3B. $([MSBuild]::MakeRelative($(OutputPath), $(_CLRTestToRunFileFullPath))) +if not exist "$([MSBuild]::MakeRelative($(OutputPath), $(_CLRTestToRunFileFullPath)).Replace(".exe", ".ni.exe"))" ( +"%CORE_ROOT%\crossgen.exe" /Platform_Assemblies_Paths %CORE_ROOT%%3B%~dp0 $([MSBuild]::MakeRelative($(OutputPath), $(_CLRTestToRunFileFullPath))) +IF NOT "!ERRORLEVEL!"=="0" ( + ECHO Crossgen failed with exitcode - !ERRORLEVEL! + Exit /b 1 + ) +) ]]> </CrossgenBatchScript> <CrossgenBatchScript Condition="'$(CLRTestKind)' == 'BuildAndRun'"> <![CDATA[ -if not exist "$(MSBuildProjectName).ni.exe" "%CORE_ROOT%\crossgen.exe" /Platform_Assemblies_Paths %CORE_ROOT%%3B%~dp0 $(MSBuildProjectName).exe +if not exist "$(MSBuildProjectName).ni.exe" ( + echo "%CORE_ROOT%\crossgen.exe" /Platform_Assemblies_Paths %CORE_ROOT%%3B%~dp0 $(MSBuildProjectName).exe + "%CORE_ROOT%\crossgen.exe" /Platform_Assemblies_Paths %CORE_ROOT%%3B%~dp0 $(MSBuildProjectName).exe + IF NOT "!ERRORLEVEL!"=="0" ( + ECHO Crossgen failed with exitcode - !ERRORLEVEL! + Exit /b 1 + ) + ) ]]> </CrossgenBatchScript> </PropertyGroup> diff --git a/tests/src/GC/API/WeakReference/Finalize2.cs b/tests/src/GC/API/WeakReference/Finalize2.cs index 84aa27bafb..52e12a0a8c 100644 --- a/tests/src/GC/API/WeakReference/Finalize2.cs +++ b/tests/src/GC/API/WeakReference/Finalize2.cs @@ -8,6 +8,7 @@ */ using System; +using System.Runtime.CompilerServices; public class GetTargetTest { @@ -121,16 +122,20 @@ public class IsAliveTest public class NullHandle { + public static GetTargetTest getTargetTest; + public static SetTargetTest setTargetTest; + public static IsAliveTest isAliveTest; + public bool RunTests(bool trackResurrection) { - GetTargetTest d1 = new GetTargetTest(trackResurrection); - SetTargetTest d2 = new SetTargetTest(trackResurrection); - IsAliveTest d3 = new IsAliveTest(trackResurrection); + CreateGetTargetTest(trackResurrection); + CreateSetTargetTest(trackResurrection); + CreateIsAliveTest(trackResurrection); // make sure Finalizers are called - d1 = null; - d2 = null; - d3 = null; + DestroyGetTargetTest(); + DestroySetTargetTest(); + DestroyIsAliveTest(); GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); @@ -139,7 +144,42 @@ public class NullHandle return ((GetTargetTest.Passed) && (SetTargetTest.Passed) && (IsAliveTest.Passed)); } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public static void CreateGetTargetTest(bool trackResurrection) + { + getTargetTest = new GetTargetTest(trackResurrection); + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public static void CreateSetTargetTest(bool trackResurrection) + { + setTargetTest = new SetTargetTest(trackResurrection); + } + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public static void CreateIsAliveTest(bool trackResurrection) + { + isAliveTest = new IsAliveTest(trackResurrection); + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public static void DestroyGetTargetTest() + { + getTargetTest = null; + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public static void DestroySetTargetTest() + { + setTargetTest = null; + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public static void DestroyIsAliveTest() + { + isAliveTest = null; + } public static int Main() { diff --git a/tests/src/GC/API/WeakReference/IsAlive.cs b/tests/src/GC/API/WeakReference/IsAlive.cs index fae70e1e8a..6192d92364 100644 --- a/tests/src/GC/API/WeakReference/IsAlive.cs +++ b/tests/src/GC/API/WeakReference/IsAlive.cs @@ -7,10 +7,23 @@ using System; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; public class Test { + public static int[] array; + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public static void CreateArray() { + array = new int[50]; + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public static void DestroyArray() { + array = null; + } + public static int Main() { - int[] array = new int[50]; + CreateArray(); WeakReference weak = new WeakReference(array); @@ -23,7 +36,7 @@ public class Test { } //else, do an expicit collect. - array=null; + DestroyArray(); GC.Collect(); bool ans2 = weak.IsAlive; diff --git a/tests/src/GC/API/WeakReference/IsAlive_neg.cs b/tests/src/GC/API/WeakReference/IsAlive_neg.cs index 31ce677e38..c1b9ba8407 100644 --- a/tests/src/GC/API/WeakReference/IsAlive_neg.cs +++ b/tests/src/GC/API/WeakReference/IsAlive_neg.cs @@ -7,15 +7,28 @@ using System; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; public class Test { + public static int[] array; + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public static void CreateArray() { + array = new int[50]; + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public static void DestroyArray() { + array = null; + } + public static int Main() { - int[] array = new int[50]; + CreateArray(); WeakReference weak = new WeakReference(array); // array has ONLY a weakreference // ensuring that GC happens even with /debug mode - array=null; + DestroyArray(); GC.Collect(); diff --git a/tests/src/GC/API/WeakReference/NullHandle.cs b/tests/src/GC/API/WeakReference/NullHandle.cs index eb9cf61b4b..d1be07003b 100644 --- a/tests/src/GC/API/WeakReference/NullHandle.cs +++ b/tests/src/GC/API/WeakReference/NullHandle.cs @@ -24,17 +24,24 @@ public class WR : WeakReference public class Test { + // This weak reference gets resurrected by WR's destructor. public static WR w; + + // This weak reference is destroyed to prompt WR's destructor to run. + public static WR wr; [MethodImplAttribute(MethodImplOptions.NoInlining)] - public static WR ReturnWR() { return new WR(new Object()); } + public static void CreateWR() { wr = new WR(new Object()); } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public static void DestroyWR() { wr = null; } public static int Main() { int numTests = 0; int numPassed = 0; - WR wr = ReturnWR(); - wr = null; + CreateWR(); + DestroyWR(); // this will resurrect wr GC.Collect(); diff --git a/tests/src/GC/API/WeakReference/Target.cs b/tests/src/GC/API/WeakReference/Target.cs index f30c3535d8..64d2a2bb36 100644 --- a/tests/src/GC/API/WeakReference/Target.cs +++ b/tests/src/GC/API/WeakReference/Target.cs @@ -7,6 +7,7 @@ using System; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; public class Dummy { @@ -20,22 +21,34 @@ public class Dummy public class Test { + public static int[] array; + public static Object[] obj; + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public static void CreateArrays() + { + array = new int[50]; + obj = new Object[25]; + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public static void DestroyArrays() + { + array = null; + obj = null; + } + public bool GetTargetTest() { - int[] array = new int[50]; - Object[] obj = new Object[25]; - + CreateArrays(); WeakReference weakarray = new WeakReference(array); // array has only weak reference // obj has both strong and weak ref and so should not get collected WeakReference weakobj = new WeakReference(obj); GCHandle objhandle = GCHandle.Alloc(obj, GCHandleType.Normal); - - // ensuring GC.Collect() occurs even with /debug option - array = null; - obj = null; - + + DestroyArrays(); GC.Collect(); Object target1 = weakarray.Target; // should be null diff --git a/tests/src/GC/Features/Finalizer/finalizeother/finalizedirectedgraph.cs b/tests/src/GC/Features/Finalizer/finalizeother/finalizedirectedgraph.cs deleted file mode 100644 index 8d486f22ec..0000000000 --- a/tests/src/GC/Features/Finalizer/finalizeother/finalizedirectedgraph.cs +++ /dev/null @@ -1,262 +0,0 @@ -// 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. - -// Build a Directed Graph with 10 nodes - -namespace Default { - -using System; - -public class Graph -{ - private Vertex Vfirst = null; - private Vertex Vlast = null; - private Edge Efirst = null; - private Edge Elast = null; - private int WeightSum = 0; - - public static int Nodes; - - - public Graph(int n) { Nodes = n;} - - public void SetWeightSum() { - Edge temp = Efirst; - WeightSum = 0; - while(temp != null) { - WeightSum += temp.Weight; - temp = temp.Next; - } - } - - public int GetWeightSum() { - return WeightSum; - } - - public void BuildEdge(int v1,int v2) { - Vertex n1 = null,n2 = null; - Vertex temp = Vfirst; - - while(temp != null) { - if (v1 == temp.Name) - { - //found 1st node.. - n1 = temp; - break; - } - else temp = temp.Next; - } - - //check if edge already exists - for(int i=0;i<n1.Num_Edges;i++) { - - if (v2 == n1.Adjacent[i].Name) return; - } - - temp = Vfirst; - while(temp != null) { - if (v2 == temp.Name) - { - //found 2nd node.. - n2 = temp; - break; - } - else temp = temp.Next; - } - - n1.Adjacent[n1.Num_Edges++]=n2; - - Edge temp2 = new Edge(n1,n2); - if(Efirst==null) { - Efirst = temp2; - Elast = temp2; - } - else { - temp2.AddEdge(Elast,temp2); - Elast = temp2; - } - } - - public void BuildGraph() { - - // Build Nodes - Console.WriteLine("Building Vertices..."); - for(int i=0;i< Nodes; i++) { - Vertex temp = new Vertex(i); - if(Vfirst==null) { - Vfirst = temp; - Vlast = temp; - } - else { - temp.AddVertex(Vlast,temp); - Vlast = temp; - } - } - - // Build Edges - Console.WriteLine("Building Edges..."); - - Int32 seed = System.Environment.TickCount; - Random rand = new Random(seed); - - for(int i=0;i< Nodes;i++) { - - int j = rand.Next(0,Nodes); - for(int k=0;k<j;k++) { - int v2; - while((v2 = rand.Next(0,Nodes))==i); //select a random node, also avoid self-loops - BuildEdge(i,v2); //build edge betn node i and v2 - - - } - } - } - - - public void CheckIfReachable() { - int[] temp = new int[Nodes]; - Vertex t1 = Vfirst; - - Console.WriteLine("Making all vertices reachable..."); - while(t1 != null) { - for(int i=0;i<t1.Num_Edges;i++) { - if(temp[t1.Adjacent[i].Name] == 0) - temp[t1.Adjacent[i].Name]=1; - } - t1 = t1.Next; - } - - for(int v2=0;v2<Nodes;v2++) { - if(temp[v2]==0) { //this vertex is not connected - Int32 seed = System.Environment.TickCount; - Random rand = new Random(seed); - int v1; - while((v1 = rand.Next(0,Nodes))==v2); //select a random node, also avoid self-loops - BuildEdge(v1,v2); - temp[v2]=1; - } - } - - } - - - public void DeleteVertex() { - - DeleteVertex(Vfirst); - - } - - public void DeleteVertex(Vertex v) { - if(v == Vlast) { - Vfirst=null; - Vlast=null; - GC.Collect(); - GC.WaitForPendingFinalizers(); - return; - } - Vertex temp = v.Next; - v=null; - GC.Collect(); - GC.WaitForPendingFinalizers(); - DeleteVertex(temp); - temp=null; - GC.Collect(); - GC.WaitForPendingFinalizers(); - - } - -} - -public class Vertex - { - public int Name; - //public bool Visited = false; - - public Vertex Next; - public Vertex[] Adjacent; - public Edge[] Edges; - public int Num_Edges = 0; - public static int count=0; - - public Vertex(int val) { - Name = val; - Next = null; - Adjacent = new Vertex[Graph.Nodes]; - } - - ~Vertex() { - Console.WriteLine("In Finalize of Vertex"); - count++; - if(count==100) { - Test.exitCode=100; - } - } - - public void AddVertex(Vertex x, Vertex y) { - x.Next = y; - } - - public void DeleteAdjacentEntry(int n) { - int temp=Num_Edges; - for(int i=0;i< temp;i++) { - if(n == Adjacent[i].Name) { - for(int j=i;j<Num_Edges;j++) - Adjacent[j] = Adjacent[j+1]; - Num_Edges--; - return; - } - } - } - } - - -public class Edge - { - public int Weight; - public Vertex v1,v2; - public Edge Next; - - public Edge(Vertex n1, Vertex n2) { - v1=n1; - v2=n2; - - int seed = n1.Name+n2.Name; - Random rand = new Random(seed); - Weight = rand.Next(0,50); - } - - public void AddEdge(Edge x, Edge y) { - x.Next = y; - } - - } - - -public class Test -{ - public static int exitCode; - public static int Main() - { - exitCode=1; - - Console.WriteLine("Test should pass with ExitCode 100"); - Console.WriteLine("Building Graph with 100 vertices..."); - Graph MyGraph = new Graph(100); // graph with 10 nodes - - MyGraph.BuildGraph(); - MyGraph.CheckIfReachable(); - - Console.WriteLine("Deleting all vertices..."); - - MyGraph.DeleteVertex(); - - GC.Collect(); - GC.WaitForPendingFinalizers(); - - Console.WriteLine("Done..."); - - return exitCode; - } -} -} diff --git a/tests/src/GC/LargeMemory/API/gc/collect.cs b/tests/src/GC/LargeMemory/API/gc/collect.cs index f39bebb90e..aca89580e3 100644 --- a/tests/src/GC/LargeMemory/API/gc/collect.cs +++ b/tests/src/GC/LargeMemory/API/gc/collect.cs @@ -3,17 +3,27 @@ // See the LICENSE file in the project root for more information. using System; +using System.Runtime.CompilerServices; public sealed class CollectTest { - + private LargeObject lo; private int numTests = 0; public uint size = 0; + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public void CreateLargeObject() { + lo = new LargeObject(size, true); + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public void DestroyLargeObject() { + lo = null; + } private bool collectLargeObject(int gen) { numTests++; - LargeObject lo; try { - lo = new LargeObject(size, true); + CreateLargeObject(); } catch (OutOfMemoryException) { Console.WriteLine("Large Memory Machine required"); return false; @@ -22,7 +32,8 @@ public sealed class CollectTest { Console.WriteLine(e); return false; } - lo = null; + + DestroyLargeObject(); GC.Collect(gen); GC.WaitForPendingFinalizers(); GC.Collect(gen); diff --git a/tests/src/GC/LargeMemory/API/gc/reregisterforfinalize.cs b/tests/src/GC/LargeMemory/API/gc/reregisterforfinalize.cs index 8690ee982e..5af051cbcf 100644 --- a/tests/src/GC/LargeMemory/API/gc/reregisterforfinalize.cs +++ b/tests/src/GC/LargeMemory/API/gc/reregisterforfinalize.cs @@ -3,22 +3,30 @@ // See the LICENSE file in the project root for more information. using System; +using System.Runtime.CompilerServices; public sealed class ReRegisterForFinalizeTest { - + private LargeObject lo; private uint size = 0; public ReRegisterForFinalizeTest(uint size ) { this.size = size; } + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public void CreateLargeObject() { + lo = new LargeObject(size, true); + GC.ReRegisterForFinalize(lo); + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public void DestroyLargeObject() { + lo = null; + } public bool RunTests() { - - LargeObject lo; try { - lo = new LargeObject(size, true); - GC.ReRegisterForFinalize(lo); + CreateLargeObject(); } catch (OutOfMemoryException) { Console.WriteLine("Large Memory Machine required"); return false; @@ -27,7 +35,8 @@ public sealed class ReRegisterForFinalizeTest { Console.WriteLine(e); return false; } - lo = null; + + DestroyLargeObject(); GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); diff --git a/tests/src/GC/LargeMemory/Allocation/finalizertest.cs b/tests/src/GC/LargeMemory/Allocation/finalizertest.cs index 66ac448334..fdeed8dc5f 100644 --- a/tests/src/GC/LargeMemory/Allocation/finalizertest.cs +++ b/tests/src/GC/LargeMemory/Allocation/finalizertest.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Runtime.CompilerServices; // a large object that resurrects itself public sealed class LargeObject2 { @@ -62,6 +63,8 @@ public sealed class FinalizerTest { public static LargeObject2 LO2 = null; public static long ObjectSize = 0; + public LargeObject2 TempObject; + private uint size = 0; private int numTests = 0; @@ -69,12 +72,23 @@ public sealed class FinalizerTest { public FinalizerTest(uint size) { this.size = size; } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public void CreateLargeObject() { + TempObject = new LargeObject2(size); + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public void DestroyLargeObject() { + TempObject = null; + } bool ressurectionTest() { numTests++; try { - new LargeObject2(size); + CreateLargeObject(); + DestroyLargeObject(); } catch (OutOfMemoryException) { Console.WriteLine("Large Memory Machine required"); return false; diff --git a/tests/src/GC/Scenarios/DoublinkList/doublinknoleak2.cs b/tests/src/GC/Scenarios/DoublinkList/doublinknoleak2.cs index ee41f04b3a..12f9948f9c 100644 --- a/tests/src/GC/Scenarios/DoublinkList/doublinknoleak2.cs +++ b/tests/src/GC/Scenarios/DoublinkList/doublinknoleak2.cs @@ -11,6 +11,7 @@ namespace DoubLink { using System; + using System.Runtime.CompilerServices; public class DoubLinkNoLeak2 { @@ -62,10 +63,24 @@ namespace DoubLink { } + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public void CreateMvDLink(int iRep) { + Mv_DLink = new DLinkNode[iRep * 10]; + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public void DestroyMvDLink() { + Mv_DLink = null; + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public void DestroyMVDoub() { + Mv_Doub = null; + } public bool runTest(int iRep, int iObj) { - Mv_DLink = new DLinkNode[iRep*10]; + CreateMvDLink(iRep); for(int i=0; i <10; i++) { @@ -73,8 +88,8 @@ namespace DoubLink { MakeLeak(iRep); } - Mv_DLink = null; - Mv_Doub = null; + DestroyMvDLink(); + DestroyMVDoub(); GC.Collect(); GC.WaitForPendingFinalizers(); @@ -92,7 +107,7 @@ namespace DoubLink { } - + [MethodImplAttribute(MethodImplOptions.NoInlining)] public void SetLink(int iRep, int iObj) { Mv_Doub = new DoubLink[iRep]; @@ -107,7 +122,7 @@ namespace DoubLink { } - + [MethodImplAttribute(MethodImplOptions.NoInlining)] public void MakeLeak(int iRep) { diff --git a/tests/src/GC/Scenarios/LeakWheel/leakwheel.cs b/tests/src/GC/Scenarios/LeakWheel/leakwheel.cs index f67c26006b..51715dfe3f 100644 --- a/tests/src/GC/Scenarios/LeakWheel/leakwheel.cs +++ b/tests/src/GC/Scenarios/LeakWheel/leakwheel.cs @@ -22,6 +22,7 @@ namespace DefaultNamespace { using System.IO; using System.Collections; using System.Collections.Generic; + using System.Runtime.CompilerServices; internal class LeakWheel { @@ -112,21 +113,26 @@ namespace DefaultNamespace { return 1; } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + public void DestroyLstNode() { + LstNode = null; + } public bool RunGame() { Dictionary<int, WeakReference> oTable = new Dictionary<int, WeakReference>(10); - LstNode = null; //the last node in the node chain// + DestroyLstNode(); //the last node in the node chain// Random r = new Random (LeakWheel.iSeed); for(int i=0; i<iIter; i++) { - LstNode = SpinWheel(oTable, LstNode, r); + SpinWheel(oTable, LstNode, r); if( GC.GetTotalMemory(false)/(1024*1024) >= iMem ) { - LstNode = null; - + DestroyLstNode(); + GC.Collect( ); GC.WaitForPendingFinalizers(); GC.Collect( ); @@ -135,7 +141,7 @@ namespace DefaultNamespace { } } - LstNode = null; + DestroyLstNode(); GC.Collect(); GC.WaitForPendingFinalizers(); @@ -161,7 +167,7 @@ namespace DefaultNamespace { Node.iVarAryCreat == Node.iVarAryFinal); } - public Node SpinWheel( Dictionary<int, WeakReference> oTable, Node LstNode, Random r ) + public void SpinWheel( Dictionary<int, WeakReference> oTable, Node node, Random r ) { int iKey;//the index which the new node will be set at Node nValue;//the new node @@ -186,7 +192,7 @@ namespace DefaultNamespace { } else { - LstNode = SetNodeInTable(iKey, nValue, LstNode, oTable); + LstNode = SetNodeInTable(iKey, nValue, node, oTable); } } else @@ -197,7 +203,6 @@ namespace DefaultNamespace { //{ // Console.WriteLine("HeapSize: {0}", GC.GetTotalMemory(false)); //} - return LstNode; } public void DeleteNode( int iKey, Dictionary<int, WeakReference> oTable) @@ -337,17 +342,17 @@ namespace DefaultNamespace { public void ThreadNode() { Dictionary<int, WeakReference> oTable = new Dictionary<int, WeakReference>( 10); - Node LstNode = null; //the last node in the node chain// + DestroyLstNode(); //the last node in the node chain// Random r = new Random (LeakWheel.iSeed); LeakWheel mv_obj = new LeakWheel(); while (true) { - LstNode = mv_obj.SpinWheel( oTable, LstNode, r ); + mv_obj.SpinWheel( oTable, LstNode, r ); if( GC.GetTotalMemory(false) >= LeakWheel.iMem*60 ) { - LstNode = null; + DestroyLstNode(); GC.Collect( ); GC.WaitForPendingFinalizers(); diff --git a/tests/src/GC/Scenarios/WeakReference/getgencollect.cs b/tests/src/GC/Scenarios/WeakReference/getgencollect.cs deleted file mode 100644 index 0fd7e24bb7..0000000000 --- a/tests/src/GC/Scenarios/WeakReference/getgencollect.cs +++ /dev/null @@ -1,81 +0,0 @@ -// 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. - -/******************************************************************************/ -/* test: GetGenCollect -/* Purpose: Test GC.GetGeneration(Object/WeakRefernce) and GC.Collect( Gen ) -/* How: 1.GC.Collect( gen ) should collect the object in "gen" generation. -/* 2.in Object mv_obj's finalize, the return value of GetGeneration(this) -/* should be same with GetGeneration(wf); -/******************************************************************************/ - -namespace DefaultNamespace { - using System; - - internal class GetGenCollect - { - internal int Gen; - internal static WeakReference wf; - internal static bool retVal; - public static int Main( String [] str ) - { - Console.WriteLine("Test should return with ExitCode 100 ..."); - - GetGenCollect mv_obj = new GetGenCollect(); - wf = new WeakReference( mv_obj, true ); - mv_obj.MakeGCBusy(); - mv_obj.Gen = GC.GetGeneration( mv_obj ); - int g = mv_obj.Gen; - mv_obj = null; - - GC.Collect( g ); - GC.WaitForPendingFinalizers(); - GC.Collect( g ); - - if (retVal) - { - Console.WriteLine ("Test Passed" ); - return 100; - } - Console.WriteLine ("Test Failed" ); - return 1; - - } - - - ~GetGenCollect() - { - Console.WriteLine( "Verified that the object in generation {0} is finalized by calling GC.Collect({0}).",Gen); - int g = GC.GetGeneration( this ); - - int gwf = GC.GetGeneration( GetGenCollect.wf ); - Console.WriteLine( "g={0}, gwf={1}", g, gwf ); - - if( g != gwf ) - { - Console.WriteLine( "GetGeneration( WeakReferance ) may have problem!" ); - retVal = false; - return; - } - - Console.WriteLine( "Passed " ); - retVal = true; - - } - - public void MakeGCBusy() - { - Object [] vary = new Object[2]; - for( int i=0; i< 1000; i++ ) - { - vary[0] = (new int[i]); - vary[1] = ( vary[0] ); - if( i%20 == 0 ) - { - GC.Collect(); - } - } - } - } -} diff --git a/tests/src/GC/Scenarios/WeakReference/weakref.cs b/tests/src/GC/Scenarios/WeakReference/weakref.cs deleted file mode 100644 index db1e9b846b..0000000000 --- a/tests/src/GC/Scenarios/WeakReference/weakref.cs +++ /dev/null @@ -1,165 +0,0 @@ -// 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. - -namespace DefaultNamespace { - using System; - using System.Collections.Generic; - - internal class CreateObj - { - private String [] Str; - private List<WeakReference> alWeakRef; - - public CreateObj(int iObj,int iSwitch) - { - Str = new String[iObj]; - alWeakRef = new List<WeakReference>(); - } - - public bool RunTest(int iObj,int iSwitch) - { - if (!DeleteObj(iObj,iSwitch)) - { - return false; - } - return CheckResult(iObj); - } - - public bool DeleteObj(int iObj,int iSwitch) - { - for( int i= 0; i< iObj; i++ ) - { - Str[i] = ( i.ToString() ); - alWeakRef.Add( new WeakReference( Str[i], iSwitch==1) ); - } - - GC.Collect(); - - for( int i=0; i< iObj; i++) - { - if ( alWeakRef[i].Target == null ) - { - //*all weakref have strong reference, so it should not return null - return false; - } - } - - for( int i=0; i< iObj; i++) - { - Str[i] = null; - } - GC.Collect(); - - return true; - - } - - public bool CheckResult(int iObj) - { - for( int i=0; i< iObj; i++) - { - if ( alWeakRef[ i ].Target != null ) - { - //*no weakref have strong reference, so it should return null - return false; - } - } - return true; - } - - } - - - internal class CreateObj2 - { - public WeakRef mv_Obj; - - public CreateObj2() - { - mv_Obj = new WeakRef(); - } - - public bool RunTest(int iObj,int iSwitch) - { - return ( mv_Obj.RealWeakRef( iObj, iSwitch )); - } - } - - - internal class WeakRef - { - - public bool RealWeakRef(int iObj, int iSwitch) - { - - CreateObj temp = new CreateObj(iObj,iSwitch); - bool result = temp.RunTest(iObj,iSwitch); - return result; - } - } - - - internal class Test - { - public static int Main(String [] Args) - { - int iObj = 0; - int iSwitch = 0; - - Console.WriteLine("Test should return with ExitCode 100 ..."); - - if (Args.Length >=2) - { - if (!Int32.TryParse( Args[0], out iObj )) - { - iObj = 10; - } - if (!Int32.TryParse( Args[1], out iSwitch )) - { - iSwitch = 1; - } - } - else - { - iObj = 10; - iSwitch = 1; - } - - - CreateObj2 temp = new CreateObj2(); - if (temp.RunTest(iObj,iSwitch)) - { - Console.WriteLine("Test Passed"); - return 100; - } - Console.WriteLine("Test Failed"); - return 1; - } - - } - - internal class BNode - { - public static int icCreateNode = 0; - public static int icFinalNode = 0; - internal int [] mem; - internal List<BNode> ResObj = new List<BNode>(); - public BNode( int i ) - { - icCreateNode++; - mem = new int[i]; - mem[0] = 0; - if(i > 1 ) - { - mem[mem.Length-1] = mem.Length-1; - } - } - - ~BNode() - { - icFinalNode++; - ResObj.Add( this ); - } - } -} diff --git a/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/_il_dbgi_array_merge.ilproj b/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/_il_dbgi_array_merge.ilproj index 0d04efcfbf..fde90f62cf 100644 --- a/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/_il_dbgi_array_merge.ilproj +++ b/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/_il_dbgi_array_merge.ilproj @@ -30,7 +30,10 @@ <DebugType>Full</DebugType> </PropertyGroup> <ItemGroup> - <Compile Include="i_array_merge-ia64.il" /> + <Compile Condition="'$(Platform)' == 'x64'" Include="i_array_merge-ia64.il" /> + <Compile Condition="'$(Platform)' == 'arm64'" Include="i_array_merge-ia64.il" /> + <Compile Condition="'$(Platform)' == 'x86'" Include="i_array_merge-i386.il" /> + <Compile Condition="'$(Platform)' == 'arm'" Include="i_array_merge-i386.il" /> </ItemGroup> <ItemGroup> <None Include="$(JitPackagesConfigFileDirectory)minimal\project.json" /> @@ -46,4 +49,4 @@ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> </PropertyGroup> -</Project>
\ No newline at end of file +</Project> diff --git a/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/_il_dbgsizeof.ilproj b/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/_il_dbgsizeof.ilproj index 8f349c39cc..6aaaea0db7 100644 --- a/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/_il_dbgsizeof.ilproj +++ b/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/_il_dbgsizeof.ilproj @@ -29,7 +29,10 @@ <DebugType>Full</DebugType> </PropertyGroup> <ItemGroup> - <Compile Include="sizeof-ia64.il" /> + <Compile Condition="'$(Platform)' == 'x64'" Include="sizeof-ia64.il" /> + <Compile Condition="'$(Platform)' == 'arm64'" Include="sizeof-ia64.il" /> + <Compile Condition="'$(Platform)' == 'x86'" Include="sizeof-i386.il" /> + <Compile Condition="'$(Platform)' == 'arm'" Include="sizeof-i386.il" /> </ItemGroup> <ItemGroup> <None Include="app.config" /> @@ -40,4 +43,4 @@ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> </PropertyGroup> -</Project>
\ No newline at end of file +</Project> diff --git a/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/_il_dbgu_array_merge.ilproj b/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/_il_dbgu_array_merge.ilproj index 7188f76529..52a54463d3 100644 --- a/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/_il_dbgu_array_merge.ilproj +++ b/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/_il_dbgu_array_merge.ilproj @@ -30,7 +30,10 @@ <DebugType>Full</DebugType> </PropertyGroup> <ItemGroup> - <Compile Include="u_array_merge-ia64.il" /> + <Compile Condition="'$(Platform)' == 'x64'" Include="u_array_merge-ia64.il" /> + <Compile Condition="'$(Platform)' == 'arm64'" Include="u_array_merge-ia64.il" /> + <Compile Condition="'$(Platform)' == 'x86'" Include="u_array_merge-i386.il" /> + <Compile Condition="'$(Platform)' == 'arm'" Include="u_array_merge-i386.il" /> </ItemGroup> <ItemGroup> <None Include="$(JitPackagesConfigFileDirectory)minimal\project.json" /> @@ -46,4 +49,4 @@ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> </PropertyGroup> -</Project>
\ No newline at end of file +</Project> diff --git a/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/_il_reli_array_merge.ilproj b/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/_il_reli_array_merge.ilproj index 75b1b3610c..49288f3f4d 100644 --- a/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/_il_reli_array_merge.ilproj +++ b/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/_il_reli_array_merge.ilproj @@ -30,7 +30,10 @@ </PropertyGroup> <ItemGroup> - <Compile Include="i_array_merge-ia64.il" /> + <Compile Condition="'$(Platform)' == 'x64'" Include="i_array_merge-ia64.il" /> + <Compile Condition="'$(Platform)' == 'arm64'" Include="i_array_merge-ia64.il" /> + <Compile Condition="'$(Platform)' == 'x86'" Include="i_array_merge-i386.il" /> + <Compile Condition="'$(Platform)' == 'arm'" Include="i_array_merge-i386.il" /> </ItemGroup> <ItemGroup> <None Include="$(JitPackagesConfigFileDirectory)minimal\project.json" /> @@ -46,4 +49,4 @@ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> </PropertyGroup> -</Project>
\ No newline at end of file +</Project> diff --git a/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/_il_relsizeof.ilproj b/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/_il_relsizeof.ilproj index dafc196b22..0dc28c7471 100644 --- a/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/_il_relsizeof.ilproj +++ b/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/_il_relsizeof.ilproj @@ -29,7 +29,10 @@ </PropertyGroup> <ItemGroup> - <Compile Include="sizeof-ia64.il" /> + <Compile Condition="'$(Platform)' == 'x64'" Include="sizeof-ia64.il" /> + <Compile Condition="'$(Platform)' == 'arm64'" Include="sizeof-ia64.il" /> + <Compile Condition="'$(Platform)' == 'x86'" Include="sizeof-i386.il" /> + <Compile Condition="'$(Platform)' == 'arm'" Include="sizeof-i386.il" /> </ItemGroup> <ItemGroup> <None Include="app.config" /> @@ -40,4 +43,4 @@ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> </PropertyGroup> -</Project>
\ No newline at end of file +</Project> diff --git a/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/_il_relu_array_merge.ilproj b/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/_il_relu_array_merge.ilproj index cfef767b2e..ad3ad05961 100644 --- a/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/_il_relu_array_merge.ilproj +++ b/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/_il_relu_array_merge.ilproj @@ -30,7 +30,10 @@ </PropertyGroup> <ItemGroup> - <Compile Include="u_array_merge-ia64.il" /> + <Compile Condition="'$(Platform)' == 'x64'" Include="u_array_merge-ia64.il" /> + <Compile Condition="'$(Platform)' == 'arm64'" Include="u_array_merge-ia64.il" /> + <Compile Condition="'$(Platform)' == 'x86'" Include="u_array_merge-i386.il" /> + <Compile Condition="'$(Platform)' == 'arm'" Include="u_array_merge-i386.il" /> </ItemGroup> <ItemGroup> <None Include="$(JitPackagesConfigFileDirectory)minimal\project.json" /> @@ -46,4 +49,4 @@ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> </PropertyGroup> -</Project>
\ No newline at end of file +</Project> diff --git a/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/i_array_merge-i386.il b/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/i_array_merge-i386.il new file mode 100644 index 0000000000..c4887642b4 --- /dev/null +++ b/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/i_array_merge-i386.il @@ -0,0 +1,116 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +.assembly extern System.Console +{ + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) + .ver 4:0:0:0 +} + +.assembly extern mscorlib +{ } +.assembly 'test' +{ } +.class private auto ansi Test extends [mscorlib]System.Object +{ +.method private hidebysig static int32 Main() il managed +{ + .entrypoint + .maxstack 8 + .locals (int32[0...], native int[0...], native int, native int) + ldc.i4 16 + newobj instance void native int[0...]::.ctor(int32) + stloc.0 + ldc.i4 16 + newobj instance void int32[0...]::.ctor(int32) + stloc.1 + + ldc.i4 0x12345678 + stloc.2 + + ldc.i4.1 + stloc.3 +loop_begin: + // + // This switch determines type of array (int32 or native int) + ldloc.3 + switch (err1,a1,a1,a1,a1,a2,a2,a2,a2) +err1: + newobj instance void [mscorlib]System.ApplicationException::.ctor() + throw +a1: + ldloc.0 + ldstr "branch1.1" + br.s end_a +a2: + ldloc.1 + ldstr "branch1.2" +end_a: + call void [System.Console]System.Console::WriteLine(string) + dup + // This switch determines opcode stelem.i or stelem.i4 + ldloc.3 + dup + dup + switch (err2,b1,b2,b1,b2,b1,b2,b1,b2) +err2: + newobj instance void [mscorlib]System.ApplicationException::.ctor() + throw +b1: + stelem.i + ldstr "branch2.1" + br end_b +b2: + stelem.i4 + ldstr "branch2.2" +end_b: + call void [System.Console]System.Console::WriteLine(string) + + dup + call void [System.Console]System.Console::WriteLine(class [mscorlib]System.Object) + ldloc.3 + + dup + switch (err3,c1,c1,c2,c2,c1,c1,c2,c2) +err3: + newobj instance void [mscorlib]System.ApplicationException::.ctor() + throw +err4: + newobj instance void [mscorlib]System.ApplicationException::.ctor() + throw +c1: + ldelem.i + ldstr "branch3.1" + br end_c +c2: + ldelem.i4 + ldstr "branch3.2" +end_c: + call void [System.Console]System.Console::WriteLine(string) + ldloc.3 + ceq + brfalse err4 + + ldloc.3 + ldc.i4.1 + add + dup + stloc.3 + ldc.i4 9 + ceq + brfalse loop_begin + + ldc.i4 0x64 + ret +} // end of method 'Test::Main' + +.method public hidebysig specialname rtspecialname + instance void .ctor() il managed +{ + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret +} // end of method 'Test::.ctor' + +} // end of class 'Test' diff --git a/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/sizeof-i386.il b/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/sizeof-i386.il new file mode 100644 index 0000000000..9433d291e2 --- /dev/null +++ b/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/sizeof-i386.il @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + + + + + + + +.assembly extern mscorlib { } +.assembly extern System.Console +{ + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) + .ver 4:0:0:0 +} +.assembly 'avg'// as "avg" +{ +} +.module 'avg.exe' +// MVID: {BCA6096F-DF11-4FA3-BF16-EEDA01729535} +.namespace AvgTest +{ + .class private auto ansi Test + extends [mscorlib]System.Object + { + .method private hidebysig static int32 Main() il managed + { + .entrypoint + // Code size 48 (0x30) + .maxstack 5 + ldc.i4.4 + dup + dup + dup + sizeof native int + ceq + brfalse pop3 + sizeof native unsigned int + ceq + brfalse pop2 + sizeof [mscorlib]System.IntPtr + ceq + brfalse pop1 + sizeof [mscorlib]System.UIntPtr + ceq + brfalse pop0 + ldc.i4 0x64 + br.s return + pop3: + pop + pop2: + pop + pop1: + pop + pop0: + ldc.i4.1 + return: + ret + } // end of method 'Test::Main' + + .method public hidebysig specialname rtspecialname + instance void .ctor() il managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method 'Test::.ctor' + + } // end of class 'Test' + +} // end of namespace 'AvgTest' + +//*********** DISASSEMBLY COMPLETE *********************** diff --git a/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/u_array_merge-i386.il b/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/u_array_merge-i386.il new file mode 100644 index 0000000000..fc846b1166 --- /dev/null +++ b/tests/src/JIT/Methodical/ELEMENT_TYPE_IU/u_array_merge-i386.il @@ -0,0 +1,116 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +.assembly extern System.Console +{ + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) + .ver 4:0:0:0 +} + +.assembly extern mscorlib +{ } +.assembly 'test' +{ } +.class private auto ansi Test extends [mscorlib]System.Object +{ +.method private hidebysig static int32 Main() il managed +{ + .entrypoint + .maxstack 8 + .locals (unsigned int32[0...], native unsigned int[0...], native unsigned int, native unsigned int) + ldc.i4 16 + newobj instance void native unsigned int[0...]::.ctor(int32) + stloc.0 + ldc.i4 16 + newobj instance void unsigned int32[0...]::.ctor(int32) + stloc.1 + + ldc.i4 0x12345678 + stloc.2 + + ldc.i4.1 + stloc.3 +loop_begin: + // + // This switch determines type of array (int32 or native int) + ldloc.3 + switch (err1,a1,a1,a1,a1,a2,a2,a2,a2) +err1: + newobj instance void [mscorlib]System.ApplicationException::.ctor() + throw +a1: + ldloc.0 + ldstr "branch1.1" + br.s end_a +a2: + ldloc.1 + ldstr "branch1.2" +end_a: + call void [System.Console]System.Console::WriteLine(string) + dup + // This switch determines opcode stelem.i or stelem.i4 + ldloc.3 + dup + dup + switch (err2,b1,b2,b1,b2,b1,b2,b1,b2) +err2: + newobj instance void [mscorlib]System.ApplicationException::.ctor() + throw +b1: + stelem.i + ldstr "branch2.1" + br end_b +b2: + stelem.i4 + ldstr "branch2.2" +end_b: + call void [System.Console]System.Console::WriteLine(string) + + dup + call void [System.Console]System.Console::WriteLine(class [mscorlib]System.Object) + ldloc.3 + + dup + switch (err3,c1,c1,c2,c2,c1,c1,c2,c2) +err3: + newobj instance void [mscorlib]System.ApplicationException::.ctor() + throw +err4: + newobj instance void [mscorlib]System.ApplicationException::.ctor() + throw +c1: + ldelem.i + ldstr "branch3.1" + br end_c +c2: + ldelem.i4 + ldstr "branch3.2" +end_c: + call void [System.Console]System.Console::WriteLine(string) + ldloc.3 + ceq + brfalse err4 + + ldloc.3 + ldc.i4.1 + add + dup + stloc.3 + ldc.i4 9 + ceq + brfalse loop_begin + + ldc.i4 0x64 + ret +} // end of method 'Test::Main' + +.method public hidebysig specialname rtspecialname + instance void .ctor() il managed +{ + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret +} // end of method 'Test::.ctor' + +} // end of class 'Test' diff --git a/tests/src/JIT/Methodical/doublearray/dblarray4_cs_d.csproj b/tests/src/JIT/Methodical/doublearray/dblarray4_cs_d.csproj index 3fdf248798..82ad275ab3 100644 --- a/tests/src/JIT/Methodical/doublearray/dblarray4_cs_d.csproj +++ b/tests/src/JIT/Methodical/doublearray/dblarray4_cs_d.csproj @@ -33,6 +33,16 @@ <ItemGroup> <Compile Include="dblarray4.cs" /> </ItemGroup> + <PropertyGroup> + <CLRTestBatchPreCommands><![CDATA[ +$(CLRTestBatchPreCommands) +set COMPlus_DoubleArrayToLargeObjectHeap=0x64 +]]></CLRTestBatchPreCommands> + <BashCLRTestPreCommands><![CDATA[ +$(BashCLRTestPreCommands) +export COMPlus_DoubleArrayToLargeObjectHeap=0x64 +]]></BashCLRTestPreCommands> + </PropertyGroup> <ItemGroup> <None Include="$(JitPackagesConfigFileDirectory)minimal\project.json" /> <None Include="app.config" /> diff --git a/tests/src/JIT/Methodical/doublearray/dblarray4_cs_do.csproj b/tests/src/JIT/Methodical/doublearray/dblarray4_cs_do.csproj index 0fba6f600d..2b164472f9 100644 --- a/tests/src/JIT/Methodical/doublearray/dblarray4_cs_do.csproj +++ b/tests/src/JIT/Methodical/doublearray/dblarray4_cs_do.csproj @@ -33,6 +33,16 @@ <ItemGroup> <Compile Include="dblarray4.cs" /> </ItemGroup> + <PropertyGroup> + <CLRTestBatchPreCommands><![CDATA[ +$(CLRTestBatchPreCommands) +set COMPlus_DoubleArrayToLargeObjectHeap=0x64 +]]></CLRTestBatchPreCommands> + <BashCLRTestPreCommands><![CDATA[ +$(BashCLRTestPreCommands) +export COMPlus_DoubleArrayToLargeObjectHeap=0x64 +]]></BashCLRTestPreCommands> + </PropertyGroup> <ItemGroup> <None Include="$(JitPackagesConfigFileDirectory)minimal\project.json" /> <None Include="app.config" /> diff --git a/tests/src/JIT/Methodical/doublearray/dblarray4_cs_r.csproj b/tests/src/JIT/Methodical/doublearray/dblarray4_cs_r.csproj index c171b92253..8e62dde24a 100644 --- a/tests/src/JIT/Methodical/doublearray/dblarray4_cs_r.csproj +++ b/tests/src/JIT/Methodical/doublearray/dblarray4_cs_r.csproj @@ -33,6 +33,16 @@ <ItemGroup> <Compile Include="dblarray4.cs" /> </ItemGroup> + <PropertyGroup> + <CLRTestBatchPreCommands><![CDATA[ +$(CLRTestBatchPreCommands) +set COMPlus_DoubleArrayToLargeObjectHeap=0x64 +]]></CLRTestBatchPreCommands> + <BashCLRTestPreCommands><![CDATA[ +$(BashCLRTestPreCommands) +export COMPlus_DoubleArrayToLargeObjectHeap=0x64 +]]></BashCLRTestPreCommands> + </PropertyGroup> <ItemGroup> <None Include="$(JitPackagesConfigFileDirectory)minimal\project.json" /> <None Include="app.config" /> diff --git a/tests/src/JIT/Methodical/doublearray/dblarray4_cs_ro.csproj b/tests/src/JIT/Methodical/doublearray/dblarray4_cs_ro.csproj index f30e435354..826914941f 100644 --- a/tests/src/JIT/Methodical/doublearray/dblarray4_cs_ro.csproj +++ b/tests/src/JIT/Methodical/doublearray/dblarray4_cs_ro.csproj @@ -33,6 +33,16 @@ <ItemGroup> <Compile Include="dblarray4.cs" /> </ItemGroup> + <PropertyGroup> + <CLRTestBatchPreCommands><![CDATA[ +$(CLRTestBatchPreCommands) +set COMPlus_DoubleArrayToLargeObjectHeap=0x64 +]]></CLRTestBatchPreCommands> + <BashCLRTestPreCommands><![CDATA[ +$(BashCLRTestPreCommands) +export COMPlus_DoubleArrayToLargeObjectHeap=0x64 +]]></BashCLRTestPreCommands> + </PropertyGroup> <ItemGroup> <None Include="$(JitPackagesConfigFileDirectory)minimal\project.json" /> <None Include="app.config" /> diff --git a/tests/src/JIT/Methodical/xxobj/sizeof/_dbgsizeof.csproj b/tests/src/JIT/Methodical/xxobj/sizeof/_dbgsizeof.csproj new file mode 100644 index 0000000000..bb25e86131 --- /dev/null +++ b/tests/src/JIT/Methodical/xxobj/sizeof/_dbgsizeof.csproj @@ -0,0 +1,55 @@ +<?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>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 .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> + <!-- Set to 'Full' if the Debug? column is marked in the spreadsheet. Leave blank otherwise. --> + <DebugType>Full</DebugType> + <Optimize>False</Optimize> + <NoLogo>True</NoLogo> + <NoStandardLib>True</NoStandardLib> + <Noconfig>True</Noconfig> + <AllowUnsafeBlocks>True</AllowUnsafeBlocks> + <DefineConstants>$(DefineConstants);CORECLR</DefineConstants> + </PropertyGroup> + <ItemGroup> + <Compile Include="sizeof.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="$(JitPackagesConfigFileDirectory)minimal\project.json" /> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <PropertyGroup> + <ProjectJson>$(JitPackagesConfigFileDirectory)minimal\project.json</ProjectJson> + <ProjectLockJson>$(JitPackagesConfigFileDirectory)minimal\project.lock.json</ProjectLockJson> + </PropertyGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project> diff --git a/tests/src/JIT/Methodical/xxobj/sizeof/_il_dbgsizeof.ilproj b/tests/src/JIT/Methodical/xxobj/sizeof/_il_dbgsizeof.ilproj index f08168eef0..67615bbdad 100644 --- a/tests/src/JIT/Methodical/xxobj/sizeof/_il_dbgsizeof.ilproj +++ b/tests/src/JIT/Methodical/xxobj/sizeof/_il_dbgsizeof.ilproj @@ -30,7 +30,8 @@ <DebugType>Full</DebugType> </PropertyGroup> <ItemGroup> - <Compile Include="64sizeof.il" /> + <Compile Condition="'$(Platform)' == 'x86'" Include="sizeof.il" /> + <Compile Condition="'$(Platform)' != 'x86'" Include="64sizeof.il" /> </ItemGroup> <ItemGroup> <None Include="$(JitPackagesConfigFileDirectory)minimal\project.json" /> @@ -46,4 +47,4 @@ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> </PropertyGroup> -</Project>
\ No newline at end of file +</Project> diff --git a/tests/src/JIT/Methodical/xxobj/sizeof/_il_dbgsizeof32.ilproj b/tests/src/JIT/Methodical/xxobj/sizeof/_il_dbgsizeof32.ilproj index bb1acd7525..a9a4ef3e39 100644 --- a/tests/src/JIT/Methodical/xxobj/sizeof/_il_dbgsizeof32.ilproj +++ b/tests/src/JIT/Methodical/xxobj/sizeof/_il_dbgsizeof32.ilproj @@ -30,7 +30,8 @@ <DebugType>Full</DebugType> </PropertyGroup> <ItemGroup> - <Compile Include="64sizeof32.il" /> + <Compile Condition="'$(Platform)' == 'x86'" Include="sizeof32.il" /> + <Compile Condition="'$(Platform)' != 'x86'" Include="64sizeof32.il" /> </ItemGroup> <ItemGroup> <None Include="$(JitPackagesConfigFileDirectory)minimal\project.json" /> @@ -46,4 +47,4 @@ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> </PropertyGroup> -</Project>
\ No newline at end of file +</Project> diff --git a/tests/src/JIT/Methodical/xxobj/sizeof/_il_dbgsizeof64.ilproj b/tests/src/JIT/Methodical/xxobj/sizeof/_il_dbgsizeof64.ilproj index e1782434b8..80b3dcb667 100644 --- a/tests/src/JIT/Methodical/xxobj/sizeof/_il_dbgsizeof64.ilproj +++ b/tests/src/JIT/Methodical/xxobj/sizeof/_il_dbgsizeof64.ilproj @@ -30,7 +30,8 @@ <DebugType>Full</DebugType> </PropertyGroup> <ItemGroup> - <Compile Include="64sizeof64.il" /> + <Compile Condition="'$(Platform)' == 'x86'" Include="sizeof64.il" /> + <Compile Condition="'$(Platform)' != 'x86'" Include="64sizeof64.il" /> </ItemGroup> <ItemGroup> <None Include="$(JitPackagesConfigFileDirectory)minimal\project.json" /> @@ -46,4 +47,4 @@ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> </PropertyGroup> -</Project>
\ No newline at end of file +</Project> diff --git a/tests/src/JIT/Methodical/xxobj/sizeof/_il_relsizeof.ilproj b/tests/src/JIT/Methodical/xxobj/sizeof/_il_relsizeof.ilproj index cf86919956..6ac9d7567b 100644 --- a/tests/src/JIT/Methodical/xxobj/sizeof/_il_relsizeof.ilproj +++ b/tests/src/JIT/Methodical/xxobj/sizeof/_il_relsizeof.ilproj @@ -30,7 +30,8 @@ </PropertyGroup> <ItemGroup> - <Compile Include="64sizeof.il" /> + <Compile Condition="'$(Platform)' == 'x86'" Include="sizeof.il" /> + <Compile Condition="'$(Platform)' != 'x86'" Include="64sizeof.il" /> </ItemGroup> <ItemGroup> <None Include="$(JitPackagesConfigFileDirectory)minimal\project.json" /> @@ -46,4 +47,4 @@ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> </PropertyGroup> -</Project>
\ No newline at end of file +</Project> diff --git a/tests/src/JIT/Methodical/xxobj/sizeof/_il_relsizeof32.ilproj b/tests/src/JIT/Methodical/xxobj/sizeof/_il_relsizeof32.ilproj index 62ce859f9b..9d776c51af 100644 --- a/tests/src/JIT/Methodical/xxobj/sizeof/_il_relsizeof32.ilproj +++ b/tests/src/JIT/Methodical/xxobj/sizeof/_il_relsizeof32.ilproj @@ -30,7 +30,8 @@ </PropertyGroup> <ItemGroup> - <Compile Include="64sizeof32.il" /> + <Compile Condition="'$(Platform)' == 'x86'" Include="sizeof32.il" /> + <Compile Condition="'$(Platform)' != 'x86'" Include="64sizeof32.il" /> </ItemGroup> <ItemGroup> <None Include="$(JitPackagesConfigFileDirectory)minimal\project.json" /> @@ -46,4 +47,4 @@ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> </PropertyGroup> -</Project>
\ No newline at end of file +</Project> diff --git a/tests/src/JIT/Methodical/xxobj/sizeof/_il_relsizeof64.ilproj b/tests/src/JIT/Methodical/xxobj/sizeof/_il_relsizeof64.ilproj index ff947a884e..745b7de950 100644 --- a/tests/src/JIT/Methodical/xxobj/sizeof/_il_relsizeof64.ilproj +++ b/tests/src/JIT/Methodical/xxobj/sizeof/_il_relsizeof64.ilproj @@ -30,7 +30,8 @@ </PropertyGroup> <ItemGroup> - <Compile Include="64sizeof64.il" /> + <Compile Condition="'$(Platform)' == 'x86'" Include="sizeof64.il" /> + <Compile Condition="'$(Platform)' != 'x86'" Include="64sizeof64.il" /> </ItemGroup> <ItemGroup> <None Include="$(JitPackagesConfigFileDirectory)minimal\project.json" /> @@ -46,4 +47,4 @@ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> </PropertyGroup> -</Project>
\ No newline at end of file +</Project> diff --git a/tests/src/JIT/Methodical/xxobj/sizeof/_relsizeof.csproj b/tests/src/JIT/Methodical/xxobj/sizeof/_relsizeof.csproj new file mode 100644 index 0000000000..93f433b92c --- /dev/null +++ b/tests/src/JIT/Methodical/xxobj/sizeof/_relsizeof.csproj @@ -0,0 +1,55 @@ +<?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>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 .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> + <!-- Set to 'Full' if the Debug? column is marked in the spreadsheet. Leave blank otherwise. --> + <DebugType>None</DebugType> + <Optimize>False</Optimize> + <NoLogo>True</NoLogo> + <NoStandardLib>True</NoStandardLib> + <Noconfig>True</Noconfig> + <AllowUnsafeBlocks>True</AllowUnsafeBlocks> + <DefineConstants>$(DefineConstants);CORECLR</DefineConstants> + </PropertyGroup> + <ItemGroup> + <Compile Include="sizeof.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="$(JitPackagesConfigFileDirectory)minimal\project.json" /> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <PropertyGroup> + <ProjectJson>$(JitPackagesConfigFileDirectory)minimal\project.json</ProjectJson> + <ProjectLockJson>$(JitPackagesConfigFileDirectory)minimal\project.lock.json</ProjectLockJson> + </PropertyGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project> diff --git a/tests/src/JIT/Methodical/xxobj/sizeof/_speed_dbgsizeof.csproj b/tests/src/JIT/Methodical/xxobj/sizeof/_speed_dbgsizeof.csproj new file mode 100644 index 0000000000..34c6f41b0e --- /dev/null +++ b/tests/src/JIT/Methodical/xxobj/sizeof/_speed_dbgsizeof.csproj @@ -0,0 +1,55 @@ +<?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>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 .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> + <!-- Set to 'Full' if the Debug? column is marked in the spreadsheet. Leave blank otherwise. --> + <DebugType>Full</DebugType> + <Optimize>True</Optimize> + <NoLogo>True</NoLogo> + <NoStandardLib>True</NoStandardLib> + <Noconfig>True</Noconfig> + <AllowUnsafeBlocks>True</AllowUnsafeBlocks> + <DefineConstants>$(DefineConstants);CORECLR</DefineConstants> + </PropertyGroup> + <ItemGroup> + <Compile Include="sizeof.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="$(JitPackagesConfigFileDirectory)minimal\project.json" /> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <PropertyGroup> + <ProjectJson>$(JitPackagesConfigFileDirectory)minimal\project.json</ProjectJson> + <ProjectLockJson>$(JitPackagesConfigFileDirectory)minimal\project.lock.json</ProjectLockJson> + </PropertyGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project> diff --git a/tests/src/JIT/Methodical/xxobj/sizeof/_speed_relsizeof.csproj b/tests/src/JIT/Methodical/xxobj/sizeof/_speed_relsizeof.csproj new file mode 100644 index 0000000000..fab4ab14eb --- /dev/null +++ b/tests/src/JIT/Methodical/xxobj/sizeof/_speed_relsizeof.csproj @@ -0,0 +1,55 @@ +<?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>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 .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> + <!-- Set to 'Full' if the Debug? column is marked in the spreadsheet. Leave blank otherwise. --> + <DebugType>None</DebugType> + <Optimize>True</Optimize> + <NoLogo>True</NoLogo> + <NoStandardLib>True</NoStandardLib> + <Noconfig>True</Noconfig> + <AllowUnsafeBlocks>True</AllowUnsafeBlocks> + <DefineConstants>$(DefineConstants);CORECLR</DefineConstants> + </PropertyGroup> + <ItemGroup> + <Compile Include="sizeof.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="$(JitPackagesConfigFileDirectory)minimal\project.json" /> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <PropertyGroup> + <ProjectJson>$(JitPackagesConfigFileDirectory)minimal\project.json</ProjectJson> + <ProjectLockJson>$(JitPackagesConfigFileDirectory)minimal\project.lock.json</ProjectLockJson> + </PropertyGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project> diff --git a/tests/src/JIT/Methodical/xxobj/sizeof/sizeof.cs b/tests/src/JIT/Methodical/xxobj/sizeof/sizeof.cs new file mode 100644 index 0000000000..2c5e012f37 --- /dev/null +++ b/tests/src/JIT/Methodical/xxobj/sizeof/sizeof.cs @@ -0,0 +1,73 @@ +// 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. + +namespace JitTest +{ + using System; + + struct SimpleStruct + { + int m_int; + uint m_uint; + byte m_byte; + sbyte m_sbyte; + char m_char; + short m_short; + ushort m_ushort; + long m_long; + ulong m_ulong; + } + + struct ComplexStruct + { + SimpleStruct ss1; + SimpleStruct ss2; + } + + struct ComplexStruct2 + { + ComplexStruct x1; + ComplexStruct x2; + ComplexStruct x3; + ComplexStruct x4; + ComplexStruct x5; + ComplexStruct x6; + ComplexStruct x7; + ComplexStruct x8; + ComplexStruct x9; + ComplexStruct x10; + ComplexStruct x11; + ComplexStruct x12; + ComplexStruct x13; + ComplexStruct x14; + ComplexStruct x15; + ComplexStruct x16; + ComplexStruct x17; + ComplexStruct x18; + } + + struct Test + { + static unsafe int Main() + { + if (sizeof(SimpleStruct) != 32) + { + Console.WriteLine("sizeof(SimpleStruct) failed."); + return 101; + } + if (sizeof(ComplexStruct) != 64) + { + Console.WriteLine("sizeof(ComplexStruct) failed."); + return 102; + } + if (sizeof(ComplexStruct2) != sizeof(ComplexStruct) * 18) + { + Console.WriteLine("sizeof(ComplexStruct2) failed."); + return 103; + } + Console.WriteLine("sizeof passed"); + return 100; + } + } +} diff --git a/tests/src/JIT/Methodical/xxobj/sizeof/sizeof.il b/tests/src/JIT/Methodical/xxobj/sizeof/sizeof.il new file mode 100644 index 0000000000..d13fb61d13 --- /dev/null +++ b/tests/src/JIT/Methodical/xxobj/sizeof/sizeof.il @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +.assembly extern System.Console +{ + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) + .ver 4:0:0:0 +} + +.assembly extern mscorlib { } +.assembly 'sizeof' +{ +} +.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) +.namespace JitTest +{ + .class private sequential ansi sealed beforefieldinit SimpleStruct + extends [mscorlib]System.ValueType + { + .field private int32 m_int + .field private unsigned int32 m_uint + .field private unsigned int8 m_byte + .field private int8 m_sbyte + .field private char m_char + .field private int16 m_short + .field private unsigned int16 m_ushort + .field private int64 m_long + .field private unsigned int64 m_ulong + } + .class private sequential ansi sealed beforefieldinit ComplexStruct + extends [mscorlib]System.ValueType + { + .field private valuetype JitTest.SimpleStruct ss1 + .field private valuetype JitTest.SimpleStruct ss2 + } + .class private sequential ansi sealed beforefieldinit RefComplexStruct + extends [mscorlib]System.ValueType + { + .field private valuetype JitTest.SimpleStruct ss1 + .field private valuetype JitTest.SimpleStruct[] ssarr + .field private valuetype JitTest.SimpleStruct ss2 + } + .class private sequential ansi sealed beforefieldinit ComplexStruct2 + extends [mscorlib]System.ValueType + { + .field private valuetype JitTest.ComplexStruct x1 + .field private valuetype JitTest.ComplexStruct x2 + .field private valuetype JitTest.ComplexStruct x3 + .field private valuetype JitTest.ComplexStruct x4 + .field private valuetype JitTest.ComplexStruct x5 + .field private valuetype JitTest.ComplexStruct x6 + .field private valuetype JitTest.ComplexStruct x7 + .field private valuetype JitTest.ComplexStruct x8 + .field private valuetype JitTest.ComplexStruct x9 + .field private valuetype JitTest.ComplexStruct x10 + .field private valuetype JitTest.ComplexStruct x11 + .field private valuetype JitTest.ComplexStruct x12 + .field private valuetype JitTest.ComplexStruct x13 + .field private valuetype JitTest.ComplexStruct x14 + .field private valuetype JitTest.ComplexStruct x15 + .field private valuetype JitTest.ComplexStruct x16 + .field private valuetype JitTest.ComplexStruct x17 + .field private valuetype JitTest.ComplexStruct x18 + } + .class private sequential ansi sealed beforefieldinit RefComplexStruct2 + extends [mscorlib]System.ValueType + { + .field private valuetype JitTest.ComplexStruct2 ss1 + .field private class [mscorlib]System.AppDomain ad + .field private valuetype JitTest.ComplexStruct2 ss2 + } + .class private sequential ansi sealed beforefieldinit Test + extends [mscorlib]System.ValueType + { + .pack 1 + .size 1 + .method private hidebysig static int32 + Main() cil managed + { + .entrypoint + .maxstack 3 + .locals (int32 V_0) + IL_0000: sizeof JitTest.SimpleStruct + IL_0006: ldc.i4.s 32 + IL_0008: beq.s IL_0019 + IL_000a: ldstr "sizeof(SimpleStruct) failed." + IL_000f: call void [System.Console]System.Console::WriteLine(string) + IL_0014: ldc.i4.s 101 + IL_0016: stloc.0 + IL_0017: br EXIT + IL_0019: sizeof JitTest.ComplexStruct + IL_001f: ldc.i4.s 64 + IL_0021: beq.s IL_0032 + IL_0023: ldstr "sizeof(ComplexStruct) failed." + IL_0028: call void [System.Console]System.Console::WriteLine(string) + IL_002d: ldc.i4.s 102 + IL_002f: stloc.0 + IL_0030: br.s EXIT + IL_0032: sizeof JitTest.ComplexStruct2 + IL_0038: sizeof JitTest.ComplexStruct + IL_003e: ldc.i4.s 18 + IL_0040: mul + IL_0041: beq.s NEXT1 + IL_0043: ldstr "sizeof(ComplexStruct2) failed." + IL_0048: call void [System.Console]System.Console::WriteLine(string) + IL_004d: ldc.i4.s 103 + IL_004f: stloc.0 + IL_0050: br.s EXIT + + NEXT1: + sizeof JitTest.RefComplexStruct + ldc.i4.s 68 + beq.s NEXT2 + + ldstr "sizeof(RefComplexStruct) failed." + call void [System.Console]System.Console::WriteLine(string) + ldc.i4.s 104 + stloc.0 + br.s EXIT + + NEXT2: + sizeof JitTest.RefComplexStruct2 + sizeof JitTest.ComplexStruct2 + ldc.i4.1 + shl + ldc.i4.4 + add + beq.s OK + + ldstr "sizeof(RefComplexStruct2) failed." + call void [System.Console]System.Console::WriteLine(string) + ldc.i4.s 105 + stloc.0 + br.s EXIT + + OK: ldstr "sizeof passed" + IL_0057: call void [System.Console]System.Console::WriteLine(string) + IL_005c: ldc.i4 100 + IL_005d: stloc.0 + + EXIT: ldloc.0 + ret + } + } +} diff --git a/tests/src/JIT/Methodical/xxobj/sizeof/sizeof32.il b/tests/src/JIT/Methodical/xxobj/sizeof/sizeof32.il new file mode 100644 index 0000000000..5ba3ef1536 --- /dev/null +++ b/tests/src/JIT/Methodical/xxobj/sizeof/sizeof32.il @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +// sizeof32.il +.assembly extern mscorlib { } +.assembly sizeof32 { } +.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) +.namespace JitTest +{ + .class private sequential ansi sealed beforefieldinit SimpleStruct + extends [mscorlib]System.ValueType + { + .field public int32 m_int + .field public unsigned int32 m_uint + .field public unsigned int8 m_byte + .field public int8 m_sbyte + .field public char m_char + .field public int16 m_short + .field public unsigned int16 m_ushort + .field public int64 m_long + .field public unsigned int64 m_ulong + } + .class private sequential ansi sealed beforefieldinit RefComplexStruct + extends [mscorlib]System.ValueType + { + .field public valuetype JitTest.SimpleStruct ss1 + .field public valuetype JitTest.SimpleStruct[0...] ss_array + .field public valuetype JitTest.SimpleStruct ss2 + } + .class private sequential ansi sealed beforefieldinit Test + extends [mscorlib]System.ValueType + { + .pack 1 + .size 1 + .method private hidebysig static int32 + Main() cil managed + { + .entrypoint + .maxstack 4 + .locals (int32 V_0, + int32 V_1, + valuetype JitTest.RefComplexStruct V_2, + valuetype JitTest.SimpleStruct V_3) + IL_0000: sizeof JitTest.RefComplexStruct + IL_0006: conv.i1 + IL_0007: conv.i4 + IL_0008: stloc.0 + IL_0009: ldloc.0 + IL_000a: sizeof JitTest.RefComplexStruct + IL_0010: ldloca.s V_2 + IL_0012: initobj JitTest.RefComplexStruct + IL_0018: ldloc.2 + IL_0019: stloc.2 + IL_001a: ldloca.s V_2 + IL_001c: ldfld valuetype JitTest.SimpleStruct JitTest.RefComplexStruct::ss1 + IL_0021: stloc.3 + IL_0022: ldloca.s V_3 + IL_0024: ldfld int8 JitTest.SimpleStruct::m_sbyte + IL_0029: conv.i4 + IL_002a: add + IL_002b: add + IL_002c: stloc.0 + IL_002d: ldloc.0 + IL_002e: ldc.i4 0x80 + IL_0033: ldloca.s V_2 + IL_0035: initobj JitTest.RefComplexStruct + IL_003b: ldloc.2 + IL_003c: stloc.2 + IL_003d: ldloca.s V_2 + IL_003f: ldfld valuetype JitTest.SimpleStruct JitTest.RefComplexStruct::ss2 + IL_0044: stloc.3 + IL_0045: ldloca.s V_3 + IL_0047: ldfld unsigned int16 JitTest.SimpleStruct::m_ushort + IL_004c: conv.i4 + IL_004d: sub + IL_004e: sizeof JitTest.RefComplexStruct + IL_0054: sub + IL_0055: sub + IL_0056: stloc.0 + IL_0057: ldloc.0 + IL_0058: sizeof JitTest.RefComplexStruct + IL_005e: ldloca.s V_2 + IL_0060: initobj JitTest.RefComplexStruct + IL_0066: ldloc.2 + IL_0067: stloc.2 + IL_0068: ldloca.s V_2 + IL_006a: ldfld valuetype JitTest.SimpleStruct JitTest.RefComplexStruct::ss1 + IL_006f: stloc.3 + IL_0070: ldloca.s V_3 + IL_0072: ldfld unsigned int32 JitTest.SimpleStruct::m_uint + IL_0077: ldc.i4.1 + IL_0078: add + IL_0079: mul + IL_007a: mul + IL_007b: stloc.0 + IL_007c: ldloc.0 + IL_007d: sizeof JitTest.RefComplexStruct + IL_0083: ldloca.s V_2 + IL_0085: initobj JitTest.RefComplexStruct + IL_008b: ldloc.2 + IL_008c: stloc.2 + IL_008d: ldloca.s V_2 + IL_008f: ldfld valuetype JitTest.SimpleStruct JitTest.RefComplexStruct::ss2 + IL_0094: stloc.3 + IL_0095: ldloca.s V_3 + IL_0097: ldfld unsigned int64 JitTest.SimpleStruct::m_ulong + IL_009c: ldc.i4.1 + IL_009d: conv.i8 + IL_009e: add + IL_009f: conv.i4 + IL_00a0: div + IL_00a1: div + IL_00a2: stloc.0 + IL_00a3: sizeof JitTest.RefComplexStruct + IL_00a9: ldc.i4.s 64 + IL_00ab: xor + IL_00ac: ldloc.0 + IL_00ad: or + IL_00ae: stloc.0 + IL_00af: sizeof JitTest.RefComplexStruct + IL_00b5: ldc.i4.s -65 + IL_00b7: xor + IL_00b8: ldloc.0 + IL_00b9: and + IL_00ba: stloc.0 + IL_00bb: ldloc.0 + IL_00bc: ldc.i4.s 28 + IL_00be: add + IL_00bf: stloc.1 + IL_00c0: br.s IL_00c2 + IL_00c2: ldloc.1 + IL_00c3: ret + } + } +} diff --git a/tests/src/JIT/Methodical/xxobj/sizeof/sizeof64.il b/tests/src/JIT/Methodical/xxobj/sizeof/sizeof64.il new file mode 100644 index 0000000000..7b7d1c4fb2 --- /dev/null +++ b/tests/src/JIT/Methodical/xxobj/sizeof/sizeof64.il @@ -0,0 +1,146 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +// sizeof64.il +.assembly extern mscorlib { } +.assembly sizeof64 { } +.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) +.namespace JitTest +{ + .class private sequential ansi sealed beforefieldinit SimpleStruct + extends [mscorlib]System.ValueType + { + .field public int32 m_int + .field public unsigned int32 m_uint + .field public unsigned int8 m_byte + .field public int8 m_sbyte + .field public char m_char + .field public int16 m_short + .field public unsigned int16 m_ushort + .field public int64 m_long + .field public unsigned int64 m_ulong + .field public valuetype JitTest.SimpleStruct[0...] ss_array + } + .class private sequential ansi sealed beforefieldinit RefComplexStruct + extends [mscorlib]System.ValueType + { + .field public valuetype JitTest.SimpleStruct ss1 + .field public valuetype JitTest.SimpleStruct[0...] ss_array + .field public valuetype JitTest.SimpleStruct ss2 + } + .class private sequential ansi sealed beforefieldinit Test + extends [mscorlib]System.ValueType + { + .pack 1 + .size 1 + .method private hidebysig static int32 + Main() cil managed + { + .entrypoint + .maxstack 4 + .locals (int64 V_0, + int32 V_1, + valuetype JitTest.RefComplexStruct V_2, + valuetype JitTest.SimpleStruct V_3) + IL_0000: sizeof JitTest.RefComplexStruct + IL_0006: conv.i1 + IL_0007: conv.i8 + IL_0008: stloc.0 + IL_0009: ldloc.0 + IL_000a: sizeof JitTest.RefComplexStruct + IL_0010: ldloca.s V_2 + IL_0012: initobj JitTest.RefComplexStruct + IL_0018: ldloc.2 + IL_0019: stloc.2 + IL_001a: ldloca.s V_2 + IL_001c: ldfld valuetype JitTest.SimpleStruct JitTest.RefComplexStruct::ss1 + IL_0021: stloc.3 + IL_0022: ldloca.s V_3 + IL_0024: ldfld int8 JitTest.SimpleStruct::m_sbyte + IL_0029: conv.i4 + IL_002a: add + IL_002b: conv.i8 + IL_002c: add + IL_002d: stloc.0 + IL_002e: ldloc.0 + IL_002f: ldc.i4 0x80 + IL_0034: conv.i8 + IL_0035: ldloca.s V_2 + IL_0037: initobj JitTest.RefComplexStruct + IL_003d: ldloc.2 + IL_003e: stloc.2 + IL_003f: ldloca.s V_2 + IL_0041: ldfld valuetype JitTest.SimpleStruct JitTest.RefComplexStruct::ss2 + IL_0046: stloc.3 + IL_0047: ldloca.s V_3 + IL_0049: ldfld unsigned int16 JitTest.SimpleStruct::m_ushort + IL_004e: conv.u8 + IL_004f: sub + IL_0050: sizeof JitTest.RefComplexStruct + IL_0056: conv.i8 + IL_0057: sub + IL_0058: sub + IL_0059: stloc.0 + IL_005a: ldloc.0 + IL_005b: sizeof JitTest.RefComplexStruct + IL_0061: conv.i8 + IL_0062: ldloca.s V_2 + IL_0064: initobj JitTest.RefComplexStruct + IL_006a: ldloc.2 + IL_006b: stloc.2 + IL_006c: ldloca.s V_2 + IL_006e: ldfld valuetype JitTest.SimpleStruct JitTest.RefComplexStruct::ss1 + IL_0073: stloc.3 + IL_0074: ldloca.s V_3 + IL_0076: ldfld unsigned int32 JitTest.SimpleStruct::m_uint + IL_007b: ldc.i4.1 + IL_007c: add + IL_007d: conv.u8 + IL_007e: mul + IL_007f: mul + IL_0080: stloc.0 + IL_0081: ldloc.0 + IL_0082: sizeof JitTest.RefComplexStruct + IL_0088: ldloca.s V_2 + IL_008a: initobj JitTest.RefComplexStruct + IL_0090: ldloc.2 + IL_0091: stloc.2 + IL_0092: ldloca.s V_2 + IL_0094: ldfld valuetype JitTest.SimpleStruct JitTest.RefComplexStruct::ss2 + IL_0099: stloc.3 + IL_009a: ldloca.s V_3 + IL_009c: ldfld unsigned int64 JitTest.SimpleStruct::m_ulong + IL_00a1: ldc.i4.1 + IL_00a2: conv.i8 + IL_00a3: add + IL_00a4: conv.i4 + IL_00a5: div + IL_00a6: conv.i8 + IL_00a7: div + IL_00a8: stloc.0 + IL_00a9: sizeof JitTest.RefComplexStruct + IL_00af: ldc.i4.s 64 + IL_00b1: xor + IL_00b2: conv.i8 + IL_00b3: ldloc.0 + IL_00b4: or + IL_00b5: stloc.0 + IL_00b6: sizeof JitTest.RefComplexStruct + IL_00bc: ldc.i4.s -65 + IL_00be: xor + IL_00bf: conv.i8 + IL_00c0: ldloc.0 + IL_00c1: and + IL_00c2: stloc.0 + IL_00c3: ldloc.0 + IL_00c4: ldc.i4.s 4 + IL_00c6: conv.i8 + IL_00c7: add + IL_00c8: conv.i4 + IL_00c9: stloc.1 + IL_00ca: br.s IL_00cc + IL_00cc: ldloc.1 + IL_00cd: ret + } + } +} diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_ClassConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_ClassConstraint_Neg.il new file mode 100644 index 0000000000..454cdc53f8 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_ClassConstraint_Neg.il @@ -0,0 +1,93 @@ +// 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{} +.assembly extern types{} + +.assembly Method_ClassConstraint_Neg {} + + + +.class public auto ansi beforefieldinit B + extends [mscorlib]System.Object +{ + + // Generic method with class() constraint + .method public hidebysig instance void + method1<class T>() cil managed + { + .maxstack 8 + ret + } + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + .maxstack 8 + ldarg.0 + call instance void [mscorlib]System.Object::.ctor() + ret + } +} + +.class public auto ansi beforefieldinit M_ClassConstraint + extends [mscorlib]System.Object +{ + + // NEGATIVE TEST + // generic argument is a struct + .method public hidebysig static void Test3() cil managed + { + .maxstack 1 + + newobj instance void class B::.ctor() + call instance void class B::method1<valuetype [types]NonGenStruct>() + ret + } + + + // NEGATIVE TEST + // generic argument is an enum with no default ctor + .method public hidebysig static void Test8() cil managed + { + .maxstack 1 + + newobj instance void class B::.ctor() + call instance void class B::method1<valuetype [types]Enum1>() + ret + } + +} + +.class public auto ansi beforefieldinit M_ClassConstraintGenTypes + extends [mscorlib]System.Object +{ + + // NEGATIVE TEST + // generic argument is a struct + .method public hidebysig static void Test3() cil managed + { + .maxstack 1 + + newobj instance void class B::.ctor() + call instance void class B::method1<valuetype [types]GenStruct<int32>>() + + ret + } + + // NEGATIVE TEST + // generic argument is NUllable<T> + .method public hidebysig static void Test6() cil managed + { + .maxstack 1 + + newobj instance void class B::.ctor() + call instance void class B::method1<valuetype [mscorlib]System.'Nullable`1'<int32>>() + + ret + } + +} + + diff --git a/tests/src/GC/Scenarios/WeakReference/weakref.csproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_ClassConstraint_Neg.ilproj index b93fb3ce48..7187cb451a 100644 --- a/tests/src/GC/Scenarios/WeakReference/weakref.csproj +++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_ClassConstraint_Neg.ilproj @@ -2,17 +2,20 @@ <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>Method_ClassConstraint_Neg</AssemblyName> <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> + <OutputType>Library</OutputType> <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> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <!-- Default configurations to help VS understand the configurations --> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> @@ -26,16 +29,11 @@ </ItemGroup> <ItemGroup> <!-- Add Compile Object Here --> - <Compile Include="WeakRef.cs" /> + <Compile Include="Method_ClassConstraint_Neg.il" /> </ItemGroup> <ItemGroup> <None Include="app.config" /> - <None Include="$(GCPackagesConfigFileDirectory)extra\project.json" /> </ItemGroup> - <PropertyGroup> - <ProjectJson>$(GCPackagesConfigFileDirectory)extra\project.json</ProjectJson> - <ProjectLockJson>$(GCPackagesConfigFileDirectory)extra\project.lock.json</ProjectLockJson> - </PropertyGroup> <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> </ItemGroup> diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_Constraints_Negative.cs b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_Constraints_Negative.cs new file mode 100644 index 0000000000..1efac5d6b7 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_Constraints_Negative.cs @@ -0,0 +1,191 @@ +// 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. + +// NEGATIVE TESTS +/* Test various combinations of constraints on methods +CONSTRAINTS: + +default ctor +reference type +valuetype +default ctor, reference tyoe +default ctor, valuetype + +Test each constraint with +- Class with default nullary ctor (Generic/Non generic) +- Class with no default nullary ctor (Generic/Non generic) +- Class from mscorlib with default nullary ctor +- Abstract Class from mscorlib with no default nullary ctor + +- Struct from mscorlib (Generic/Non generic) +- Struct (Generic/Non generic) +- Enum (Generic/Non generic) + +- Interface (Generic/Non generic) + +- Array + +- Delegate + +- Nullable<T> +*/ + +using System; +using System.Security; + +public class Test +{ + static bool pass; + static int testNumber = 1; + + delegate void Case(); + + + static void Check(Case mytest, string testName, string type, string methodName, string violatingType) + { + + Console.Write("Test"+testNumber + ": " + testName); + ++testNumber; + + + try + { + mytest(); + + Console.WriteLine("\nFAIL: Did not catch expected TypeLoadException"); + pass = false; + } + catch (VerificationException e) + { + + + Test.CheckVerificationExceptionMessage(8311, e, type, methodName, violatingType); + } + + catch (Exception e) + { + Console.WriteLine("\nFAIL: Caught unexpected exception: " + e); + pass = false; + } + + } + + + public static void CheckVerificationExceptionMessage(uint ResourceID, VerificationException e, string type, string methodName, string violatingType) + { + // "Method %1.%2: type argument '%3' violates the constraint of type parameter '%4'." + bool found1 = e.ToString().IndexOf(type + "." + methodName) >= 0; + bool found2 = e.ToString().IndexOf(violatingType) >= 0; + bool found3 = e.ToString().IndexOf("T") >= 0; + + if (!found1 || !found2 || !found3) + { + Console.WriteLine(" : Exception message is incorrect"); + Console.WriteLine("Expected: " + "Method " + type + "." + methodName + ": type argument '" + violatingType + "' violates the constraint of type parameter 'T'"); + Console.WriteLine("Actual: " + e.Message.ToString()); + pass = false; + } + else + { + Console.WriteLine(" : Caught expected exception"); + } + } + + + + public static int Main() + { + pass = true; + + Console.WriteLine("\nNEGATIVE TESTS"); + + Console.WriteLine("\nType: A<T> where T : new()\n"); + + + Check(new Case(M_DefaultCtorConstraint.Test2), "Generic argument is a class with no default ctor", "A", "method1", "ClassNoCtor"); + Check(new Case(M_DefaultCtorConstraint.Test4), "Generic argument is a delegate", "A", "method1", "Delegate1"); + Check(new Case(M_DefaultCtorConstraint.Test6), "Generic argument is an mscorlib abstract class with no default ctor", "A", "method1", "System.ValueType"); + Check(new Case(M_DefaultCtorConstraint.Test7), "Generic argument is an interface with no default ctor", "A", "method1", "NonGenInterface"); + + // WRONG? + Check(new Case(M_DefaultCtorConstraint.Test9), "Generic argument is an array of classes with default ctor", "A", "method1", "ClassWithCtor[]"); + + Check(new Case(M_DefaultCtorConstraintGenTypes.Test2), " Generic argument is a generic class with no default ctor", "A", "method1", "GenClassNoCtor[System.Int32]"); + Check(new Case(M_DefaultCtorConstraintGenTypes.Test5), "Generic argument is a generic interface", "A", "method1", "GenInterface[System.Int32]"); + + + Console.WriteLine("\nType: A<T> where T : class()\n"); + + Check(new Case(M_ClassConstraint.Test3), "Generic argument is a struct", "B", "method1", "NonGenStruct"); + Check(new Case(M_ClassConstraint.Test8), "Generic argument is an enum", "B", "method1", "Enum1"); + Check(new Case(M_ClassConstraintGenTypes.Test3), "Generic argument is a generic struct with default ctor", "B", "method1", "GenStruct[System.Int32]"); + Check(new Case(M_ClassConstraintGenTypes.Test6), "Generic argument is Nullable<T>", "B", "method1", "System.Nullable`1[System.Int32]"); + + Console.WriteLine("\nType: A<T> where T : struct()\n"); + + Check(new Case(M_StructConstraint.Test1), "Generic argument is a class with default ctor", "C", "method1", "ClassWithCtor"); + Check(new Case(M_StructConstraint.Test2), "Generic argument is a class with no default ctor", "C", "method1", "ClassNoCtor"); + Check(new Case(M_StructConstraint.Test4), "Generic argument is a delegate", "C", "method1", "Delegate1"); + Check(new Case(M_StructConstraint.Test5), "Generic argument is an mscorlib class with default ctor", "C", "method1", "System.Object"); + Check(new Case(M_StructConstraint.Test6), "Generic argument is an mscorlib abstract class with no default ctor", "C", "method1", "System.ValueType"); + Check(new Case(M_StructConstraint.Test7), "Generic argument is an interface", "C", "method1", "NonGenInterface"); + Check(new Case(M_StructConstraint.Test10), "Generic argument is an array of classes with default ctor", "C", "method1", "ClassWithCtor[]"); + + Check(new Case(M_StructConstraintGenTypes.Test1), "Generic argument is a generic class with default ctor", "C", "method1", "GenClassWithCtor[System.Int32]"); + Check(new Case(M_StructConstraintGenTypes.Test2), "Generic argument is a generic class with no default ctor", "C", "method1", "GenClassNoCtor[System.Int32]"); + Check(new Case(M_StructConstraintGenTypes.Test5), "Generic argument is a generic interface", "C", "method1", "GenInterface[System.Int32]"); + Check(new Case(M_StructConstraintGenTypes.Test7), "Generic argument is Nullable<T>", "C", "method1", "System.Nullable`1[System.Int32]"); + + + + Console.WriteLine("\nType: A<T> where T : class(), new() \n"); + + Check(new Case(M_DefaultCtorAndClassConstraint.Test2), "Generic argument is a class with no default ctor", "D", "method1", "ClassNoCtor"); + Check(new Case(M_DefaultCtorAndClassConstraint.Test3), "Generic argument is a struct", "D", "method1", "NonGenStruct"); + Check(new Case(M_DefaultCtorAndClassConstraint.Test4), "Generic argument is a delegate", "D", "method1", "Delegate1"); + Check(new Case(M_DefaultCtorAndClassConstraint.Test6), "Generic argument is an mscorlib abstract class with no default ctor", "D", "method1", "System.ValueType"); + Check(new Case(M_DefaultCtorAndClassConstraint.Test9), "Generic argument is an mscorlib struct", "D", "method1", "System.DateTime"); + Check(new Case(M_DefaultCtorAndClassConstraint.Test7), "Generic argument is an interface", "D", "method1", "NonGenInterface"); + Check(new Case(M_DefaultCtorAndClassConstraint.Test8), "Generic argument is an enum", "D", "method1", "Enum1"); + Check(new Case(M_DefaultCtorAndClassConstraint.Test10), "Generic argument is an array of classes with default ctor", "D", "method1", "ClassWithCtor[]"); + + + Check(new Case(M_DefaultCtorAndClassConstraintGenTypes.Test3), "Generic argument is a generic struct", "D", "method1", "GenStruct[System.Int32]"); + Check(new Case(M_DefaultCtorAndClassConstraintGenTypes.Test2), "Generic argument is a generic class with no default ctor", "D", "method1", "GenClassNoCtor[System.Int32]"); + Check(new Case(M_DefaultCtorAndClassConstraintGenTypes.Test5), "Generic argument is a generic interface", "D", "method1", "GenInterface[System.Int32]"); + Check(new Case(M_DefaultCtorAndClassConstraintGenTypes.Test6), "Generic argument is a generic mscorlib struct", "D", "method1", "System.Collections.Generic.KeyValuePair`2[NonGenStruct,System.Int32]"); + Check(new Case(M_DefaultCtorAndClassConstraintGenTypes.Test7), "Generic argument is Nullable<T>", "D", "method1", "System.Nullable`1[System.Int32]"); + + + Console.WriteLine("\nType: A<T> where T : struct(), new()\n"); + + Check(new Case(M_DefaultCtorAndStructConstraint.Test1), "Generic argument is a class with default ctor", "E", "method1", "ClassWithCtor"); + Check(new Case(M_DefaultCtorAndStructConstraint.Test2), "Generic argument is a class with no default ctor", "E", "method1", "ClassNoCtor"); + Check(new Case(M_DefaultCtorAndStructConstraint.Test4), "Generic argument is a delegate", "E", "method1", "Delegate1"); + Check(new Case(M_DefaultCtorAndStructConstraint.Test5), "Generic argument is an mscorlib class with default ctor", "E", "method1", "System.Object"); + Check(new Case(M_DefaultCtorAndStructConstraint.Test6), "Generic argument is an mscorlib abstract class with no default ctor", "E", "method1", "System.ValueType"); + Check(new Case(M_DefaultCtorAndStructConstraint.Test7), "Generic argument is an interface", "E", "method1", "NonGenInterface"); + + Check(new Case(M_DefaultCtorAndStructConstraint.Test10), "Generic argument is an array of classes with default ctor", "E", "method1", "NonGenStruct[]"); + + Check(new Case(M_DefaultCtorAndStructConstraintGenTypes.Test1), "Generic argument is a generic class with default ctor", "E", "method1", "GenClassWithCtor[System.Int32]"); + Check(new Case(M_DefaultCtorAndStructConstraintGenTypes.Test2), "Generic argument is a generic class with no default ctor", "E", "method1", "GenClassNoCtor[System.Int32]"); + Check(new Case(M_DefaultCtorAndStructConstraintGenTypes.Test5), "Generic argument is a generic interface", "E", "method1", "GenInterface[System.Int32]"); + Check(new Case(M_DefaultCtorAndStructConstraintGenTypes.Test7), "Generic argument is Nullable<T>", "E", "method1", "System.Nullable`1[System.Int32]"); + + + if (pass) + { + Console.WriteLine("PASS"); + return 100; + } + else + { + Console.WriteLine("FAIL"); + return 101; + } + + } +} + diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_Constraints_Negative.csproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_Constraints_Negative.csproj new file mode 100644 index 0000000000..b8677916bb --- /dev/null +++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_Constraints_Negative.csproj @@ -0,0 +1,52 @@ +<?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>Method_Constraints_Negative</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </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="Method_Constraints_Negative.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="Method_ClassConstraint_Neg.ilproj" /> + <ProjectReference Include="Method_DefaultCtorAndClassConstraint_Neg.ilproj" /> + <ProjectReference Include="Method_DefaultCtorAndStructConstraint_Neg.ilproj" /> + <ProjectReference Include="Method_DefaultCtorConstraint_Neg.ilproj" /> + <ProjectReference Include="Method_StructConstraint_Neg.ilproj" /> + <ProjectReference Include="types.ilproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndClassConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndClassConstraint_Neg.il new file mode 100644 index 0000000000..fd926bb4fe --- /dev/null +++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndClassConstraint_Neg.il @@ -0,0 +1,211 @@ +// 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{} +.assembly extern types{} + +.assembly Method_DefaultCtorAndClassConstraint_Neg {} + + + +.class public auto ansi beforefieldinit D + extends [mscorlib]System.Object +{ + + // Generic method with class() and new() constraints + .method public hidebysig instance void + method1<class .ctor T>() cil managed + { + .maxstack 8 + ret + } + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + .maxstack 8 + ldarg.0 + call instance void [mscorlib]System.Object::.ctor() + ret + } + + + +} + +.class public auto ansi beforefieldinit M_DefaultCtorAndClassConstraint + extends [mscorlib]System.Object +{ + // NEGATIVE TEST + // generic argument is a class with no default ctor + .method public hidebysig static void Test2() cil managed + { + .maxstack 1 + + newobj instance void class D::.ctor() + call instance void class D::method1<class [types]ClassNoCtor>() + ret + } + + + // NEGATIVE TEST + // generic argument is a struct + .method public hidebysig static void Test3() cil managed + { + .maxstack 1 + + newobj instance void class D::.ctor() + call instance void class D::method1<valuetype [types]NonGenStruct>() + ret + } + + // NEGATIVE TEST + // generic argument is a delegate (doesn't have public parameterless constructor) + .method public hidebysig static void Test4() cil managed + { + .maxstack 1 + + newobj instance void class D::.ctor() + call instance void class D::method1<class [types]Delegate1>() + + ret + } + + + + // NEGATIVE TEST + // generic argument is an mscorlib abstract class with no default ctor + + .method public hidebysig static void Test6() cil managed + { + .maxstack 1 + + newobj instance void class D::.ctor() + call instance void class D::method1<class [mscorlib]System.ValueType>() + + ret + } + + + // NEGATIVE TEST + // generic argument is an interface + .method public hidebysig static void Test7() cil managed + { + .maxstack 1 + + newobj instance void class D::.ctor() + call instance void class D::method1<class [types]NonGenInterface>() + + ret + } + + + // NEGATIVE TEST + // generic argument is an enum + .method public hidebysig static void Test8() cil managed + { + .maxstack 1 + + newobj instance void class D::.ctor() + call instance void class D::method1<valuetype [types]Enum1>() + + ret + } + + + // NEGATIVE TEST + // generic argument is an mscorlib struct + .method public hidebysig static void Test9() cil managed + { + .maxstack 1 + + newobj instance void class D::.ctor() + call instance void class D::method1<valuetype [mscorlib]System.DateTime>() + + ret + } + + // NEGATIVE TEST + // generic argument is an array of classes with default ctor + .method public hidebysig static void Test10() cil managed + { + .maxstack 1 + + newobj instance void class D::.ctor() + call instance void class D::method1<class [types]ClassWithCtor[]>() + + ret + } + +} + +.class public auto ansi beforefieldinit M_DefaultCtorAndClassConstraintGenTypes + extends [mscorlib]System.Object +{ + + // NEGATIVE TEST + // generic argument is a class with no default ctor + .method public hidebysig static void Test2() cil managed + { + .maxstack 1 + + newobj instance void class D::.ctor() + call instance void class D::method1<class [types]GenClassNoCtor<int32>>() + ret + } + + + // NEGATIVE TEST + // generic argument is a generic struct + .method public hidebysig static void Test3() cil managed + { + .maxstack 1 + + newobj instance void class D::.ctor() + call instance void class D::method1<valuetype [types]GenStruct<int32>>() + + ret + } + + + // NEGATIVE TEST + // generic argument is an generic interface + .method public hidebysig static void Test5() cil managed + { + .maxstack 1 + + newobj instance void class D::.ctor() + call instance void class D::method1<class [types]GenInterface<int32>>() + + ret + } + + + + // NEGATIVE TEST + // generic argument is an mscorlib generic struct + .method public hidebysig static void Test6() cil managed + { + .maxstack 1 + + newobj instance void class D::.ctor() + call instance void class D::method1<valuetype [mscorlib]System.Collections.Generic.KeyValuePair`2<valuetype [types]NonGenStruct,int32>>() + + + ret + } + + // NEGATIVE TEST + // generic argument is NUllable<T> + .method public hidebysig static void Test7() cil managed + { + .maxstack 1 + + newobj instance void class D::.ctor() + call instance void class D::method1<valuetype [mscorlib]System.'Nullable`1'<int32>>() + + ret + } + +} diff --git a/tests/src/GC/Scenarios/WeakReference/getgencollect.csproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndClassConstraint_Neg.ilproj index 8bf2b814bc..ec74a8cafe 100644 --- a/tests/src/GC/Scenarios/WeakReference/getgencollect.csproj +++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndClassConstraint_Neg.ilproj @@ -2,17 +2,20 @@ <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>Method_DefaultCtorAndClassConstraint_Neg</AssemblyName> <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> + <OutputType>Library</OutputType> <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> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <!-- Default configurations to help VS understand the configurations --> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> @@ -26,16 +29,11 @@ </ItemGroup> <ItemGroup> <!-- Add Compile Object Here --> - <Compile Include="GetGenCollect.cs" /> + <Compile Include="Method_DefaultCtorAndClassConstraint_Neg.il" /> </ItemGroup> <ItemGroup> <None Include="app.config" /> - <None Include="$(GCPackagesConfigFileDirectory)extra\project.json" /> </ItemGroup> - <PropertyGroup> - <ProjectJson>$(GCPackagesConfigFileDirectory)extra\project.json</ProjectJson> - <ProjectLockJson>$(GCPackagesConfigFileDirectory)extra\project.lock.json</ProjectLockJson> - </PropertyGroup> <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> </ItemGroup> diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndStructConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndStructConstraint_Neg.il new file mode 100644 index 0000000000..5214b72882 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndStructConstraint_Neg.il @@ -0,0 +1,185 @@ +// 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{} +.assembly extern types{} + +.assembly Method_DefaultCtorAndStructConstraint_Neg {} + + + +.class public auto ansi beforefieldinit E + extends [mscorlib]System.Object +{ + + // Generic method with struct() and new() constraints + .method public hidebysig instance void + method1<valuetype .ctor T>() cil managed + { + .maxstack 8 + ret + } + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + .maxstack 8 + ldarg.0 + call instance void [mscorlib]System.Object::.ctor() + ret + } +} + +.class public auto ansi beforefieldinit M_DefaultCtorAndStructConstraint + extends [mscorlib]System.Object +{ + // NEGATIVE TEST + // generic argument is a class with default ctor + .method public hidebysig static void Test1() cil managed + { + .maxstack 1 + + newobj instance void class E::.ctor() + call instance void class E::method1<class [types]ClassWithCtor>() + ret + } + + // NEGATIVE TEST + // generic argument is a class with no default ctor + .method public hidebysig static void Test2() cil managed + { + .maxstack 1 + + newobj instance void class E::.ctor() + call instance void class E::method1<class [types]ClassNoCtor>() + + ret + } + + + // NEGATIVE TEST + // generic argument is a delegate + .method public hidebysig static void Test4() cil managed + { + .maxstack 1 + + newobj instance void class E::.ctor() + call instance void class E::method1<class [types]Delegate1>() + ret + } + + + + + // NEGATIVE TEST + // generic argument is an mscorlib class with default ctor + .method public hidebysig static void Test5() cil managed + { + .maxstack 1 + + newobj instance void class E::.ctor() + call instance void class E::method1<class [mscorlib]System.Object>() + + ret + } + + + + // NEGATIVE TEST + // generic argument is an mscorlib abstract class with no default ctor + + .method public hidebysig static void Test6() cil managed + { + .maxstack 1 + + newobj instance void class E::.ctor() + call instance void class E::method1<class [mscorlib]System.ValueType>() + + ret + } + + + // NEGATIVE TEST + // generic argument is an interface + .method public hidebysig static void Test7() cil managed + { + .maxstack 1 + + newobj instance void class E::.ctor() + call instance void class E::method1<class [types]NonGenInterface>() + + ret + } + + // NEGATIVE TEST + // generic argument is an array of classes with default ctor + .method public hidebysig static void Test10() cil managed + { + .maxstack 1 + + newobj instance void class E::.ctor() + call instance void class E::method1<valuetype [types]NonGenStruct[]>() + ret + } + + +} + +.class public auto ansi beforefieldinit M_DefaultCtorAndStructConstraintGenTypes + extends [mscorlib]System.Object +{ + // NEGATIVE TEST + // generic argument is a class with default ctor + .method public hidebysig static void Test1() cil managed + { + .maxstack 1 + + newobj instance void class E::.ctor() + call instance void class E::method1<class [types]GenClassWithCtor<int32>>() + ret + } + + // NEGATIVE TEST + // generic argument is a class with no default ctor + .method public hidebysig static void Test2() cil managed + { + .maxstack 1 + + newobj instance void class E::.ctor() + call instance void class E::method1<class [types]GenClassNoCtor<int32>>() + + ret + } + + // NEGATIVE TEST + // generic argument is an interface + .method public hidebysig static void Test5() cil managed + { + .maxstack 1 + + newobj instance void class E::.ctor() + call instance void class E::method1<class [types]GenInterface<int32>>() + ret + } + + + // NEGATIVE TEST + // generic argument is NUllable<T> + .method public hidebysig static void Test7() cil managed + { + .maxstack 1 + + newobj instance void class E::.ctor() + call instance void class E::method1<valuetype [mscorlib]System.'Nullable`1'<int32>>() + + ret + } + + + +} + + + + diff --git a/tests/src/GC/Features/Finalizer/finalizeother/finalizedirectedgraph.csproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndStructConstraint_Neg.ilproj index eb454c8a82..d5f7e5dc6d 100644 --- a/tests/src/GC/Features/Finalizer/finalizeother/finalizedirectedgraph.csproj +++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorAndStructConstraint_Neg.ilproj @@ -2,17 +2,20 @@ <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>Method_DefaultCtorAndStructConstraint_Neg</AssemblyName> <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> + <OutputType>Library</OutputType> <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> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <!-- Default configurations to help VS understand the configurations --> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> @@ -26,16 +29,11 @@ </ItemGroup> <ItemGroup> <!-- Add Compile Object Here --> - <Compile Include="FinalizeDirectedGraph.cs" /> + <Compile Include="Method_DefaultCtorAndStructConstraint_Neg.il" /> </ItemGroup> <ItemGroup> <None Include="app.config" /> - <None Include="$(GCPackagesConfigFileDirectory)extra\project.json" /> </ItemGroup> - <PropertyGroup> - <ProjectJson>$(GCPackagesConfigFileDirectory)extra\project.json</ProjectJson> - <ProjectLockJson>$(GCPackagesConfigFileDirectory)extra\project.lock.json</ProjectLockJson> - </PropertyGroup> <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> </ItemGroup> diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorConstraint_Neg.il new file mode 100644 index 0000000000..9bf744bc72 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorConstraint_Neg.il @@ -0,0 +1,130 @@ +// 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{} +.assembly extern types{} + +.assembly Method_DefaultCtorConstraint_Neg {} + + +.class public auto ansi beforefieldinit A + extends [mscorlib]System.Object +{ + + // Generic method with new() constraint + .method public hidebysig instance void + method1<.ctor T>() cil managed + { + .maxstack 8 + ret + } + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + .maxstack 8 + ldarg.0 + call instance void [mscorlib]System.Object::.ctor() + ret + } + +} + +.class public auto ansi beforefieldinit M_DefaultCtorConstraint + extends [mscorlib]System.Object +{ + + // NEGATIVE TEST + // generic argument is a class with no default ctor + .method public hidebysig static void Test2() cil managed + { + .maxstack 1 + newobj instance void class A::.ctor() + call instance void class A::method1<class [types]ClassNoCtor>() + ret + } + + + // NEGATIVE TEST + // generic argument is a delegate (doesn't have public parameterless constructor) + .method public hidebysig static void Test4() cil managed + { + .maxstack 1 + newobj instance void class A::.ctor() + call instance void class A::method1<class [types]Delegate1>() + ret + } + + + // NEGATIVE TEST + // generic argument is an mscorlib abstract class with no default ctor + + .method public hidebysig static void Test6() cil managed + { + .maxstack 1 + + newobj instance void class A::.ctor() + call instance void class A::method1<class [mscorlib]System.ValueType>() + ret + } + + + // NEGATIVE TEST + // generic argument is an interface with no default ctor + .method public hidebysig static void Test7() cil managed + { + .maxstack 1 + + newobj instance void class A::.ctor() + call instance void class A::method1<class [types]NonGenInterface>() + ret + } + + // NEGATIVE TEST + // generic argument is an array of classes with default ctor + .method public hidebysig static void Test9() cil managed + { + .maxstack 1 + + newobj instance void class A::.ctor() + call instance void class A::method1<class [types]ClassWithCtor[]>() + + ret + } + + +} + +.class public auto ansi beforefieldinit M_DefaultCtorConstraintGenTypes + extends [mscorlib]System.Object +{ + + // NEGATIVE TEST + // generic argument is a class with no default ctor + .method public hidebysig static void Test2() cil managed + { + .maxstack 1 + + newobj instance void class A::.ctor() + call instance void class A::method1<class [types]GenClassNoCtor<int32>>() + ret + } + + + // NEGATIVE TEST + // generic argument is an interface + .method public hidebysig static void Test5() cil managed + { + .maxstack 1 + + newobj instance void class A::.ctor() + call instance void class A::method1<class [types]GenInterface<int32>>() + + ret + } +} + + + + diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorConstraint_Neg.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorConstraint_Neg.ilproj new file mode 100644 index 0000000000..d0d36a934d --- /dev/null +++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_DefaultCtorConstraint_Neg.ilproj @@ -0,0 +1,43 @@ +<?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>Method_DefaultCtorConstraint_Neg</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Library</OutputType> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </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="Method_DefaultCtorConstraint_Neg.il" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_StructConstraint_Neg.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_StructConstraint_Neg.il new file mode 100644 index 0000000000..570576c59a --- /dev/null +++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_StructConstraint_Neg.il @@ -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. + +.assembly extern mscorlib{} +.assembly extern types{} + +.assembly Method_StructConstraint_Neg {} + + + +.class public auto ansi beforefieldinit C + extends [mscorlib]System.Object +{ + + // Generic method with class() constraint + .method public hidebysig instance void + method1<valuetype T>() cil managed + { + .maxstack 8 + ret + } + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + .maxstack 8 + ldarg.0 + call instance void [mscorlib]System.Object::.ctor() + ret + } +} + +.class public auto ansi beforefieldinit M_StructConstraint + extends [mscorlib]System.Object +{ + // NEGATIVE TEST + // generic argument is a class with default ctor + .method public hidebysig static void Test1() cil managed + { + .maxstack 1 + + newobj instance void class C::.ctor() + call instance void class C::method1<class [types]ClassWithCtor>() + + ret + } + + // NEGATIVE TEST + // generic argument is a class with no default ctor + .method public hidebysig static void Test2() cil managed + { + .maxstack 1 + + newobj instance void class C::.ctor() + call instance void class C::method1<class [types]ClassNoCtor>() + ret + } + + + // NEGATIVE TEST + // generic argument is a delegate + .method public hidebysig static void Test4() cil managed + { + .maxstack 1 + + newobj instance void class C::.ctor() + call instance void class C::method1<class [types]Delegate1>() + ret + } + + // NEGATIVE TEST + // generic argument is an mscorlib class with default ctor + .method public hidebysig static void Test5() cil managed + { + .maxstack 1 + + newobj instance void class C::.ctor() + call instance void class C::method1<class [mscorlib]System.Object>() + ret + } + + + // NEGATIVE TEST + // generic argument is an mscorlib abstract class with no default ctor + + .method public hidebysig static void Test6() cil managed + { + .maxstack 1 + + newobj instance void class C::.ctor() + call instance void class C::method1<class [mscorlib]System.ValueType>() + ret + } + + + // NEGATIVE TEST + // generic argument is an interface with no default ctor + .method public hidebysig static void Test7() cil managed + { + .maxstack 1 + + newobj instance void class C::.ctor() + call instance void class C::method1<class [types]NonGenInterface>() + ret + } + + + // NEGATIVE TEST + // generic argument is an array of classes with default ctor + .method public hidebysig static void Test10() cil managed + { + .maxstack 1 + + newobj instance void class C::.ctor() + call instance void class C::method1<class [types]ClassWithCtor[]>() + ret + } + + +} + +.class public auto ansi beforefieldinit M_StructConstraintGenTypes + extends [mscorlib]System.Object +{ + // NEGATIVE TEST + // generic argument is a class with default ctor + .method public hidebysig static void Test1() cil managed + { + .maxstack 1 + + newobj instance void class C::.ctor() + call instance void class C::method1<class [types]GenClassWithCtor<int32>>() + + ret + } + + // NEGATIVE TEST + // generic argument is a class with no default ctor + .method public hidebysig static void Test2() cil managed + { + .maxstack 1 + + + newobj instance void class C::.ctor() + call instance void class C::method1<class [types]GenClassNoCtor<int32>>() + + ret + } + + + // NEGATIVE TEST + // generic argument is an interface + .method public hidebysig static void Test5() cil managed + { + .maxstack 1 + + newobj instance void class C::.ctor() + call instance void class C::method1<class [types]GenInterface<int32>>() + + ret + } + + // NEGATIVE TEST + // generic argument is NUllable<T> + .method public hidebysig static void Test7() cil managed + { + .maxstack 1 + + newobj instance void class C::.ctor() + call instance void class C::method1<valuetype [mscorlib]System.'Nullable`1'<int32>>() + + ret + } + +} + + + + diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_StructConstraint_Neg.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_StructConstraint_Neg.ilproj new file mode 100644 index 0000000000..3611ac569b --- /dev/null +++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/Method_StructConstraint_Neg.ilproj @@ -0,0 +1,43 @@ +<?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>Method_StructConstraint_Neg</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Library</OutputType> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </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="Method_StructConstraint_Neg.il" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/app.config b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/app.config new file mode 100644 index 0000000000..62803f5972 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/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>
\ No newline at end of file diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/project.json b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/project.json new file mode 100644 index 0000000000..cda793f996 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/project.json @@ -0,0 +1,11 @@ +{ + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816", + "System.Console": "4.0.0-rc2-23816", + "System.Runtime": "4.1.0-rc2-23816", + "System.Runtime.Extensions": "4.0.10" + }, + "frameworks": { + "dnxcore50": {} + } +} diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/types.il b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/types.il new file mode 100644 index 0000000000..a43bb72b20 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/types.il @@ -0,0 +1,115 @@ +// 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{} + +.assembly Types {} + +// class with public nullary ctor +.class public auto ansi beforefieldinit ClassWithCtor + extends [mscorlib]System.Object +{ + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + .maxstack 8 + ldarg.0 + call instance void [mscorlib]System.Object::.ctor() + ret + } +} + +// generic class with public nullary ctor +.class public auto ansi beforefieldinit GenClassWithCtor<T> + extends [mscorlib]System.Object +{ + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + .maxstack 8 + ldarg.0 + call instance void [mscorlib]System.Object::.ctor() + ret + } +} + + +// class without public nullary ctor +.class public auto ansi beforefieldinit ClassNoCtor + extends [mscorlib]System.Object +{ +} + +// generic class without public nullary ctor +.class public auto ansi beforefieldinit GenClassNoCtor<T> + extends [mscorlib]System.Object +{ +} + + +// struct (valuetypes have public nullary ctors by default) +.class public sequential ansi sealed beforefieldinit NonGenStruct + extends [mscorlib]System.ValueType +{ + .pack 0 + .size 1 +} + + + +// generic struct (valuetypes have public nullary ctors by default) +.class public sequential ansi sealed beforefieldinit GenStruct<T> + extends [mscorlib]System.ValueType +{ + .pack 0 + .size 1 +} + +// interface without public nullary ctor +.class public abstract interface auto ansi beforefieldinit NonGenInterface +{ +} + +// interface without public nullary ctor +.class public abstract interface auto ansi beforefieldinit GenInterface<T> +{ +} + + +.class public auto ansi sealed Enum1 + extends [mscorlib]System.Enum +{ + .field public specialname rtspecialname int32 value__ + .field public static literal valuetype Enum1 One = int32(0x00000000) +} + + +// doesn't have public parameterless constructor +.class public auto ansi sealed Delegate1 + extends [mscorlib]System.MulticastDelegate +{ + + .method public hidebysig specialname rtspecialname + instance void .ctor(object 'object', + native int 'method') runtime managed + { + } + + .method public hidebysig newslot virtual + instance void Invoke() runtime managed + { + } + + .method public hidebysig newslot virtual + instance class [mscorlib]System.IAsyncResult + BeginInvoke(class [mscorlib]System.AsyncCallback callback, + object 'object') runtime managed + { + } + + .method public hidebysig newslot virtual + instance void EndInvoke(class [mscorlib]System.IAsyncResult result) runtime managed + { + } +} diff --git a/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/types.ilproj b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/types.ilproj new file mode 100644 index 0000000000..9fc7db8e42 --- /dev/null +++ b/tests/src/Loader/classloader/generics/Constraints/ConstraintsOnMethod/Negative/types.ilproj @@ -0,0 +1,43 @@ +<?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>types</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Library</OutputType> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </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="types.il" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file |