diff options
Diffstat (limited to 'tests/src/Loader/classloader/v1/Beta1')
137 files changed, 17153 insertions, 0 deletions
diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-1-1.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-1-1.cs new file mode 100644 index 0000000000..c250ae158a --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-1-1.cs @@ -0,0 +1,231 @@ +// 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. + +////////////////////////////////////////////////////////// +// L-1-1-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 1-deep inheritance in +// the same assembly and module +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +using System; + +class Test{ +public static int Main(){ + int mi_RetCode; + B b = new B(); + mi_RetCode = b.Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; +} +} + +class A{ + + ////////////////////////////// + // Instance Fields +public int FldPubInst; +//private int FldPrivInst; +protected int FldFamInst; //Translates to "family" +internal int FldAsmInst; //Translates to "assembly" +protected internal int FldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields +public static int FldPubStat; +//private static int FldPrivStat; +protected static int FldFamStat; //family +internal static int FldAsmStat; //assembly +protected internal int FldFoaStat; //famorassem + + ////////////////////////////// + // Instance Methods +public int MethPubInst(){ + Console.WriteLine("A::MethPubInst()"); + return 100; +} + +private int MethPrivInst(){ + Console.WriteLine("A::MethPrivInst()"); + return 100; +} + +protected int MethFamInst(){ + Console.WriteLine("A::MethFamInst()"); + return 100; +} + +internal int MethAsmInst(){ + Console.WriteLine("A::MethAsmInst()"); + return 100; +} + +protected internal int MethFoaInst(){ + Console.WriteLine("A::MethFoaInst()"); + return 100; +} + + ////////////////////////////// + // Static Methods +public static int MethPubStat(){ + Console.WriteLine("A::MethPubStat()"); + return 100; +} + +private static int MethPrivStat(){ + Console.WriteLine("A::MethPrivStat()"); + return 100; +} + +protected static int MethFamStat(){ + Console.WriteLine("A::MethFamStat()"); + return 100; +} + +internal static int MethAsmStat(){ + Console.WriteLine("A::MethAsmStat()"); + return 100; +} + +protected internal static int MethFoaStat(){ + Console.WriteLine("A::MethFoaStat()"); + return 100; +} + + ////////////////////////////// + // Virtual Instance Methods +public virtual int MethPubVirt(){ + Console.WriteLine("A::MethPubVirt()"); + return 100; +} + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing MethPrivVirt() here. + +protected virtual int MethFamVirt(){ + Console.WriteLine("A::MethFamVirt()"); + return 100; +} + +internal virtual int MethAsmVirt(){ + Console.WriteLine("A::MethAsmVirt()"); + return 100; +} + +protected internal virtual int MethFoaVirt(){ + Console.WriteLine("A::MethFoaVirt()"); + return 100; +} +} + +class B : A{ +public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance field access + FldPubInst = 100; + if(FldPubInst != 100) + mi_RetCode = 0; + + //@csharp - Note that C# will not compile an illegal access of FldPrivInst + //So there is no negative test here, it should be covered elsewhere and + //should throw a FielAccessException within the runtime. (IL sources is + //the most logical, only?, choice) + + FldFamInst = 100; + if(FldFamInst != 100) + mi_RetCode = 0; + + FldAsmInst = 100; + if(FldAsmInst != 100) + mi_RetCode = 0; + + FldFoaInst = 100; + if(FldFoaInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + FldPubStat = 100; + if(FldPubStat != 100) + mi_RetCode = 0; + + //@csharp - Again, note C# won't do private field access + + FldFamStat = 100; + if(FldFamStat != 100) + mi_RetCode = 0; + + FldAsmStat = 100; + if(FldAsmStat != 100) + mi_RetCode = 0; + + FldFoaStat = 100; + if(FldFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance method access + if(MethPubInst() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private method access + + if(MethFamInst() != 100) + mi_RetCode = 0; + + if(MethAsmInst() != 100) + mi_RetCode = 0; + + if(MethFoaInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethPubStat() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private method access + + if(MethFamStat() != 100) + mi_RetCode = 0; + + if(MethAsmStat() != 100) + mi_RetCode = 0; + + if(MethFoaStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test virtual method access + if(MethPubVirt() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private method access + + if(MethFamVirt() != 100) + mi_RetCode = 0; + + if(MethAsmVirt() != 100) + mi_RetCode = 0; + + if(MethFoaVirt() != 100) + mi_RetCode = 0; + + return mi_RetCode; +} +} + + + + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-1-1.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-1-1.csproj new file mode 100644 index 0000000000..6c01a0fb51 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-1-1.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-1-1</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-1-1.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-1-2.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-1-2.csproj new file mode 100644 index 0000000000..b1d5b5f37c --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-1-2.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-1-2</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-1-2D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-1-2D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-1-2D.cs new file mode 100644 index 0000000000..618e1d61f7 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-1-2D.cs @@ -0,0 +1,108 @@ +// 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. + +/////////////////////////////////////// +// L-1-1-2D.cs - DLL Component of +// L-1-1-2.cs test. - RDawson +// + +using System; + +class A{ + + ////////////////////////////// + // Instance Fields +public int FldPubInst; +private int FldPrivInst; +protected int FldFamInst; //Translates to "family" +internal int FldAsmInst; //Translates to "assembly" +protected internal int FldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields +public static int FldPubStat; +private static int FldPrivStat; +protected static int FldFamStat; //family +internal static int FldAsmStat; //assembly +protected internal int FldFoaStat; //famorassem + + ////////////////////////////// + // Instance Methods +public int MethPubInst(){ + Console.WriteLine("A::MethPubInst()"); + return 100; +} + +private int MethPrivInst(){ + Console.WriteLine("A::MethPrivInst()"); + return 100; +} + +protected int MethFamInst(){ + Console.WriteLine("A::MethFamInst()"); + return 100; +} + +internal int MethAsmInst(){ + Console.WriteLine("A::MethAsmInst()"); + return 100; +} + +protected internal int MethFoaInst(){ + Console.WriteLine("A::MethFoaInst()"); + return 100; +} + + ////////////////////////////// + // Static Methods +public static int MethPubStat(){ + Console.WriteLine("A::MethPubStat()"); + return 100; +} + +private static int MethPrivStat(){ + Console.WriteLine("A::MethPrivStat()"); + return 100; +} + +protected static int MethFamStat(){ + Console.WriteLine("A::MethFamStat()"); + return 100; +} + +internal static int MethAsmStat(){ + Console.WriteLine("A::MethAsmStat()"); + return 100; +} + +protected internal static int MethFoaStat(){ + Console.WriteLine("A::MethFoaStat()"); + return 100; +} + + ////////////////////////////// + // Virtual Instance Methods +public virtual int MethPubVirt(){ + Console.WriteLine("A::MethPubVirt()"); + return 100; +} + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing MethPrivVirt() here. + +protected virtual int MethFamVirt(){ + Console.WriteLine("A::MethFamVirt()"); + return 100; +} + +internal virtual int MethAsmVirt(){ + Console.WriteLine("A::MethAsmVirt()"); + return 100; +} + +protected internal virtual int MethFoaVirt(){ + Console.WriteLine("A::MethFoaVirt()"); + return 100; +} +} diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-1-3.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-1-3.cs new file mode 100644 index 0000000000..266d01d92e --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-1-3.cs @@ -0,0 +1,117 @@ +// 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. + +////////////////////////////////////////////////////////// +// L-1-1-2.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 1-deep inheritance in +// the same assembly and separate modules. +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// +//@charp - C# will not allow illegal assembly access, so there is no negative testing for that in the L-*-*-3 suites + +using System; + +class Test{ +public static int Main(){ + int mi_RetCode; + B b = new B(); + mi_RetCode = b.Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; +} +} + +class B : A{ +public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance field access + FldPubInst = 100; + if(FldPubInst != 100) + mi_RetCode = 0; + + //@csharp - Note that C# will not compile an illegal access of FldPrivInst + //So there is no negative test here, it should be covered elsewhere and + //should throw a FielAccessException within the runtime. (IL sources is + //the most logical, only?, choice) + + FldFamInst = 100; + if(FldFamInst != 100) + mi_RetCode = 0; + + FldFoaInst = 100; + if(FldFoaInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + FldPubStat = 100; + if(FldPubStat != 100) + mi_RetCode = 0; + + //@csharp - Again, note C# won't do private field access + + FldFamStat = 100; + if(FldFamStat != 100) + mi_RetCode = 0; + + FldFoaStat = 100; + if(FldFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance method access + if(MethPubInst() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private method access + + if(MethFamInst() != 100) + mi_RetCode = 0; + + if(MethFoaInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethPubStat() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private method access + + if(MethFamStat() != 100) + mi_RetCode = 0; + + if(MethFoaStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test virtual method access + if(MethPubVirt() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private method access + + if(MethFamVirt() != 100) + mi_RetCode = 0; + + if(MethFoaVirt() != 100) + mi_RetCode = 0; + + return mi_RetCode; +} +} + + + + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-1-3.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-1-3.csproj new file mode 100644 index 0000000000..3e81bee39f --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-1-3.csproj @@ -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>L-1-1-3</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-1-3.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <ProjectReference Include="L-1-1-3D.csproj" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-1-3D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-1-3D.cs new file mode 100644 index 0000000000..3e473ec19c --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-1-3D.cs @@ -0,0 +1,108 @@ +// 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. + +/////////////////////////////////////// +// L-1-1-2D.cs - DLL Component of +// L-1-1-2.cs test. - RDawson +// + +using System; + +public class A{ + + ////////////////////////////// + // Instance Fields +public int FldPubInst; +private int FldPrivInst; +protected int FldFamInst; //Translates to "family" +internal int FldAsmInst; //Translates to "assembly" +protected internal int FldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields +public static int FldPubStat; +private static int FldPrivStat; +protected static int FldFamStat; //family +internal static int FldAsmStat; //assembly +protected internal int FldFoaStat; //famorassem + + ////////////////////////////// + // Instance Methods +public int MethPubInst(){ + Console.WriteLine("A::MethPubInst()"); + return 100; +} + +private int MethPrivInst(){ + Console.WriteLine("A::MethPrivInst()"); + return 100; +} + +protected int MethFamInst(){ + Console.WriteLine("A::MethFamInst()"); + return 100; +} + +internal int MethAsmInst(){ + Console.WriteLine("A::MethAsmInst()"); + return 100; +} + +protected internal int MethFoaInst(){ + Console.WriteLine("A::MethFoaInst()"); + return 100; +} + + ////////////////////////////// + // Static Methods +public static int MethPubStat(){ + Console.WriteLine("A::MethPubStat()"); + return 100; +} + +private static int MethPrivStat(){ + Console.WriteLine("A::MethPrivStat()"); + return 100; +} + +protected static int MethFamStat(){ + Console.WriteLine("A::MethFamStat()"); + return 100; +} + +internal static int MethAsmStat(){ + Console.WriteLine("A::MethAsmStat()"); + return 100; +} + +protected internal static int MethFoaStat(){ + Console.WriteLine("A::MethFoaStat()"); + return 100; +} + + ////////////////////////////// + // Virtual Instance Methods +public virtual int MethPubVirt(){ + Console.WriteLine("A::MethPubVirt()"); + return 100; +} + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing MethPrivVirt() here. + +protected virtual int MethFamVirt(){ + Console.WriteLine("A::MethFamVirt()"); + return 100; +} + +internal virtual int MethAsmVirt(){ + Console.WriteLine("A::MethAsmVirt()"); + return 100; +} + +protected internal virtual int MethFoaVirt(){ + Console.WriteLine("A::MethFoaVirt()"); + return 100; +} +} diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-1-3D.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-1-3D.csproj new file mode 100644 index 0000000000..4604f396f2 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-1-3D.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-1-3D</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-1-3D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-10-1.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-10-1.cs new file mode 100644 index 0000000000..07a494676c --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-10-1.cs @@ -0,0 +1,71 @@ +// 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. + +////////////////////////////////////////////////////////// +// L-1-9-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 1-deep implementation in +// the same assembly and module +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +//@csharp C# doesn't allow much flexibility here in terms of negative testing on interfaces... +//THIS NEEDS MORE COVERAGE + +using System; + +class Test{ +public static int Main(){ + int mi_RetCode; + C c = new C(); + mi_RetCode = c.Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; +} +} + +interface A{ +int MethPubInst(); +} + +interface B : A{ +int MethPubInstB(); +} + +class C : B{ +public int MethPubInst(){ + Console.WriteLine("B::MethPubInst()"); + return 100; +} + +public int MethPubInstB(){ + Console.WriteLine("B::MethPubInstB()"); + return 100; +} + +public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance method access + if(MethPubInst() != 100) + mi_RetCode = 0; + + if(MethPubInstB() != 100) + mi_RetCode = 0; + + return mi_RetCode; +} +} + + + + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-10-1.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-10-1.csproj new file mode 100644 index 0000000000..8066817b4d --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-10-1.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-10-1</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-10-1.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-10-2.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-10-2.csproj new file mode 100644 index 0000000000..d0b6e0ba65 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-10-2.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-10-2</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-10-2D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-10-2D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-10-2D.cs new file mode 100644 index 0000000000..736ddcdeff --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-10-2D.cs @@ -0,0 +1,12 @@ +// 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. + +interface A{ +int MethPubInst(); +} + +interface B : A{ +int MethPubInstB(); +} + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-10-3.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-10-3.cs new file mode 100644 index 0000000000..6b81b83779 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-10-3.cs @@ -0,0 +1,63 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +////////////////////////////////////////////////////////// +// L-1-9-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 1-deep implementation in +// the same assembly and module +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +//@csharp C# doesn't allow much flexibility here in terms of negative testing on interfaces... +//THIS NEEDS MORE COVERAGE + +using System; + +class Test{ +public static int Main(){ + int mi_RetCode; + C c = new C(); + mi_RetCode = c.Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; +} +} + +class C : B{ +public int MethPubInst(){ + Console.WriteLine("B::MethPubInst()"); + return 100; +} + +public int MethPubInstB(){ + Console.WriteLine("B::MethPubInstB()"); + return 100; +} + +public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance method access + if(MethPubInst() != 100) + mi_RetCode = 0; + + if(MethPubInstB() != 100) + mi_RetCode = 0; + + return mi_RetCode; +} +} + + + + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-10-3.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-10-3.csproj new file mode 100644 index 0000000000..cd1a71b838 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-10-3.csproj @@ -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>L-1-10-3</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-10-3.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <ProjectReference Include="L-1-10-3D.csproj" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-10-3D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-10-3D.cs new file mode 100644 index 0000000000..62199596fb --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-10-3D.cs @@ -0,0 +1,12 @@ +// 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. + +public interface A{ +int MethPubInst(); +} + +public interface B : A{ +int MethPubInstB(); +} + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-10-3D.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-10-3D.csproj new file mode 100644 index 0000000000..e6f591b708 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-10-3D.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-10-3D</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-10-3D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-11-1.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-11-1.cs new file mode 100644 index 0000000000..11b8e03718 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-11-1.cs @@ -0,0 +1,416 @@ +// 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. + +////////////////////////////////////////////////////////// +// L-1-11-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes two unrelated classes in +// the same assembly and module +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +using System; + +class Test{ +public static int Main(){ + int mi_RetCode = 100; + A a = new A(); + B b = new B(); + + if(a.Test(b) != 100) + mi_RetCode = 0; + + if(b.Test(a) != 100) + mi_RetCode = 0; + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; +} +} + +class A{ +public int Test(B b){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance field access + b.FldPubInst = 100; + if(b.FldPubInst != 100) + mi_RetCode = 0; + + //@csharp - Note that C# will not compile an illegal access of b.FldPrivInst + //So there is no negative test here, it should be covered elsewhere and + //should throw a FielAccessException within the runtime. (IL sources is + //the most logical, only?, choice) + + //@csharp - C# Won't compile illegal family access from non-family members + + b.FldAsmInst = 100; + if(b.FldAsmInst != 100) + mi_RetCode = 0; + + b.FldFoaInst = 100; + if(b.FldFoaInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + B.FldPubStat = 100; + if(B.FldPubStat != 100) + mi_RetCode = 0; + + //@csharp - Again, note C# won't do private field access + + //@csharp - C# Won't compile illegal family access from non-family members + + B.FldAsmStat = 100; + if(B.FldAsmStat != 100) + mi_RetCode = 0; + + B.FldFoaStat = 100; + if(B.FldFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance b.Method access + if(b.MethPubInst() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private b.Method access + + //@csharp - C# Won't compile illegal family access from non-family members + + if(b.MethAsmInst() != 100) + mi_RetCode = 0; + + if(b.MethFoaInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static b.Method access + if(B.MethPubStat() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private b.Method access + + //@csharp - C# Won't compile illegal family access from non-family members + + if(B.MethAsmStat() != 100) + mi_RetCode = 0; + + if(B.MethFoaStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test virtual b.Method access + if(b.MethPubVirt() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private b.Method access + + //@csharp - C# Won't compile illegal family access from non-family members + + if(b.MethAsmVirt() != 100) + mi_RetCode = 0; + + if(b.MethFoaVirt() != 100) + mi_RetCode = 0; + + return mi_RetCode; +} + + ////////////////////////////// + // Instance Fields +public int FldPubInst; +private int FldPrivInst; +protected int FldFamInst; //Translates to "family" +internal int FldAsmInst; //Translates to "assembly" +protected internal int FldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields +public static int FldPubStat; +private static int FldPrivStat; +protected static int FldFamStat; //family +internal static int FldAsmStat; //assembly +protected internal static int FldFoaStat; //famorassem + + ////////////////////////////// + // Instance Methods +public int MethPubInst(){ + Console.WriteLine("A::MethPubInst()"); + return 100; +} + +private int MethPrivInst(){ + Console.WriteLine("A::MethPrivInst()"); + return 100; +} + +protected int MethFamInst(){ + Console.WriteLine("A::MethFamInst()"); + return 100; +} + +internal int MethAsmInst(){ + Console.WriteLine("A::MethAsmInst()"); + return 100; +} + +protected internal int MethFoaInst(){ + Console.WriteLine("A::MethFoaInst()"); + return 100; +} + + ////////////////////////////// + // Static Methods +public static int MethPubStat(){ + Console.WriteLine("A::MethPubStat()"); + return 100; +} + +private static int MethPrivStat(){ + Console.WriteLine("A::MethPrivStat()"); + return 100; +} + +protected static int MethFamStat(){ + Console.WriteLine("A::MethFamStat()"); + return 100; +} + +internal static int MethAsmStat(){ + Console.WriteLine("A::MethAsmStat()"); + return 100; +} + +protected internal static int MethFoaStat(){ + Console.WriteLine("A::MethFoaStat()"); + return 100; +} + + ////////////////////////////// + // Virtual Instance Methods +public virtual int MethPubVirt(){ + Console.WriteLine("A::MethPubVirt()"); + return 100; +} + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing MethPrivVirt() here. + +protected virtual int MethFamVirt(){ + Console.WriteLine("A::MethFamVirt()"); + return 100; +} + +internal virtual int MethAsmVirt(){ + Console.WriteLine("A::MethAsmVirt()"); + return 100; +} + +protected internal virtual int MethFoaVirt(){ + Console.WriteLine("A::MethFoaVirt()"); + return 100; +} +} + +class B{ +public int Test(A a){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance field access + a.FldPubInst = 100; + if(a.FldPubInst != 100) + mi_RetCode = 0; + + //@csharp - Note that C# will not compile an illegal access of a.FldPrivInst + //So there is no negative test here, it should be covered elsewhere and + //should throw a FielAccessException within the runtime. (IL sources is + //the most logical, only?, choice) + + //@csharp - C# Won't compile illegal family access from non-family members + + a.FldAsmInst = 100; + if(a.FldAsmInst != 100) + mi_RetCode = 0; + + a.FldFoaInst = 100; + if(a.FldFoaInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + A.FldPubStat = 100; + if(A.FldPubStat != 100) + mi_RetCode = 0; + + //@csharp - Again, note C# won't do private field access + + //@csharp - C# Won't compile illegal family access from non-family members + + A.FldAsmStat = 100; + if(A.FldAsmStat != 100) + mi_RetCode = 0; + + A.FldFoaStat = 100; + if(A.FldFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance a.Method access + if(a.MethPubInst() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private a.Method access + + //@csharp - C# Won't compile illegal family access from non-family members + + if(a.MethAsmInst() != 100) + mi_RetCode = 0; + + if(a.MethFoaInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static a.Method access + if(A.MethPubStat() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private a.Method access + + //@csharp - C# Won't compile illegal family access from non-family members + + if(A.MethAsmStat() != 100) + mi_RetCode = 0; + + if(A.MethFoaStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test virtual a.Method access + if(a.MethPubVirt() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private a.Method access + + //@csharp - C# Won't compile illegal family access from non-family members + + if(a.MethAsmVirt() != 100) + mi_RetCode = 0; + + if(a.MethFoaVirt() != 100) + mi_RetCode = 0; + + return mi_RetCode; +} + + + ////////////////////////////// + // Instance Fields +public int FldPubInst; +private int FldPrivInst; +protected int FldFamInst; //Translates to "family" +internal int FldAsmInst; //Translates to "assembly" +protected internal int FldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields +public static int FldPubStat; +private static int FldPrivStat; +protected static int FldFamStat; //family +internal static int FldAsmStat; //assembly +protected internal static int FldFoaStat; //famorassem + + ////////////////////////////// + // Instance Methods +public int MethPubInst(){ + Console.WriteLine("B::MethPubInst()"); + return 100; +} + +private int MethPrivInst(){ + Console.WriteLine("B::MethPrivInst()"); + return 100; +} + +protected int MethFamInst(){ + Console.WriteLine("B::MethFamInst()"); + return 100; +} + +internal int MethAsmInst(){ + Console.WriteLine("B::MethAsmInst()"); + return 100; +} + +protected internal int MethFoaInst(){ + Console.WriteLine("B::MethFoaInst()"); + return 100; +} + + ////////////////////////////// + // Static Methods +public static int MethPubStat(){ + Console.WriteLine("B::MethPubStat()"); + return 100; +} + +private static int MethPrivStat(){ + Console.WriteLine("B::MethPrivStat()"); + return 100; +} + +protected static int MethFamStat(){ + Console.WriteLine("B::MethFamStat()"); + return 100; +} + +internal static int MethAsmStat(){ + Console.WriteLine("B::MethAsmStat()"); + return 100; +} + +protected internal static int MethFoaStat(){ + Console.WriteLine("B::MethFoaStat()"); + return 100; +} + + ////////////////////////////// + // Virtual Instance Methods +public virtual int MethPubVirt(){ + Console.WriteLine("B::MethPubVirt()"); + return 100; +} + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing MethPrivVirt() here. + +protected virtual int MethFamVirt(){ + Console.WriteLine("B::MethFamVirt()"); + return 100; +} + +internal virtual int MethAsmVirt(){ + Console.WriteLine("B::MethAsmVirt()"); + return 100; +} + +protected internal virtual int MethFoaVirt(){ + Console.WriteLine("B::MethFoaVirt()"); + return 100; +} + +} + + + + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-11-1.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-11-1.csproj new file mode 100644 index 0000000000..c36c9b2584 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-11-1.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-11-1</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-11-1.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-11-2.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-11-2.csproj new file mode 100644 index 0000000000..5eafcb188c --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-11-2.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-11-2</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-11-2D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-11-2D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-11-2D.cs new file mode 100644 index 0000000000..aa6173903f --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-11-2D.cs @@ -0,0 +1,192 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +public class A{ +/*public int Test(B b){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance field access + b.FldPubInst = 100; + if(b.FldPubInst != 100) + mi_RetCode = 0; + + //@csharp - Note that C# will not compile an illegal access of b.FldPrivInst + //So there is no negative test here, it should be covered elsewhere and + //should throw a FielAccessException within the runtime. (IL sources is + //the most logical, only?, choice) + + //@csharp - C# Won't compile illegial family access from non-family members + + b.FldAsmInst = 100; + if(b.FldAsmInst != 100) + mi_RetCode = 0; + + b.FldFoaInst = 100; + if(b.FldFoaInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + B.FldPubStat = 100; + if(B.FldPubStat != 100) + mi_RetCode = 0; + + //@csharp - Again, note C# won't do private field access + + //@csharp - C# Won't compile illegial family access from non-family members + + B.FldAsmStat = 100; + if(B.FldAsmStat != 100) + mi_RetCode = 0; + + B.FldFoaStat = 100; + if(B.FldFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance b.Method access + if(b.MethPubInst() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private b.Method access + + //@csharp - C# Won't compile illegial family access from non-family members + + if(b.MethAsmInst() != 100) + mi_RetCode = 0; + + if(b.MethFoaInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static b.Method access + if(B.MethPubStat() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private b.Method access + + //@csharp - C# Won't compile illegial family access from non-family members + + if(B.MethAsmStat() != 100) + mi_RetCode = 0; + + if(B.MethFoaStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test virtual b.Method access + if(b.MethPubVirt() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private b.Method access + + //@csharp - C# Won't compile illegial family access from non-family members + + if(b.MethAsmVirt() != 100) + mi_RetCode = 0; + + if(b.MethFoaVirt() != 100) + mi_RetCode = 0; + + return mi_RetCode; +} +*/ + ////////////////////////////// + // Instance Fields +public int FldPubInst; +private int FldPrivInst; +protected int FldFamInst; //Translates to "family" +internal int FldAsmInst; //Translates to "assembly" +protected internal int FldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields +public static int FldPubStat; +private static int FldPrivStat; +protected static int FldFamStat; //family +internal static int FldAsmStat; //assembly +protected internal static int FldFoaStat; //famorassem + + ////////////////////////////// + // Instance Methods +public int MethPubInst(){ + Console.WriteLine("A::MethPubInst()"); + return 100; +} + +private int MethPrivInst(){ + Console.WriteLine("A::MethPrivInst()"); + return 100; +} + +protected int MethFamInst(){ + Console.WriteLine("A::MethFamInst()"); + return 100; +} + +internal int MethAsmInst(){ + Console.WriteLine("A::MethAsmInst()"); + return 100; +} + +protected internal int MethFoaInst(){ + Console.WriteLine("A::MethFoaInst()"); + return 100; +} + + ////////////////////////////// + // Static Methods +public static int MethPubStat(){ + Console.WriteLine("A::MethPubStat()"); + return 100; +} + +private static int MethPrivStat(){ + Console.WriteLine("A::MethPrivStat()"); + return 100; +} + +protected static int MethFamStat(){ + Console.WriteLine("A::MethFamStat()"); + return 100; +} + +internal static int MethAsmStat(){ + Console.WriteLine("A::MethAsmStat()"); + return 100; +} + +protected internal static int MethFoaStat(){ + Console.WriteLine("A::MethFoaStat()"); + return 100; +} + + ////////////////////////////// + // Virtual Instance Methods +public virtual int MethPubVirt(){ + Console.WriteLine("A::MethPubVirt()"); + return 100; +} + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing MethPrivVirt() here. + +protected virtual int MethFamVirt(){ + Console.WriteLine("A::MethFamVirt()"); + return 100; +} + +internal virtual int MethAsmVirt(){ + Console.WriteLine("A::MethAsmVirt()"); + return 100; +} + +protected internal virtual int MethFoaVirt(){ + Console.WriteLine("A::MethFoaVirt()"); + return 100; +} +} diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-11-3.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-11-3.cs new file mode 100644 index 0000000000..18dae69ff5 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-11-3.cs @@ -0,0 +1,196 @@ +// 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. + +////////////////////////////////////////////////////////// +// L-1-11-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes two unrelated classes in +// the same assembly and module +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +using System; + +class Test{ +public static int Main(){ + int mi_RetCode = 100; + A a = new A(); + B b = new B(); + +// if(a.Test(b) != 100) +// mi_RetCode = 0; + + if(b.Test(a) != 100) + mi_RetCode = 0; + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; +} +} + + +class B{ +public int Test(A a){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance field access + a.FldPubInst = 100; + if(a.FldPubInst != 100) + mi_RetCode = 0; + + //@csharp - Note that C# will not compile an illegal access of a.FldPrivInst + //So there is no negative test here, it should be covered elsewhere and + //should throw a FielAccessException within the runtime. (IL sources is + //the most logical, only?, choice) + + //@csharp - C# Won't compile illegial family access from non-family members + + ///////////////////////////////// + // Test static field access + A.FldPubStat = 100; + if(A.FldPubStat != 100) + mi_RetCode = 0; + + //@csharp - Again, note C# won't do private field access + + //@csharp - C# Won't compile illegial family access from non-family members + + ///////////////////////////////// + // Test instance a.Method access + if(a.MethPubInst() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private a.Method access + + //@csharp - C# Won't compile illegial family access from non-family members + + ///////////////////////////////// + // Test static a.Method access + if(A.MethPubStat() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private a.Method access + + //@csharp - C# Won't compile illegial family access from non-family members + + ///////////////////////////////// + // Test virtual a.Method access + if(a.MethPubVirt() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private a.Method access + + //@csharp - C# Won't compile illegial family access from non-family members + + return mi_RetCode; +} + + + ////////////////////////////// + // Instance Fields +public int FldPubInst; +private int FldPrivInst; +protected int FldFamInst; //Translates to "family" +internal int FldAsmInst; //Translates to "assembly" +protected internal int FldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields +public static int FldPubStat; +private static int FldPrivStat; +protected static int FldFamStat; //family +internal static int FldAsmStat; //assembly +protected internal static int FldFoaStat; //famorassem + + ////////////////////////////// + // Instance Methods +public int MethPubInst(){ + Console.WriteLine("B::MethPubInst()"); + return 100; +} + +private int MethPrivInst(){ + Console.WriteLine("B::MethPrivInst()"); + return 100; +} + +protected int MethFamInst(){ + Console.WriteLine("B::MethFamInst()"); + return 100; +} + +internal int MethAsmInst(){ + Console.WriteLine("B::MethAsmInst()"); + return 100; +} + +protected internal int MethFoaInst(){ + Console.WriteLine("B::MethFoaInst()"); + return 100; +} + + ////////////////////////////// + // Static Methods +public static int MethPubStat(){ + Console.WriteLine("B::MethPubStat()"); + return 100; +} + +private static int MethPrivStat(){ + Console.WriteLine("B::MethPrivStat()"); + return 100; +} + +protected static int MethFamStat(){ + Console.WriteLine("B::MethFamStat()"); + return 100; +} + +internal static int MethAsmStat(){ + Console.WriteLine("B::MethAsmStat()"); + return 100; +} + +protected internal static int MethFoaStat(){ + Console.WriteLine("B::MethFoaStat()"); + return 100; +} + + ////////////////////////////// + // Virtual Instance Methods +public virtual int MethPubVirt(){ + Console.WriteLine("B::MethPubVirt()"); + return 100; +} + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing MethPrivVirt() here. + +protected virtual int MethFamVirt(){ + Console.WriteLine("B::MethFamVirt()"); + return 100; +} + +internal virtual int MethAsmVirt(){ + Console.WriteLine("B::MethAsmVirt()"); + return 100; +} + +protected internal virtual int MethFoaVirt(){ + Console.WriteLine("B::MethFoaVirt()"); + return 100; +} + +} + + + + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-11-3.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-11-3.csproj new file mode 100644 index 0000000000..0c287006a7 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-11-3.csproj @@ -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>L-1-11-3</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-11-3.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <ProjectReference Include="L-1-11-3D.csproj" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-11-3D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-11-3D.cs new file mode 100644 index 0000000000..61eed04990 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-11-3D.cs @@ -0,0 +1,193 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +public class A{ +/* +public int Test(B b){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance field access + b.FldPubInst = 100; + if(b.FldPubInst != 100) + mi_RetCode = 0; + + //@csharp - Note that C# will not compile an illegal access of b.FldPrivInst + //So there is no negative test here, it should be covered elsewhere and + //should throw a FielAccessException within the runtime. (IL sources is + //the most logical, only?, choice) + + //@csharp - C# Won't compile illegial family access from non-family members + + b.FldAsmInst = 100; + if(b.FldAsmInst != 100) + mi_RetCode = 0; + + b.FldFoaInst = 100; + if(b.FldFoaInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + B.FldPubStat = 100; + if(B.FldPubStat != 100) + mi_RetCode = 0; + + //@csharp - Again, note C# won't do private field access + + //@csharp - C# Won't compile illegial family access from non-family members + + B.FldAsmStat = 100; + if(B.FldAsmStat != 100) + mi_RetCode = 0; + + B.FldFoaStat = 100; + if(B.FldFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance b.Method access + if(b.MethPubInst() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private b.Method access + + //@csharp - C# Won't compile illegial family access from non-family members + + if(b.MethAsmInst() != 100) + mi_RetCode = 0; + + if(b.MethFoaInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static b.Method access + if(B.MethPubStat() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private b.Method access + + //@csharp - C# Won't compile illegial family access from non-family members + + if(B.MethAsmStat() != 100) + mi_RetCode = 0; + + if(B.MethFoaStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test virtual b.Method access + if(b.MethPubVirt() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private b.Method access + + //@csharp - C# Won't compile illegial family access from non-family members + + if(b.MethAsmVirt() != 100) + mi_RetCode = 0; + + if(b.MethFoaVirt() != 100) + mi_RetCode = 0; + + return mi_RetCode; +} +*/ + ////////////////////////////// + // Instance Fields +public int FldPubInst; +private int FldPrivInst; +protected int FldFamInst; //Translates to "family" +internal int FldAsmInst; //Translates to "assembly" +protected internal int FldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields +public static int FldPubStat; +private static int FldPrivStat; +protected static int FldFamStat; //family +internal static int FldAsmStat; //assembly +protected internal static int FldFoaStat; //famorassem + + ////////////////////////////// + // Instance Methods +public int MethPubInst(){ + Console.WriteLine("A::MethPubInst()"); + return 100; +} + +private int MethPrivInst(){ + Console.WriteLine("A::MethPrivInst()"); + return 100; +} + +protected int MethFamInst(){ + Console.WriteLine("A::MethFamInst()"); + return 100; +} + +internal int MethAsmInst(){ + Console.WriteLine("A::MethAsmInst()"); + return 100; +} + +protected internal int MethFoaInst(){ + Console.WriteLine("A::MethFoaInst()"); + return 100; +} + + ////////////////////////////// + // Static Methods +public static int MethPubStat(){ + Console.WriteLine("A::MethPubStat()"); + return 100; +} + +private static int MethPrivStat(){ + Console.WriteLine("A::MethPrivStat()"); + return 100; +} + +protected static int MethFamStat(){ + Console.WriteLine("A::MethFamStat()"); + return 100; +} + +internal static int MethAsmStat(){ + Console.WriteLine("A::MethAsmStat()"); + return 100; +} + +protected internal static int MethFoaStat(){ + Console.WriteLine("A::MethFoaStat()"); + return 100; +} + + ////////////////////////////// + // Virtual Instance Methods +public virtual int MethPubVirt(){ + Console.WriteLine("A::MethPubVirt()"); + return 100; +} + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing MethPrivVirt() here. + +protected virtual int MethFamVirt(){ + Console.WriteLine("A::MethFamVirt()"); + return 100; +} + +internal virtual int MethAsmVirt(){ + Console.WriteLine("A::MethAsmVirt()"); + return 100; +} + +protected internal virtual int MethFoaVirt(){ + Console.WriteLine("A::MethFoaVirt()"); + return 100; +} +} diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-11-3D.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-11-3D.csproj new file mode 100644 index 0000000000..15e918aefa --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-11-3D.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-11-3D</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-11-3D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-12-1.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-12-1.cs new file mode 100644 index 0000000000..f8287fef7b --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-12-1.cs @@ -0,0 +1,74 @@ +// 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. + +////////////////////////////////////////////////////////// +// L-1-9-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 1-deep implementation in +// the same assembly and module +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +//@csharp C# doesn't allow much flexibility here in terms of negative testing on interfaces... +//THIS NEEDS MORE COVERAGE + +using System; + +class Test{ +public static int Main(){ + int mi_RetCode; + C c = new C(); + mi_RetCode = c.Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; +} +} + +interface A{ + + ////////////////////////////// + // Instance Methods +int MethPubInst(); +} + +interface B{ +int MethPubInst2(); +} + +class C : A, B{ +public int MethPubInst(){ + Console.WriteLine("B::MethPubInst()"); + return 100; +} + +public int MethPubInst2(){ + Console.WriteLine("C::MethPubInst2()"); + return 100; +} + +public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance method access + if(MethPubInst() != 100) + mi_RetCode = 0; + + if(MethPubInst2() != 100) + mi_RetCode = 0; + + return mi_RetCode; +} +} + + + + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-12-1.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-12-1.csproj new file mode 100644 index 0000000000..ad47d52707 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-12-1.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-12-1</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-12-1.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-12-2.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-12-2.csproj new file mode 100644 index 0000000000..db7d25399f --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-12-2.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-12-2</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-12-2D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-12-2D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-12-2D.cs new file mode 100644 index 0000000000..44bf3b55c2 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-12-2D.cs @@ -0,0 +1,14 @@ +// 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. + +interface A{ + + ////////////////////////////// + // Instance Methods +int MethPubInst(); +} + +interface B{ +int MethPubInst2(); +} diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-12-3.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-12-3.cs new file mode 100644 index 0000000000..d8e99f91fd --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-12-3.cs @@ -0,0 +1,63 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +////////////////////////////////////////////////////////// +// L-1-9-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 1-deep implementation in +// the same assembly and module +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +//@csharp C# doesn't allow much flexibility here in terms of negative testing on interfaces... +//THIS NEEDS MORE COVERAGE + +using System; + +class Test{ +public static int Main(){ + int mi_RetCode; + C c = new C(); + mi_RetCode = c.Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; +} +} + +class C : A, B{ +public int MethPubInst(){ + Console.WriteLine("B::MethPubInst()"); + return 100; +} + +public int MethPubInst2(){ + Console.WriteLine("C::MethPubInst2()"); + return 100; +} + +public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance method access + if(MethPubInst() != 100) + mi_RetCode = 0; + + if(MethPubInst2() != 100) + mi_RetCode = 0; + + return mi_RetCode; +} +} + + + + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-12-3.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-12-3.csproj new file mode 100644 index 0000000000..c17b6cd2cc --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-12-3.csproj @@ -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>L-1-12-3</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-12-3.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <ProjectReference Include="L-1-12-3D.csproj" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-12-3D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-12-3D.cs new file mode 100644 index 0000000000..9ee05ce65a --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-12-3D.cs @@ -0,0 +1,14 @@ +// 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. + +public interface A{ + + ////////////////////////////// + // Instance Methods +int MethPubInst(); +} + +public interface B{ +int MethPubInst2(); +} diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-12-3D.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-12-3D.csproj new file mode 100644 index 0000000000..e0cfc1725b --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-12-3D.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-12-3D</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-12-3D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-2-1.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-2-1.cs new file mode 100644 index 0000000000..26cb54e8f7 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-2-1.cs @@ -0,0 +1,238 @@ +// 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. + +////////////////////////////////////////////////////////// +// L-1-2-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 2-deep inheritance in +// the same assembly and module +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +using System; + +class Test{ +public static int Main(){ + int mi_RetCode; + C c = new C(); + mi_RetCode = c.Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; +} +} + +class A{ + + ////////////////////////////// + // Instance Fields +public int FldPubInst; +private int FldPrivInst; +protected int FldFamInst; //Translates to "family" +internal int FldAsmInst; //Translates to "assembly" +protected internal int FldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields +public static int FldPubStat; +private static int FldPrivStat; +protected static int FldFamStat; //family +internal static int FldAsmStat; //assembly +protected internal int FldFoaStat; //famorassem + + ////////////////////////////// + // Instance Methods +public int MethPubInst(){ + Console.WriteLine("A::MethPubInst()"); + return 100; +} + +private int MethPrivInst(){ + Console.WriteLine("A::MethPrivInst()"); + return 100; +} + +protected int MethFamInst(){ + Console.WriteLine("A::MethFamInst()"); + return 100; +} + +internal int MethAsmInst(){ + Console.WriteLine("A::MethAsmInst()"); + return 100; +} + +protected internal int MethFoaInst(){ + Console.WriteLine("A::MethFoaInst()"); + return 100; +} + + ////////////////////////////// + // Static Methods +public static int MethPubStat(){ + Console.WriteLine("A::MethPubStat()"); + return 100; +} + +private static int MethPrivStat(){ + Console.WriteLine("A::MethPrivStat()"); + return 100; +} + +protected static int MethFamStat(){ + Console.WriteLine("A::MethFamStat()"); + return 100; +} + +internal static int MethAsmStat(){ + Console.WriteLine("A::MethAsmStat()"); + return 100; +} + +protected internal static int MethFoaStat(){ + Console.WriteLine("A::MethFoaStat()"); + return 100; +} + + ////////////////////////////// + // Virtual Instance Methods +public virtual int MethPubVirt(){ + Console.WriteLine("A::MethPubVirt()"); + return 100; +} + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing MethPrivVirt() here. + +protected virtual int MethFamVirt(){ + Console.WriteLine("A::MethFamVirt()"); + return 100; +} + +internal virtual int MethAsmVirt(){ + Console.WriteLine("A::MethAsmVirt()"); + return 100; +} + +protected internal virtual int MethFoaVirt(){ + Console.WriteLine("A::MethFoaVirt()"); + return 100; +} +} + +class B : A{ + //@todo - Class B is currently a simple placeholder to force N-Deep inheritance... + //However, a non-trivial class B that might hide some members of A as a visiblity + //test is a test that we need to think about and develop. That is not currently the + //focus of this test (maybe in the near future), but for now we're happy forcing + //a N-Deep inheritance. Such instances have, in the past, proven worthy of + //investigation. + +public int placeholder; +} + +class C : B{ +public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance field access + FldPubInst = 100; + if(FldPubInst != 100) + mi_RetCode = 0; + + //@csharp - Note that C# will not compile an illegal access of FldPrivInst + //So there is no negative test here, it should be covered elsewhere and + //should throw a FielAccessException within the runtime. (IL sources is + //the most logical, only?, choice) + + FldFamInst = 100; + if(FldFamInst != 100) + mi_RetCode = 0; + + FldAsmInst = 100; + if(FldAsmInst != 100) + mi_RetCode = 0; + + FldFoaInst = 100; + if(FldFoaInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + FldPubStat = 100; + if(FldPubStat != 100) + mi_RetCode = 0; + + //@csharp - Again, note C# won't do private field access + + FldFamStat = 100; + if(FldFamStat != 100) + mi_RetCode = 0; + + FldAsmStat = 100; + if(FldAsmStat != 100) + mi_RetCode = 0; + + FldFoaStat = 100; + if(FldFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance method access + if(MethPubInst() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private method access + + if(MethFamInst() != 100) + mi_RetCode = 0; + + if(MethAsmInst() != 100) + mi_RetCode = 0; + + if(MethFoaInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethPubStat() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private method access + + if(MethFamStat() != 100) + mi_RetCode = 0; + + if(MethAsmStat() != 100) + mi_RetCode = 0; + + if(MethFoaStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test virtual method access + if(MethPubVirt() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private method access + + if(MethFamVirt() != 100) + mi_RetCode = 0; + + if(MethAsmVirt() != 100) + mi_RetCode = 0; + + if(MethFoaVirt() != 100) + mi_RetCode = 0; + + return mi_RetCode; +} +} diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-2-1.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-2-1.csproj new file mode 100644 index 0000000000..9da2437b7e --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-2-1.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-2-1</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-2-1.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-2-2.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-2-2.csproj new file mode 100644 index 0000000000..f2a4e47927 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-2-2.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-2-2</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-2-2D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-2-2D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-2-2D.cs new file mode 100644 index 0000000000..dcd90508b9 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-2-2D.cs @@ -0,0 +1,114 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +class A{ + + ////////////////////////////// + // Instance Fields +public int FldPubInst; +private int FldPrivInst; +protected int FldFamInst; //Translates to "family" +internal int FldAsmInst; //Translates to "assembly" +protected internal int FldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields +public static int FldPubStat; +private static int FldPrivStat; +protected static int FldFamStat; //family +internal static int FldAsmStat; //assembly +protected internal int FldFoaStat; //famorassem + + ////////////////////////////// + // Instance Methods +public int MethPubInst(){ + Console.WriteLine("A::MethPubInst()"); + return 100; +} + +private int MethPrivInst(){ + Console.WriteLine("A::MethPrivInst()"); + return 100; +} + +protected int MethFamInst(){ + Console.WriteLine("A::MethFamInst()"); + return 100; +} + +internal int MethAsmInst(){ + Console.WriteLine("A::MethAsmInst()"); + return 100; +} + +protected internal int MethFoaInst(){ + Console.WriteLine("A::MethFoaInst()"); + return 100; +} + + ////////////////////////////// + // Static Methods +public static int MethPubStat(){ + Console.WriteLine("A::MethPubStat()"); + return 100; +} + +private static int MethPrivStat(){ + Console.WriteLine("A::MethPrivStat()"); + return 100; +} + +protected static int MethFamStat(){ + Console.WriteLine("A::MethFamStat()"); + return 100; +} + +internal static int MethAsmStat(){ + Console.WriteLine("A::MethAsmStat()"); + return 100; +} + +protected internal static int MethFoaStat(){ + Console.WriteLine("A::MethFoaStat()"); + return 100; +} + + ////////////////////////////// + // Virtual Instance Methods +public virtual int MethPubVirt(){ + Console.WriteLine("A::MethPubVirt()"); + return 100; +} + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing MethPrivVirt() here. + +protected virtual int MethFamVirt(){ + Console.WriteLine("A::MethFamVirt()"); + return 100; +} + +internal virtual int MethAsmVirt(){ + Console.WriteLine("A::MethAsmVirt()"); + return 100; +} + +protected internal virtual int MethFoaVirt(){ + Console.WriteLine("A::MethFoaVirt()"); + return 100; +} +} + +class B : A{ + //@todo - Class B is currently a simple placeholder to force N-Deep inheritance... + //However, a non-trivial class B that might hide some members of A as a visiblity + //test is a test that we need to think about and develop. That is not currently the + //focus of this test (maybe in the near future), but for now we're happy forcing + //a N-Deep inheritance. Such instances have, in the past, proven worthy of + //investigation. + +public int placeholder; +} diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-2-3.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-2-3.cs new file mode 100644 index 0000000000..5ee293a031 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-2-3.cs @@ -0,0 +1,129 @@ +// 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. + +////////////////////////////////////////////////////////// +// L-1-2-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 2-deep inheritance in +// the separate assemblies and modules. +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +using System; + +class Test{ +public static int Main(){ + int mi_RetCode; + C c = new C(); + mi_RetCode = c.Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; +} +} + +class C : B{ +public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance field access + FldPubInst = 100; + if(FldPubInst != 100) + mi_RetCode = 0; + + //@csharp - Note that C# will not compile an illegal access of FldPrivInst + //So there is no negative test here, it should be covered elsewhere and + //should throw a FielAccessException within the runtime. (IL sources is + //the most logical, only?, choice) + + FldFamInst = 100; + if(FldFamInst != 100) + mi_RetCode = 0; + + /* FldAsmInst = 100; + if(FldAsmInst != 100) + mi_RetCode = 0; + */ + FldFoaInst = 100; + if(FldFoaInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + FldPubStat = 100; + if(FldPubStat != 100) + mi_RetCode = 0; + + //@csharp - Again, note C# won't do private field access + + FldFamStat = 100; + if(FldFamStat != 100) + mi_RetCode = 0; + + /* FldAsmStat = 100; + if(FldAsmStat != 100) + mi_RetCode = 0; + */ + FldFoaStat = 100; + if(FldFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance method access + if(MethPubInst() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private method access + + if(MethFamInst() != 100) + mi_RetCode = 0; + + /* if(MethAsmInst() != 100) + mi_RetCode = 0; + */ + if(MethFoaInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethPubStat() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private method access + + if(MethFamStat() != 100) + mi_RetCode = 0; + + /* if(MethAsmStat() != 100) + mi_RetCode = 0; + */ + if(MethFoaStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test virtual method access + if(MethPubVirt() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private method access + + if(MethFamVirt() != 100) + mi_RetCode = 0; + + /* if(MethAsmVirt() != 100) + mi_RetCode = 0; + */ + if(MethFoaVirt() != 100) + mi_RetCode = 0; + + return mi_RetCode; +} +} diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-2-3.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-2-3.csproj new file mode 100644 index 0000000000..f214900d9a --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-2-3.csproj @@ -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>L-1-2-3</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-2-3.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <ProjectReference Include="L-1-2-3D.csproj" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-2-3D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-2-3D.cs new file mode 100644 index 0000000000..5bb343d988 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-2-3D.cs @@ -0,0 +1,114 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +public class A{ + + ////////////////////////////// + // Instance Fields +public int FldPubInst; +private int FldPrivInst; +protected int FldFamInst; //Translates to "family" +internal int FldAsmInst; //Translates to "assembly" +protected internal int FldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields +public static int FldPubStat; +private static int FldPrivStat; +protected static int FldFamStat; //family +internal static int FldAsmStat; //assembly +protected internal int FldFoaStat; //famorassem + + ////////////////////////////// + // Instance Methods +public int MethPubInst(){ + Console.WriteLine("A::MethPubInst()"); + return 100; +} + +private int MethPrivInst(){ + Console.WriteLine("A::MethPrivInst()"); + return 100; +} + +protected int MethFamInst(){ + Console.WriteLine("A::MethFamInst()"); + return 100; +} + +internal int MethAsmInst(){ + Console.WriteLine("A::MethAsmInst()"); + return 100; +} + +protected internal int MethFoaInst(){ + Console.WriteLine("A::MethFoaInst()"); + return 100; +} + + ////////////////////////////// + // Static Methods +public static int MethPubStat(){ + Console.WriteLine("A::MethPubStat()"); + return 100; +} + +private static int MethPrivStat(){ + Console.WriteLine("A::MethPrivStat()"); + return 100; +} + +protected static int MethFamStat(){ + Console.WriteLine("A::MethFamStat()"); + return 100; +} + +internal static int MethAsmStat(){ + Console.WriteLine("A::MethAsmStat()"); + return 100; +} + +protected internal static int MethFoaStat(){ + Console.WriteLine("A::MethFoaStat()"); + return 100; +} + + ////////////////////////////// + // Virtual Instance Methods +public virtual int MethPubVirt(){ + Console.WriteLine("A::MethPubVirt()"); + return 100; +} + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing MethPrivVirt() here. + +protected virtual int MethFamVirt(){ + Console.WriteLine("A::MethFamVirt()"); + return 100; +} + +internal virtual int MethAsmVirt(){ + Console.WriteLine("A::MethAsmVirt()"); + return 100; +} + +protected internal virtual int MethFoaVirt(){ + Console.WriteLine("A::MethFoaVirt()"); + return 100; +} +} + +public class B : A{ + //@todo - Class B is currently a simple placeholder to force N-Deep inheritance... + //However, a non-trivial class B that might hide some members of A as a visiblity + //test is a test that we need to think about and develop. That is not currently the + //focus of this test (maybe in the near future), but for now we're happy forcing + //a N-Deep inheritance. Such instances have, in the past, proven worthy of + //investigation. + +public int placeholder; +} diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-2-3D.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-2-3D.csproj new file mode 100644 index 0000000000..61c02f806e --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-2-3D.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-2-3D</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-2-3D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-3-1.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-3-1.cs new file mode 100644 index 0000000000..ec73a1aa9c --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-3-1.cs @@ -0,0 +1,468 @@ +// 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. + +////////////////////////////////////////////////////////// +// L-1-3-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 1-deep nesting in +// the same assembly and module +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +using System; + + +class Test +{ + public static int Main() + { + int mi_RetCode; + A a = new A(); + mi_RetCode = a.Test(); + + if (mi_RetCode == 100) + { + Console.WriteLine("Pass"); + } + else + { + Console.WriteLine("FAIL"); + } + + return mi_RetCode; + } +} + +class A +{ + public int Test() + { + int mi_RetCode = 100; + + ///////////////////////////////// + // Test nested class access + if(Test_Nested(ClsPubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsPrivInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsFamInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsAsmInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsFoaInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsPubStat) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsPrivStat) != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + public int Test_Nested(Cls Nested_Cls) + { + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS NESTED FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + ///////////////////////////////// + // Test instance field access + Nested_Cls.NestFldPubInst = 100; + if(Nested_Cls.NestFldPubInst != 100) + mi_RetCode = 0; + + //@csharp - Note, CSharp won't allow access of family or private members of a nested class... + //from it's enclosing class. + + Nested_Cls.NestFldAsmInst = 100; + if(Nested_Cls.NestFldAsmInst != 100) + mi_RetCode = 0; + + Nested_Cls.NestFldFoaInst = 100; + if(Nested_Cls.NestFldFoaInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + Cls.NestFldPubStat = 100; + if(Cls.NestFldPubStat != 100) + mi_RetCode = 0; + + //@csharp - See last @csharp + + Cls.NestFldAsmStat = 100; + if(Cls.NestFldAsmStat != 100) + mi_RetCode = 0; + + Cls.NestFldFoaStat = 100; + if(Cls.NestFldFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance method access + if(Nested_Cls.NestMethPubInst() != 100) + mi_RetCode = 0; + + //@csharp - See last @csharp + + if(Nested_Cls.NestMethAsmInst() != 100) + mi_RetCode = 0; + + if(Nested_Cls.NestMethFoaInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(Cls.NestMethPubStat() != 100) + mi_RetCode = 0; + + //@csharp - See last @csharp + + if(Cls.NestMethAsmStat() != 100) + mi_RetCode = 0; + + if(Cls.NestMethFoaStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test virtual method access + if(Nested_Cls.NestMethPubVirt() != 100) + mi_RetCode = 0; + + //@csharp - See last @csharp + + if(Nested_Cls.NestMethAsmVirt() != 100) + mi_RetCode = 0; + + if(Nested_Cls.NestMethFoaVirt() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + if(Nested_Cls.Test() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + // TODO: CHECK IF THIS IS TESTED + ////////////////////////////// + // Instance Fields + // public int FldPubInst; + // private int FldPrivInst; + // protected int FldFamInst; //Translates to "family" + // internal int FldAsmInst; //Translates to "assembly" + ///protected internal int FldFoaInst; //Translates to "famorassem" + + + ////////////////////////////// + // Static Fields + public static int FldPubStat; + private static int FldPrivStat; + protected static int FldFamStat; //family + internal static int FldAsmStat; //assembly + protected internal static int FldFoaStat; //famorassem + + ////////////////////////////////////// + // Instance fields for nested classes + public Cls ClsPubInst = new Cls(); + private Cls ClsPrivInst = new Cls(); + protected Cls ClsFamInst = new Cls(); + internal Cls ClsAsmInst = new Cls(); + protected internal Cls ClsFoaInst = new Cls(); + + ///////////////////////////////////// + // Static fields of nested classes + public static Cls ClsPubStat = new Cls(); + private static Cls ClsPrivStat = new Cls(); + + ////////////////////////////// + // Instance Methods + public int MethPubInst() + { + Console.WriteLine("A::MethPubInst()"); + return 100; + } + + private int MethPrivInst() + { + Console.WriteLine("A::MethPrivInst()"); + return 100; + } + + protected int MethFamInst() + { + Console.WriteLine("A::MethFamInst()"); + return 100; + } + + internal int MethAsmInst() + { + Console.WriteLine("A::MethAsmInst()"); + return 100; + } + + protected internal int MethFoaInst() + { + Console.WriteLine("A::MethFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static Methods + public static int MethPubStat() + { + Console.WriteLine("A::MethPubStat()"); + return 100; + } + + private static int MethPrivStat() + { + Console.WriteLine("A::MethPrivStat()"); + return 100; + } + + protected static int MethFamStat() + { + Console.WriteLine("A::MethFamStat()"); + return 100; + } + + internal static int MethAsmStat() + { + Console.WriteLine("A::MethAsmStat()"); + return 100; + } + + protected internal static int MethFoaStat() + { + Console.WriteLine("A::MethFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance Methods + public virtual int MethPubVirt() + { + Console.WriteLine("A::MethPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing MethPrivVirt() here. + + protected virtual int MethFamVirt() + { + Console.WriteLine("A::MethFamVirt()"); + return 100; + } + + internal virtual int MethAsmVirt() + { + Console.WriteLine("A::MethAsmVirt()"); + return 100; + } + + protected internal virtual int MethFoaVirt() + { + Console.WriteLine("A::MethFoaVirt()"); + return 100; + } + + public class Cls + { + public int Test() + { + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS ENCLOSING FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + //@csharp - C# will not allow nested classes to access non-static members of their enclosing classes + + ///////////////////////////////// + // Test static field access + FldPubStat = 100; + if(FldPubStat != 100) + mi_RetCode = 0; + + FldPrivStat = 100; + if(FldPrivStat != 100) + mi_RetCode = 0; + + FldFamStat = 100; + if(FldFamStat != 100) + mi_RetCode = 0; + + FldAsmStat = 100; + if(FldAsmStat != 100) + mi_RetCode = 0; + + FldFoaStat = 100; + if(FldFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethPubStat() != 100) + mi_RetCode = 0; + + if(MethFamStat() != 100) + mi_RetCode = 0; + + if(MethAsmStat() != 100) + mi_RetCode = 0; + + if(MethFoaStat() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + //@todo - Look at testing accessing one nested class from another, @bugug - NEED TO ADD SUCH TESTING, access the public nested class fields from here, etc... + + return mi_RetCode; + } + + ////////////////////////////// + // Instance Fields + public int NestFldPubInst; + + // TODO: Check if this is covered in IL + // private int NestFldPrivInst; + + // TODO: Check if this is covered in IL + // protected int NestFldFamInst; //Translates to "family" + internal int NestFldAsmInst; //Translates to "assembly" + protected internal int NestFldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int NestFldPubStat; + + // TODO: Check if this is covered in IL + // private static int NestFldPrivStat; + // TODO: Check if this is covered in IL + // protected static int NestFldFamStat; //family + + internal static int NestFldAsmStat; //assembly + protected internal static int NestFldFoaStat; //famorassem + + ////////////////////////////// + // Instance NestMethods + public int NestMethPubInst() + { + Console.WriteLine("A::NestMethPubInst()"); + return 100; + } + + private int NestMethPrivInst() + { + Console.WriteLine("A::NestMethPrivInst()"); + return 100; + } + + protected int NestMethFamInst() + { + Console.WriteLine("A::NestMethFamInst()"); + return 100; + } + + internal int NestMethAsmInst() + { + Console.WriteLine("A::NestMethAsmInst()"); + return 100; + } + + protected internal int NestMethFoaInst() + { + Console.WriteLine("A::NestMethFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethods + public static int NestMethPubStat() + { + Console.WriteLine("A::NestMethPubStat()"); + return 100; + } + + private static int NestMethPrivStat() + { + Console.WriteLine("A::NestMethPrivStat()"); + return 100; + } + + protected static int NestMethFamStat() + { + Console.WriteLine("A::NestMethFamStat()"); + return 100; + } + + internal static int NestMethAsmStat() + { + Console.WriteLine("A::NestMethAsmStat()"); + return 100; + } + + protected internal static int NestMethFoaStat() + { + Console.WriteLine("A::NestMethFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance NestMethods + public virtual int NestMethPubVirt() + { + Console.WriteLine("A::NestMethPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing NestMethPrivVirt() here. + + protected virtual int NestMethFamVirt() + { + Console.WriteLine("A::NestMethFamVirt()"); + return 100; + } + + internal virtual int NestMethAsmVirt() + { + Console.WriteLine("A::NestMethAsmVirt()"); + return 100; + } + + protected internal virtual int NestMethFoaVirt() + { + Console.WriteLine("A::NestMethFoaVirt()"); + return 100; + } + + } +} + + + + + + + + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-3-1.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-3-1.csproj new file mode 100644 index 0000000000..6b6c1bd921 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-3-1.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-3-1</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-3-1.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-4-1.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-4-1.cs new file mode 100644 index 0000000000..09c2ebed16 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-4-1.cs @@ -0,0 +1,844 @@ +// 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. + +////////////////////////////////////////////////////////// +// L-1-4-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 2-deep nesting in +// the same assembly and module +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +using System; + +class Test +{ + public static int Main() + { + int mi_RetCode; + A a = new A(); + mi_RetCode = a.Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; + } +} + +class A +{ + public int Test() + { + int mi_RetCode = 100; + + ///////////////////////////////// + // Test nested class access + if(Test_Nested(ClsPubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsPrivInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsFamInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsAsmInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsFoaInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsPubStat) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsPrivStat) != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + public int Test_Nested(Cls Nested_Cls) + { + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS NESTED FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + ///////////////////////////////// + // Test instance field access + Nested_Cls.NestFldPubInst = 100; + if(Nested_Cls.NestFldPubInst != 100) + mi_RetCode = 0; + + //@csharp - Note, CSharp won't allow access of family or private members of a nested class... + //from it's enclosing class. + + Nested_Cls.NestFldAsmInst = 100; + if(Nested_Cls.NestFldAsmInst != 100) + mi_RetCode = 0; + + Nested_Cls.NestFldFoaInst = 100; + if(Nested_Cls.NestFldFoaInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + Cls.NestFldPubStat = 100; + if(Cls.NestFldPubStat != 100) + mi_RetCode = 0; + + //@csharp - See last @csharp + + Cls.NestFldAsmStat = 100; + if(Cls.NestFldAsmStat != 100) + mi_RetCode = 0; + + Cls.NestFldFoaStat = 100; + if(Cls.NestFldFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance method access + if(Nested_Cls.NestMethPubInst() != 100) + mi_RetCode = 0; + + //@csharp - See last @csharp + + if(Nested_Cls.NestMethAsmInst() != 100) + mi_RetCode = 0; + + if(Nested_Cls.NestMethFoaInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(Cls.NestMethPubStat() != 100) + mi_RetCode = 0; + + //@csharp - See last @csharp + + if(Cls.NestMethAsmStat() != 100) + mi_RetCode = 0; + + if(Cls.NestMethFoaStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test virtual method access + if(Nested_Cls.NestMethPubVirt() != 100) + mi_RetCode = 0; + + //@csharp - See last @csharp + + if(Nested_Cls.NestMethAsmVirt() != 100) + mi_RetCode = 0; + + if(Nested_Cls.NestMethFoaVirt() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + if(Nested_Cls.Test() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test accessing the second nested class + if(Test_Nested2(Nested_Cls.Cls2PubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested2(Nested_Cls.Cls2AsmInst) != 100) + mi_RetCode = 0; + + if(Test_Nested2(Nested_Cls.Cls2FoaInst) != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + + public int Test_Nested2(Cls.Cls2 Nested_Cls2) + { + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS NESTED FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + ///////////////////////////////// + // Test instance field access + Nested_Cls2.Nest2FldPubInst = 100; + if(Nested_Cls2.Nest2FldPubInst != 100) + mi_RetCode = 0; + + //@csharp - Note, CSharp won't allow access of family or private members of a nested class... + //from it's enclosing class. + + Nested_Cls2.Nest2FldAsmInst = 100; + if(Nested_Cls2.Nest2FldAsmInst != 100) + mi_RetCode = 0; + + Nested_Cls2.Nest2FldFoaInst = 100; + if(Nested_Cls2.Nest2FldFoaInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + Cls.Cls2.Nest2FldPubStat = 100; + if(Cls.Cls2.Nest2FldPubStat != 100) + mi_RetCode = 0; + + //@csharp - See last @csharp + + Cls.Cls2.Nest2FldAsmStat = 100; + if(Cls.Cls2.Nest2FldAsmStat != 100) + mi_RetCode = 0; + + Cls.Cls2.Nest2FldFoaStat = 100; + if(Cls.Cls2.Nest2FldFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance method access + if(Nested_Cls2.Nest2MethPubInst() != 100) + mi_RetCode = 0; + + //@csharp - See last @csharp + + if(Nested_Cls2.Nest2MethAsmInst() != 100) + mi_RetCode = 0; + + if(Nested_Cls2.Nest2MethFoaInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(Cls.Cls2.Nest2MethPubStat() != 100) + mi_RetCode = 0; + + //@csharp - See last @csharp + + if(Cls.Cls2.Nest2MethAsmStat() != 100) + mi_RetCode = 0; + + if(Cls.Cls2.Nest2MethFoaStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test virtual method access + if(Nested_Cls2.Nest2MethPubVirt() != 100) + mi_RetCode = 0; + + //@csharp - See last @csharp + + if(Nested_Cls2.Nest2MethAsmVirt() != 100) + mi_RetCode = 0; + + if(Nested_Cls2.Nest2MethFoaVirt() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + if(Nested_Cls2.Test() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + + + // TODO: CHECK IF THIS IS TESTED + ////////////////////////////// + // Instance Fields + // public int FldPubInst; + // private int FldPrivInst; + // protected int FldFamInst; //Translates to "family" + // internal int FldAsmInst; //Translates to "assembly" + // protected internal int FldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int FldPubStat; + private static int FldPrivStat; + protected static int FldFamStat; //family + internal static int FldAsmStat; //assembly + protected internal static int FldFoaStat; //famorassem + + ////////////////////////////////////// + // Instance fields for nested classes + public Cls ClsPubInst = new Cls(); + private Cls ClsPrivInst = new Cls(); + protected Cls ClsFamInst = new Cls(); + internal Cls ClsAsmInst = new Cls(); + protected internal Cls ClsFoaInst = new Cls(); + + ///////////////////////////////////// + // Static fields of nested classes + public static Cls ClsPubStat = new Cls(); + private static Cls ClsPrivStat = new Cls(); + + ////////////////////////////// + // Instance Methods + public int MethPubInst(){ + Console.WriteLine("A::MethPubInst()"); + return 100; + } + + private int MethPrivInst(){ + Console.WriteLine("A::MethPrivInst()"); + return 100; + } + + protected int MethFamInst(){ + Console.WriteLine("A::MethFamInst()"); + return 100; + } + + internal int MethAsmInst(){ + Console.WriteLine("A::MethAsmInst()"); + return 100; + } + + protected internal int MethFoaInst(){ + Console.WriteLine("A::MethFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static Methods + public static int MethPubStat(){ + Console.WriteLine("A::MethPubStat()"); + return 100; + } + + private static int MethPrivStat(){ + Console.WriteLine("A::MethPrivStat()"); + return 100; + } + + protected static int MethFamStat(){ + Console.WriteLine("A::MethFamStat()"); + return 100; + } + + internal static int MethAsmStat(){ + Console.WriteLine("A::MethAsmStat()"); + return 100; + } + + protected internal static int MethFoaStat(){ + Console.WriteLine("A::MethFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance Methods + public virtual int MethPubVirt(){ + Console.WriteLine("A::MethPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing MethPrivVirt() here. + + protected virtual int MethFamVirt(){ + Console.WriteLine("A::MethFamVirt()"); + return 100; + } + + internal virtual int MethAsmVirt(){ + Console.WriteLine("A::MethAsmVirt()"); + return 100; + } + + protected internal virtual int MethFoaVirt(){ + Console.WriteLine("A::MethFoaVirt()"); + return 100; + } + + public class Cls{ + public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS ENCLOSING FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + //@csharp - C# will not allow nested classes to access non-static members of their enclosing classes + + ///////////////////////////////// + // Test static field access + FldPubStat = 100; + if(FldPubStat != 100) + mi_RetCode = 0; + + FldPrivStat = 100; + if(FldPrivStat != 100) + mi_RetCode = 0; + + FldFamStat = 100; + if(FldFamStat != 100) + mi_RetCode = 0; + + FldAsmStat = 100; + if(FldAsmStat != 100) + mi_RetCode = 0; + + FldFoaStat = 100; + if(FldFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethPubStat() != 100) + mi_RetCode = 0; + + if(MethFamStat() != 100) + mi_RetCode = 0; + + if(MethAsmStat() != 100) + mi_RetCode = 0; + + if(MethFoaStat() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + //@todo - Look at testing accessing one nested class from another, @bugug - NEED TO ADD SUCH TESTING, access the public nested class fields from here, etc... + + ///////////////////////////////// + // Test nested class access + if(Test_Nested(Cls2PubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(Cls2PrivInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(Cls2FamInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(Cls2AsmInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(Cls2FoaInst) != 100) + mi_RetCode = 0; + + + + if(Test_Nested(ClsPubStat) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsPrivStat) != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + public int Test_Nested(Cls2 Nested_Cls2){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS NESTED FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + ///////////////////////////////// + // Test instance field access + Nested_Cls2.Nest2FldPubInst = 100; + if(Nested_Cls2.Nest2FldPubInst != 100) + mi_RetCode = 0; + + //@csharp - Note, CSharp won't allow access of family or private members of a nested class... + //from it's enclosing class. + + Nested_Cls2.Nest2FldAsmInst = 100; + if(Nested_Cls2.Nest2FldAsmInst != 100) + mi_RetCode = 0; + + Nested_Cls2.Nest2FldFoaInst = 100; + if(Nested_Cls2.Nest2FldFoaInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + Cls2.Nest2FldPubStat = 100; + if(Cls2.Nest2FldPubStat != 100) + mi_RetCode = 0; + + //@csharp - See last @csharp + + Cls2.Nest2FldAsmStat = 100; + if(Cls2.Nest2FldAsmStat != 100) + mi_RetCode = 0; + + Cls2.Nest2FldFoaStat = 100; + if(Cls2.Nest2FldFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance method access + if(Nested_Cls2.Nest2MethPubInst() != 100) + mi_RetCode = 0; + + //@csharp - See last @csharp + + if(Nested_Cls2.Nest2MethAsmInst() != 100) + mi_RetCode = 0; + + if(Nested_Cls2.Nest2MethFoaInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(Cls2.Nest2MethPubStat() != 100) + mi_RetCode = 0; + + //@csharp - See last @csharp + + if(Cls2.Nest2MethAsmStat() != 100) + mi_RetCode = 0; + + if(Cls2.Nest2MethFoaStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test virtual method access + if(Nested_Cls2.Nest2MethPubVirt() != 100) + mi_RetCode = 0; + + //@csharp - See last @csharp + + if(Nested_Cls2.Nest2MethAsmVirt() != 100) + mi_RetCode = 0; + + if(Nested_Cls2.Nest2MethFoaVirt() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + if(Nested_Cls2.Test() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + ////////////////////////////// + // Instance Fields + public int NestFldPubInst; + + // TODO: Check if this is covered in IL + // private int NestFldPrivInst; + + // TODO: Check if this is covered in IL + // protected int NestFldFamInst; //Translates to "family" + + internal int NestFldAsmInst; //Translates to "assembly" + protected internal int NestFldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int NestFldPubStat; + private static int NestFldPrivStat; + protected static int NestFldFamStat; //family + internal static int NestFldAsmStat; //assembly + protected internal static int NestFldFoaStat; //famorassem + + ////////////////////////////////////// + // Instance fields for nested classes + public Cls2 Cls2PubInst = new Cls2(); + private Cls2 Cls2PrivInst = new Cls2(); + protected Cls2 Cls2FamInst = new Cls2(); + internal Cls2 Cls2AsmInst = new Cls2(); + protected internal Cls2 Cls2FoaInst = new Cls2(); + + ///////////////////////////////////// + // Static fields of nested classes + public static Cls2 ClsPubStat = new Cls2(); + private static Cls2 ClsPrivStat = new Cls2(); + + ////////////////////////////// + // Instance NestMethods + public int NestMethPubInst(){ + Console.WriteLine("A::NestMethPubInst()"); + return 100; + } + + private int NestMethPrivInst(){ + Console.WriteLine("A::NestMethPrivInst()"); + return 100; + } + + protected int NestMethFamInst(){ + Console.WriteLine("A::NestMethFamInst()"); + return 100; + } + + internal int NestMethAsmInst(){ + Console.WriteLine("A::NestMethAsmInst()"); + return 100; + } + + protected internal int NestMethFoaInst(){ + Console.WriteLine("A::NestMethFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethods + public static int NestMethPubStat(){ + Console.WriteLine("A::NestMethPubStat()"); + return 100; + } + + private static int NestMethPrivStat(){ + Console.WriteLine("A::NestMethPrivStat()"); + return 100; + } + + protected static int NestMethFamStat(){ + Console.WriteLine("A::NestMethFamStat()"); + return 100; + } + + internal static int NestMethAsmStat(){ + Console.WriteLine("A::NestMethAsmStat()"); + return 100; + } + + protected internal static int NestMethFoaStat(){ + Console.WriteLine("A::NestMethFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance NestMethods + public virtual int NestMethPubVirt(){ + Console.WriteLine("A::NestMethPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing NestMethPrivVirt() here. + + protected virtual int NestMethFamVirt(){ + Console.WriteLine("A::NestMethFamVirt()"); + return 100; + } + + internal virtual int NestMethAsmVirt(){ + Console.WriteLine("A::NestMethAsmVirt()"); + return 100; + } + + protected internal virtual int NestMethFoaVirt(){ + Console.WriteLine("A::NestMethFoaVirt()"); + return 100; + } + + + public class Cls2{ + public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS ENCLOSING FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + //@csharp - C# will not allow nested classes to access non-static members of their enclosing classes + + ///////////////////////////////// + // Test static field access + FldPubStat = 100; + if(FldPubStat != 100) + mi_RetCode = 0; + + FldFamStat = 100; + if(FldFamStat != 100) + mi_RetCode = 0; + + FldAsmStat = 100; + if(FldAsmStat != 100) + mi_RetCode = 0; + + FldFoaStat = 100; + if(FldFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethPubStat() != 100) + mi_RetCode = 0; + + if(MethFamStat() != 100) + mi_RetCode = 0; + + if(MethAsmStat() != 100) + mi_RetCode = 0; + + if(MethFoaStat() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + //@todo - Look at testing accessing one nested class from another, @bugug - NEED TO ADD SUCH TESTING, access the public nested class fields from here, etc... + + ///////////////////////////////// + // Test static field access + NestFldPubStat = 100; + if(NestFldPubStat != 100) + mi_RetCode = 0; + + NestFldPrivStat = 100; + if(NestFldPrivStat != 100) + mi_RetCode = 0; + + + NestFldFamStat = 100; + if(NestFldFamStat != 100) + mi_RetCode = 0; + + NestFldAsmStat = 100; + if(NestFldAsmStat != 100) + mi_RetCode = 0; + + NestFldFoaStat = 100; + if(NestFldFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(NestMethPubStat() != 100) + mi_RetCode = 0; + + if(NestMethFamStat() != 100) + mi_RetCode = 0; + + if(NestMethAsmStat() != 100) + mi_RetCode = 0; + + if(NestMethFoaStat() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + ////////////////////////////// + // Instance Fields + public int Nest2FldPubInst; + + // TODO: Check if this is covered in IL + // private int Nest2FldPrivInst; + + // TODO: Check if this is covered in IL + // protected int Nest2FldFamInst; //Translates to "family" + internal int Nest2FldAsmInst; //Translates to "assembly" + protected internal int Nest2FldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int Nest2FldPubStat; + + // TODO: Check if this is covered in IL + // private static int Nest2FldPrivStat; + // TODO: Check if this is covered in IL + // protected static int Nest2FldFamStat; //family + internal static int Nest2FldAsmStat; //assembly + protected internal static int Nest2FldFoaStat; //famorassem + + ////////////////////////////// + // Instance Nest2Methods + public int Nest2MethPubInst(){ + Console.WriteLine("A::Nest2MethPubInst()"); + return 100; + } + + private int Nest2MethPrivInst(){ + Console.WriteLine("A::Nest2MethPrivInst()"); + return 100; + } + + protected int Nest2MethFamInst(){ + Console.WriteLine("A::Nest2MethFamInst()"); + return 100; + } + + internal int Nest2MethAsmInst(){ + Console.WriteLine("A::Nest2MethAsmInst()"); + return 100; + } + + protected internal int Nest2MethFoaInst(){ + Console.WriteLine("A::Nest2MethFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static Nest2Methods + public static int Nest2MethPubStat(){ + Console.WriteLine("A::Nest2MethPubStat()"); + return 100; + } + + private static int Nest2MethPrivStat(){ + Console.WriteLine("A::Nest2MethPrivStat()"); + return 100; + } + + protected static int Nest2MethFamStat(){ + Console.WriteLine("A::Nest2MethFamStat()"); + return 100; + } + + internal static int Nest2MethAsmStat(){ + Console.WriteLine("A::Nest2MethAsmStat()"); + return 100; + } + + protected internal static int Nest2MethFoaStat(){ + Console.WriteLine("A::Nest2MethFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance Nest2Methods + public virtual int Nest2MethPubVirt(){ + Console.WriteLine("A::Nest2MethPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing Nest2MethPrivVirt() here. + + protected virtual int Nest2MethFamVirt(){ + Console.WriteLine("A::Nest2MethFamVirt()"); + return 100; + } + + internal virtual int Nest2MethAsmVirt(){ + Console.WriteLine("A::Nest2MethAsmVirt()"); + return 100; + } + + protected internal virtual int Nest2MethFoaVirt(){ + Console.WriteLine("A::Nest2MethFoaVirt()"); + return 100; + } + } + } +} + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-4-1.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-4-1.csproj new file mode 100644 index 0000000000..be3754eb90 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-4-1.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-4-1</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-4-1.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-5-1.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-5-1.cs new file mode 100644 index 0000000000..3b817a6fb7 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-5-1.cs @@ -0,0 +1,422 @@ +// 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. + +////////////////////////////////////////////////////////// +// L-1-5-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 1-deep nesting in +// the same assembly and module (checking access from an +// unrelated class). +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +using System; + +class Test +{ + public static int Main() + { + int mi_RetCode; + mi_RetCode = B.Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; + } +} + +class B +{ + public static int Test() + { + int mi_RetCode = 100; + + A.Cls ac = new A.Cls(); + A a = new A(); + + if(Test_Nested(ac) != 100) + mi_RetCode = 0; + + //@csharp - C# simply won't compile non-related private/family/protected access + + if(Test_Nested(a.ClsPubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(a.ClsAsmInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(a.ClsFoaInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(A.ClsPubStat) != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + public static int Test_Nested(A.Cls ac) + { + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance field access + ac.NestFldPubInst = 100; + if(ac.NestFldPubInst != 100) + mi_RetCode = 0; + + ac.NestFldAsmInst = 100; + if(ac.NestFldAsmInst != 100) + mi_RetCode = 0; + + ac.NestFldFoaInst = 100; + if(ac.NestFldFoaInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + A.Cls.NestFldPubStat = 100; + if(A.Cls.NestFldPubStat != 100) + mi_RetCode = 0; + + A.Cls.NestFldAsmStat = 100; + if(A.Cls.NestFldAsmStat != 100) + mi_RetCode = 0; + + A.Cls.NestFldFoaStat = 100; + if(A.Cls.NestFldFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance method access + if(ac.NestMethPubInst() != 100) + mi_RetCode = 0; + + if(ac.NestMethAsmInst() != 100) + mi_RetCode = 0; + + if(ac.NestMethFoaInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(A.Cls.NestMethPubStat() != 100) + mi_RetCode = 0; + + if(A.Cls.NestMethAsmStat() != 100) + mi_RetCode = 0; + + if(A.Cls.NestMethFoaStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test virtual method access + if(ac.NestMethPubVirt() != 100) + mi_RetCode = 0; + + if(ac.NestMethAsmVirt() != 100) + mi_RetCode = 0; + + if(ac.NestMethFoaVirt() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + if(ac.Test() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } +} + +class A +{ + + // TODO: CHECK IF THIS IS TESTED + ////////////////////////////// + // Instance Fields + // public int FldPubInst; + // private int FldPrivInst; + // protected int FldFamInst; //Translates to "family" + // internal int FldAsmInst; //Translates to "assembly" + // protected internal int FldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int FldPubStat; + private static int FldPrivStat; + protected static int FldFamStat; //family + internal static int FldAsmStat; //assembly + protected internal static int FldFoaStat; //famorassem + + ////////////////////////////////////// + // Instance fields for nested classes + public Cls ClsPubInst = new Cls(); + + // not used + //private Cls ClsPrivInst = new Cls(); + //protected Cls ClsFamInst = new Cls(); + + internal Cls ClsAsmInst = new Cls(); + protected internal Cls ClsFoaInst = new Cls(); + + ///////////////////////////////////// + // Static fields of nested classes + public static Cls ClsPubStat = new Cls(); + + // not used + // private static Cls ClsPrivStat = new Cls(); + + ////////////////////////////// + // Instance Methods + public int MethPubInst(){ + Console.WriteLine("A::MethPubInst()"); + return 100; + } + + private int MethPrivInst(){ + Console.WriteLine("A::MethPrivInst()"); + return 100; + } + + protected int MethFamInst(){ + Console.WriteLine("A::MethFamInst()"); + return 100; + } + + internal int MethAsmInst(){ + Console.WriteLine("A::MethAsmInst()"); + return 100; + } + + protected internal int MethFoaInst(){ + Console.WriteLine("A::MethFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static Methods + public static int MethPubStat(){ + Console.WriteLine("A::MethPubStat()"); + return 100; + } + + private static int MethPrivStat(){ + Console.WriteLine("A::MethPrivStat()"); + return 100; + } + + protected static int MethFamStat(){ + Console.WriteLine("A::MethFamStat()"); + return 100; + } + + internal static int MethAsmStat(){ + Console.WriteLine("A::MethAsmStat()"); + return 100; + } + + protected internal static int MethFoaStat(){ + Console.WriteLine("A::MethFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance Methods + public virtual int MethPubVirt(){ + Console.WriteLine("A::MethPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing MethPrivVirt() here. + + protected virtual int MethFamVirt(){ + Console.WriteLine("A::MethFamVirt()"); + return 100; + } + + internal virtual int MethAsmVirt(){ + Console.WriteLine("A::MethAsmVirt()"); + return 100; + } + + protected internal virtual int MethFoaVirt(){ + Console.WriteLine("A::MethFoaVirt()"); + return 100; + } + + public class Cls{ + public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS ENCLOSING FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + //@csharp - C# will not allow nested classes to access non-static members of their enclosing classes + + ///////////////////////////////// + // Test static field access + FldPubStat = 100; + if(FldPubStat != 100) + mi_RetCode = 0; + + FldPrivStat = 100; + if(FldPrivStat != 100) + mi_RetCode = 0; + + FldFamStat = 100; + if(FldFamStat != 100) + mi_RetCode = 0; + + FldAsmStat = 100; + if(FldAsmStat != 100) + mi_RetCode = 0; + + FldFoaStat = 100; + if(FldFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethPubStat() != 100) + mi_RetCode = 0; + + if(MethFamStat() != 100) + mi_RetCode = 0; + + if(MethAsmStat() != 100) + mi_RetCode = 0; + + if(MethFoaStat() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + //@todo - Look at testing accessing one nested class from another, @bugug - NEED TO ADD SUCH TESTING, access the public nested class fields from here, etc... + + return mi_RetCode; + } + + ////////////////////////////// + // Instance Fields + public int NestFldPubInst; + + // TODO: Check if this is covered in IL + // private int NestFldPrivInst; + + // TODO: Check if this is covered in IL + // protected int NestFldFamInst; //Translates to "family" + + internal int NestFldAsmInst; //Translates to "assembly" + protected internal int NestFldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int NestFldPubStat; + + // TODO: Check if this is covered in IL + // private static int NestFldPrivStat; + // TODO: Check if this is covered in IL + // protected static int NestFldFamStat; //family + + internal static int NestFldAsmStat; //assembly + protected internal static int NestFldFoaStat; //famorassem + + ////////////////////////////// + // Instance NestMethods + public int NestMethPubInst(){ + Console.WriteLine("A::NestMethPubInst()"); + return 100; + } + + private int NestMethPrivInst(){ + Console.WriteLine("A::NestMethPrivInst()"); + return 100; + } + + protected int NestMethFamInst(){ + Console.WriteLine("A::NestMethFamInst()"); + return 100; + } + + internal int NestMethAsmInst(){ + Console.WriteLine("A::NestMethAsmInst()"); + return 100; + } + + protected internal int NestMethFoaInst(){ + Console.WriteLine("A::NestMethFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethods + public static int NestMethPubStat(){ + Console.WriteLine("A::NestMethPubStat()"); + return 100; + } + + private static int NestMethPrivStat(){ + Console.WriteLine("A::NestMethPrivStat()"); + return 100; + } + + protected static int NestMethFamStat(){ + Console.WriteLine("A::NestMethFamStat()"); + return 100; + } + + internal static int NestMethAsmStat(){ + Console.WriteLine("A::NestMethAsmStat()"); + return 100; + } + + protected internal static int NestMethFoaStat(){ + Console.WriteLine("A::NestMethFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance NestMethods + public virtual int NestMethPubVirt(){ + Console.WriteLine("A::NestMethPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing NestMethPrivVirt() here. + + protected virtual int NestMethFamVirt(){ + Console.WriteLine("A::NestMethFamVirt()"); + return 100; + } + + internal virtual int NestMethAsmVirt(){ + Console.WriteLine("A::NestMethAsmVirt()"); + return 100; + } + + protected internal virtual int NestMethFoaVirt(){ + Console.WriteLine("A::NestMethFoaVirt()"); + return 100; + } + + } +} + + + + + + + + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-5-1.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-5-1.csproj new file mode 100644 index 0000000000..be78b0bcdc --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-5-1.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-5-1</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-5-1.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-5-2.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-5-2.csproj new file mode 100644 index 0000000000..a51d559cbd --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-5-2.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-5-2</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-5-2D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-5-2D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-5-2D.cs new file mode 100644 index 0000000000..589abeec9b --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-5-2D.cs @@ -0,0 +1,272 @@ +// 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. + +#pragma warning disable 414 +using System; + +public class A{ + ////////////////////////////// + // Instance Fields + public int FldPubInst; + private int FldPrivInst; + protected int FldFamInst; //Translates to "family" + internal int FldAsmInst; //Translates to "assembly" + protected internal int FldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int FldPubStat; + private static int FldPrivStat; + protected static int FldFamStat; //family + internal static int FldAsmStat; //assembly + protected internal static int FldFoaStat; //famorassem + + ////////////////////////////////////// + // Instance fields for nested classes + public Cls ClsPubInst = new Cls(); + private Cls ClsPrivInst = new Cls(); + protected Cls ClsFamInst = new Cls(); + internal Cls ClsAsmInst = new Cls(); + protected internal Cls ClsFoaInst = new Cls(); + + ///////////////////////////////////// + // Static fields of nested classes + public static Cls ClsPubStat = new Cls(); + private static Cls ClsPrivStat = new Cls(); + + ////////////////////////////// + // Instance Methods + public int MethPubInst(){ + Console.WriteLine("A::MethPubInst()"); + return 100; + } + + private int MethPrivInst(){ + Console.WriteLine("A::MethPrivInst()"); + return 100; + } + + protected int MethFamInst(){ + Console.WriteLine("A::MethFamInst()"); + return 100; + } + + internal int MethAsmInst(){ + Console.WriteLine("A::MethAsmInst()"); + return 100; + } + + protected internal int MethFoaInst(){ + Console.WriteLine("A::MethFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static Methods + public static int MethPubStat(){ + Console.WriteLine("A::MethPubStat()"); + return 100; + } + + private static int MethPrivStat(){ + Console.WriteLine("A::MethPrivStat()"); + return 100; + } + + protected static int MethFamStat(){ + Console.WriteLine("A::MethFamStat()"); + return 100; + } + + internal static int MethAsmStat(){ + Console.WriteLine("A::MethAsmStat()"); + return 100; + } + + protected internal static int MethFoaStat(){ + Console.WriteLine("A::MethFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance Methods + public virtual int MethPubVirt(){ + Console.WriteLine("A::MethPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing MethPrivVirt() here. + + protected virtual int MethFamVirt(){ + Console.WriteLine("A::MethFamVirt()"); + return 100; + } + + internal virtual int MethAsmVirt(){ + Console.WriteLine("A::MethAsmVirt()"); + return 100; + } + + protected internal virtual int MethFoaVirt(){ + Console.WriteLine("A::MethFoaVirt()"); + return 100; + } + + public class Cls{ + public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS ENCLOSING FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + //@csharp - C# will not allow nested classes to access non-static members of their enclosing classes + + ///////////////////////////////// + // Test static field access + FldPubStat = 100; + if(FldPubStat != 100) + mi_RetCode = 0; + + FldFamStat = 100; + if(FldFamStat != 100) + mi_RetCode = 0; + + FldAsmStat = 100; + if(FldAsmStat != 100) + mi_RetCode = 0; + + FldFoaStat = 100; + if(FldFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethPubStat() != 100) + mi_RetCode = 0; + + if(MethFamStat() != 100) + mi_RetCode = 0; + + if(MethAsmStat() != 100) + mi_RetCode = 0; + + if(MethFoaStat() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + //@todo - Look at testing accessing one nested class from another, @bugug - NEED TO ADD SUCH TESTING, access the public nested class fields from here, etc... + + return mi_RetCode; + } + + ////////////////////////////// + // Instance Fields + public int NestFldPubInst; + private int NestFldPrivInst; + protected int NestFldFamInst; //Translates to "family" + internal int NestFldAsmInst; //Translates to "assembly" + protected internal int NestFldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int NestFldPubStat; + private static int NestFldPrivStat; + protected static int NestFldFamStat; //family + internal static int NestFldAsmStat; //assembly + protected internal static int NestFldFoaStat; //famorassem + + ////////////////////////////// + // Instance NestMethods + public int NestMethPubInst(){ + Console.WriteLine("A::NestMethPubInst()"); + return 100; + } + + private int NestMethPrivInst(){ + Console.WriteLine("A::NestMethPrivInst()"); + return 100; + } + + protected int NestMethFamInst(){ + Console.WriteLine("A::NestMethFamInst()"); + return 100; + } + + internal int NestMethAsmInst(){ + Console.WriteLine("A::NestMethAsmInst()"); + return 100; + } + + protected internal int NestMethFoaInst(){ + Console.WriteLine("A::NestMethFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethods + public static int NestMethPubStat(){ + Console.WriteLine("A::NestMethPubStat()"); + return 100; + } + + private static int NestMethPrivStat(){ + Console.WriteLine("A::NestMethPrivStat()"); + return 100; + } + + protected static int NestMethFamStat(){ + Console.WriteLine("A::NestMethFamStat()"); + return 100; + } + + internal static int NestMethAsmStat(){ + Console.WriteLine("A::NestMethAsmStat()"); + return 100; + } + + protected internal static int NestMethFoaStat(){ + Console.WriteLine("A::NestMethFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance NestMethods + public virtual int NestMethPubVirt(){ + Console.WriteLine("A::NestMethPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing NestMethPrivVirt() here. + + protected virtual int NestMethFamVirt(){ + Console.WriteLine("A::NestMethFamVirt()"); + return 100; + } + + internal virtual int NestMethAsmVirt(){ + Console.WriteLine("A::NestMethAsmVirt()"); + return 100; + } + + protected internal virtual int NestMethFoaVirt(){ + Console.WriteLine("A::NestMethFoaVirt()"); + return 100; + } + + } +} + + + + + + + + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-5-3.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-5-3.cs new file mode 100644 index 0000000000..eeebe140c8 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-5-3.cs @@ -0,0 +1,88 @@ +// 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. + +////////////////////////////////////////////////////////// +// L-1-5-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 1-deep nesting in +// the same assembly and module (checking access from an +// unrelated class). +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +using System; + +class Test{ + public static int Main(){ + int mi_RetCode; + mi_RetCode = B.Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; + } +} + +class B{ + public static int Test(){ + int mi_RetCode = 100; + + A.Cls ac = new A.Cls(); + A a = new A(); + + if(Test_Nested(ac) != 100) + mi_RetCode = 0; + + //@csharp - C# simply won't compile non-related private/family/protected access + + if(Test_Nested(a.ClsPubInst) != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + public static int Test_Nested(A.Cls ac){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance field access + ac.NestFldPubInst = 100; + if(ac.NestFldPubInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + A.Cls.NestFldPubStat = 100; + if(A.Cls.NestFldPubStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance method access + if(ac.NestMethPubInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(A.Cls.NestMethPubStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test virtual method access + if(ac.NestMethPubVirt() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + if(ac.Test() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } +} + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-5-3.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-5-3.csproj new file mode 100644 index 0000000000..de89dd6890 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-5-3.csproj @@ -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>L-1-5-3</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-5-3.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <ProjectReference Include="L-1-5-3D.csproj" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-5-3D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-5-3D.cs new file mode 100644 index 0000000000..48ace453b7 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-5-3D.cs @@ -0,0 +1,273 @@ +// 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. + +#pragma warning disable 414 + +using System; + +public class A{ + ////////////////////////////// + // Instance Fields + public int FldPubInst; + private int FldPrivInst; + protected int FldFamInst; //Translates to "family" + internal int FldAsmInst; //Translates to "assembly" + protected internal int FldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int FldPubStat; + private static int FldPrivStat; + protected static int FldFamStat; //family + internal static int FldAsmStat; //assembly + protected internal static int FldFoaStat; //famorassem + + ////////////////////////////////////// + // Instance fields for nested classes + public Cls ClsPubInst = new Cls(); + private Cls ClsPrivInst = new Cls(); + protected Cls ClsFamInst = new Cls(); + internal Cls ClsAsmInst = new Cls(); + protected internal Cls ClsFoaInst = new Cls(); + + ///////////////////////////////////// + // Static fields of nested classes + public static Cls ClsPubStat = new Cls(); + private static Cls ClsPrivStat = new Cls(); + + ////////////////////////////// + // Instance Methods + public int MethPubInst(){ + Console.WriteLine("A::MethPubInst()"); + return 100; + } + + private int MethPrivInst(){ + Console.WriteLine("A::MethPrivInst()"); + return 100; + } + + protected int MethFamInst(){ + Console.WriteLine("A::MethFamInst()"); + return 100; + } + + internal int MethAsmInst(){ + Console.WriteLine("A::MethAsmInst()"); + return 100; + } + + protected internal int MethFoaInst(){ + Console.WriteLine("A::MethFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static Methods + public static int MethPubStat(){ + Console.WriteLine("A::MethPubStat()"); + return 100; + } + + private static int MethPrivStat(){ + Console.WriteLine("A::MethPrivStat()"); + return 100; + } + + protected static int MethFamStat(){ + Console.WriteLine("A::MethFamStat()"); + return 100; + } + + internal static int MethAsmStat(){ + Console.WriteLine("A::MethAsmStat()"); + return 100; + } + + protected internal static int MethFoaStat(){ + Console.WriteLine("A::MethFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance Methods + public virtual int MethPubVirt(){ + Console.WriteLine("A::MethPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing MethPrivVirt() here. + + protected virtual int MethFamVirt(){ + Console.WriteLine("A::MethFamVirt()"); + return 100; + } + + internal virtual int MethAsmVirt(){ + Console.WriteLine("A::MethAsmVirt()"); + return 100; + } + + protected internal virtual int MethFoaVirt(){ + Console.WriteLine("A::MethFoaVirt()"); + return 100; + } + + public class Cls{ + public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS ENCLOSING FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + //@csharp - C# will not allow nested classes to access non-static members of their enclosing classes + + ///////////////////////////////// + // Test static field access + FldPubStat = 100; + if(FldPubStat != 100) + mi_RetCode = 0; + + FldFamStat = 100; + if(FldFamStat != 100) + mi_RetCode = 0; + + FldAsmStat = 100; + if(FldAsmStat != 100) + mi_RetCode = 0; + + FldFoaStat = 100; + if(FldFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethPubStat() != 100) + mi_RetCode = 0; + + if(MethFamStat() != 100) + mi_RetCode = 0; + + if(MethAsmStat() != 100) + mi_RetCode = 0; + + if(MethFoaStat() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + //@todo - Look at testing accessing one nested class from another, @bugug - NEED TO ADD SUCH TESTING, access the public nested class fields from here, etc... + + return mi_RetCode; + } + + ////////////////////////////// + // Instance Fields + public int NestFldPubInst; + private int NestFldPrivInst; + protected int NestFldFamInst; //Translates to "family" + internal int NestFldAsmInst; //Translates to "assembly" + protected internal int NestFldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int NestFldPubStat; + private static int NestFldPrivStat; + protected static int NestFldFamStat; //family + internal static int NestFldAsmStat; //assembly + protected internal static int NestFldFoaStat; //famorassem + + ////////////////////////////// + // Instance NestMethods + public int NestMethPubInst(){ + Console.WriteLine("A::NestMethPubInst()"); + return 100; + } + + private int NestMethPrivInst(){ + Console.WriteLine("A::NestMethPrivInst()"); + return 100; + } + + protected int NestMethFamInst(){ + Console.WriteLine("A::NestMethFamInst()"); + return 100; + } + + internal int NestMethAsmInst(){ + Console.WriteLine("A::NestMethAsmInst()"); + return 100; + } + + protected internal int NestMethFoaInst(){ + Console.WriteLine("A::NestMethFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethods + public static int NestMethPubStat(){ + Console.WriteLine("A::NestMethPubStat()"); + return 100; + } + + private static int NestMethPrivStat(){ + Console.WriteLine("A::NestMethPrivStat()"); + return 100; + } + + protected static int NestMethFamStat(){ + Console.WriteLine("A::NestMethFamStat()"); + return 100; + } + + internal static int NestMethAsmStat(){ + Console.WriteLine("A::NestMethAsmStat()"); + return 100; + } + + protected internal static int NestMethFoaStat(){ + Console.WriteLine("A::NestMethFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance NestMethods + public virtual int NestMethPubVirt(){ + Console.WriteLine("A::NestMethPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing NestMethPrivVirt() here. + + protected virtual int NestMethFamVirt(){ + Console.WriteLine("A::NestMethFamVirt()"); + return 100; + } + + internal virtual int NestMethAsmVirt(){ + Console.WriteLine("A::NestMethAsmVirt()"); + return 100; + } + + protected internal virtual int NestMethFoaVirt(){ + Console.WriteLine("A::NestMethFoaVirt()"); + return 100; + } + + } +} + + + + + + + + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-5-3D.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-5-3D.csproj new file mode 100644 index 0000000000..143f9fe3da --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-5-3D.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-5-3D</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-5-3D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-6-1.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-6-1.cs new file mode 100644 index 0000000000..48b1cf43c6 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-6-1.cs @@ -0,0 +1,598 @@ +// 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. + +////////////////////////////////////////////////////////// +// L-1-4-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 2-deep nesting in +// the same assembly and module +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +using System; + +class Test{ + public static int Main() + { + int mi_RetCode; + mi_RetCode = B.Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; + } +} + +class B +{ + public static int Test() + { + A a = new A(); + + int mi_RetCode = 100; + + ///////////////////////////////// + // Test nested class access + if(Test_Nested(a.ClsPubInst.Cls2PubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(a.ClsPubInst.Cls2AsmInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(a.ClsPubInst.Cls2FoaInst) != 100) + mi_RetCode = 0; + + + if(Test_Nested(a.ClsAsmInst.Cls2PubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(a.ClsAsmInst.Cls2AsmInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(a.ClsAsmInst.Cls2FoaInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(a.ClsFoaInst.Cls2PubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(a.ClsFoaInst.Cls2AsmInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(a.ClsFoaInst.Cls2FoaInst) != 100) + mi_RetCode = 0; + + + // static fields + if(Test_Nested(A.ClsPubStat.Cls2PubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(A.ClsPubStat.Cls2AsmInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(A.ClsPubStat.Cls2FoaInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(A.Cls.ClsPubStat) != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + public static int Test_Nested(A.Cls.Cls2 Nested_Cls){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS NESTED FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + ///////////////////////////////// + // Test instance field access + Nested_Cls.Nest2FldPubInst = 100; + if(Nested_Cls.Nest2FldPubInst != 100) + mi_RetCode = 0; + + Nested_Cls.Nest2FldAsmInst = 100; + if(Nested_Cls.Nest2FldAsmInst != 100) + mi_RetCode = 0; + + Nested_Cls.Nest2FldFoaInst = 100; + if(Nested_Cls.Nest2FldFoaInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + A.Cls.Cls2.Nest2FldPubStat = 100; + if(A.Cls.Cls2.Nest2FldPubStat != 100) + mi_RetCode = 0; + + A.Cls.Cls2.Nest2FldAsmStat = 100; + if(A.Cls.Cls2.Nest2FldAsmStat != 100) + mi_RetCode = 0; + + A.Cls.Cls2.Nest2FldFoaStat = 100; + if(A.Cls.Cls2.Nest2FldFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance method access + if(Nested_Cls.Nest2MethPubInst() != 100) + mi_RetCode = 0; + + if(Nested_Cls.Nest2MethAsmInst() != 100) + mi_RetCode = 0; + + if(Nested_Cls.Nest2MethFoaInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(A.Cls.Cls2.Nest2MethPubStat() != 100) + mi_RetCode = 0; + + if(A.Cls.Cls2.Nest2MethAsmStat() != 100) + mi_RetCode = 0; + + if(A.Cls.Cls2.Nest2MethFoaStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test virtual method access + if(Nested_Cls.Nest2MethPubVirt() != 100) + mi_RetCode = 0; + + if(Nested_Cls.Nest2MethAsmVirt() != 100) + mi_RetCode = 0; + + if(Nested_Cls.Nest2MethFoaVirt() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + if(Nested_Cls.Test() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } +} + + +class A +{ + // TODO: CHECK IF THIS IS TESTED + ////////////////////////////// + // Instance Fields + // public int FldPubInst; + // private int FldPrivInst; + // protected int FldFamInst; //Translates to "family" + // internal int FldAsmInst; //Translates to "assembly" + // protected internal int FldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int FldPubStat; + private static int FldPrivStat; + protected static int FldFamStat; //family + internal static int FldAsmStat; //assembly + protected internal static int FldFoaStat; //famorassem + + ////////////////////////////////////// + // Instance fields for nested classes + public Cls ClsPubInst = new Cls(); + + // not used + //private Cls ClsPrivInst = new Cls(); + // not used + //protected Cls ClsFamInst = new Cls(); + internal Cls ClsAsmInst = new Cls(); + protected internal Cls ClsFoaInst = new Cls(); + + ///////////////////////////////////// + // Static fields of nested classes + public static Cls ClsPubStat = new Cls(); + + // not used + //private static Cls ClsPrivStat = new Cls(); + + ////////////////////////////// + // Instance Methods + public int MethPubInst(){ + Console.WriteLine("A::MethPubInst()"); + return 100; + } + + private int MethPrivInst(){ + Console.WriteLine("A::MethPrivInst()"); + return 100; + } + + protected int MethFamInst(){ + Console.WriteLine("A::MethFamInst()"); + return 100; + } + + internal int MethAsmInst(){ + Console.WriteLine("A::MethAsmInst()"); + return 100; + } + + protected internal int MethFoaInst(){ + Console.WriteLine("A::MethFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static Methods + public static int MethPubStat(){ + Console.WriteLine("A::MethPubStat()"); + return 100; + } + + private static int MethPrivStat(){ + Console.WriteLine("A::MethPrivStat()"); + return 100; + } + + protected static int MethFamStat(){ + Console.WriteLine("A::MethFamStat()"); + return 100; + } + + internal static int MethAsmStat(){ + Console.WriteLine("A::MethAsmStat()"); + return 100; + } + + protected internal static int MethFoaStat(){ + Console.WriteLine("A::MethFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance Methods + public virtual int MethPubVirt(){ + Console.WriteLine("A::MethPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing MethPrivVirt() here. + + protected virtual int MethFamVirt(){ + Console.WriteLine("A::MethFamVirt()"); + return 100; + } + + internal virtual int MethAsmVirt(){ + Console.WriteLine("A::MethAsmVirt()"); + return 100; + } + + protected internal virtual int MethFoaVirt(){ + Console.WriteLine("A::MethFoaVirt()"); + return 100; + } + + public class Cls + { + + // TODO: CHECK IF THIS IS TESTED + ////////////////////////////// + // Instance Fields + // public int NestFldPubInst; + // private int NestFldPrivInst; + // protected int NestFldFamInst; //Translates to "family" + // internal int NestFldAsmInst; //Translates to "assembly" + // protected internal int NestFldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int NestFldPubStat; + private static int NestFldPrivStat; + protected static int NestFldFamStat; //family + internal static int NestFldAsmStat; //assembly + protected internal static int NestFldFoaStat; //famorassem + + ////////////////////////////////////// + // Instance fields for nested classes + public Cls2 Cls2PubInst = new Cls2(); + + // not used + // private Cls2 Cls2PrivInst = new Cls2(); + // protected Cls2 Cls2FamInst = new Cls2(); + internal Cls2 Cls2AsmInst = new Cls2(); + protected internal Cls2 Cls2FoaInst = new Cls2(); + + ///////////////////////////////////// + // Static fields of nested classes + public static Cls2 ClsPubStat = new Cls2(); + + // not used + // private static Cls2 ClsPrivStat = new Cls2(); + + ////////////////////////////// + // Instance NestMethods + public int NestMethPubInst(){ + Console.WriteLine("A::NestMethPubInst()"); + return 100; + } + + private int NestMethPrivInst(){ + Console.WriteLine("A::NestMethPrivInst()"); + return 100; + } + + protected int NestMethFamInst(){ + Console.WriteLine("A::NestMethFamInst()"); + return 100; + } + + internal int NestMethAsmInst(){ + Console.WriteLine("A::NestMethAsmInst()"); + return 100; + } + + protected internal int NestMethFoaInst(){ + Console.WriteLine("A::NestMethFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethods + public static int NestMethPubStat(){ + Console.WriteLine("A::NestMethPubStat()"); + return 100; + } + + private static int NestMethPrivStat(){ + Console.WriteLine("A::NestMethPrivStat()"); + return 100; + } + + protected static int NestMethFamStat(){ + Console.WriteLine("A::NestMethFamStat()"); + return 100; + } + + internal static int NestMethAsmStat(){ + Console.WriteLine("A::NestMethAsmStat()"); + return 100; + } + + protected internal static int NestMethFoaStat(){ + Console.WriteLine("A::NestMethFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance NestMethods + public virtual int NestMethPubVirt(){ + Console.WriteLine("A::NestMethPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing NestMethPrivVirt() here. + + protected virtual int NestMethFamVirt(){ + Console.WriteLine("A::NestMethFamVirt()"); + return 100; + } + + internal virtual int NestMethAsmVirt(){ + Console.WriteLine("A::NestMethAsmVirt()"); + return 100; + } + + protected internal virtual int NestMethFoaVirt(){ + Console.WriteLine("A::NestMethFoaVirt()"); + return 100; + } + + + public class Cls2{ + public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS ENCLOSING FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + //@csharp - C# will not allow nested classes to access non-static members of their enclosing classes + + ///////////////////////////////// + // Test static field access + FldPubStat = 100; + if(FldPubStat != 100) + mi_RetCode = 0; + + FldPrivStat = 100; + if(FldPrivStat != 100) + mi_RetCode = 0; + + FldFamStat = 100; + if(FldFamStat != 100) + mi_RetCode = 0; + + FldAsmStat = 100; + if(FldAsmStat != 100) + mi_RetCode = 0; + + FldFoaStat = 100; + if(FldFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethPubStat() != 100) + mi_RetCode = 0; + + if(MethFamStat() != 100) + mi_RetCode = 0; + + if(MethAsmStat() != 100) + mi_RetCode = 0; + + if(MethFoaStat() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + //@todo - Look at testing accessing one nested class from another, @bugug - NEED TO ADD SUCH TESTING, access the public nested class fields from here, etc... + + ///////////////////////////////// + // Test static field access + NestFldPubStat = 100; + if(NestFldPubStat != 100) + mi_RetCode = 0; + + NestFldPrivStat = 100; + if(NestFldPrivStat != 100) + mi_RetCode = 0; + + NestFldFamStat = 100; + if(NestFldFamStat != 100) + mi_RetCode = 0; + + NestFldAsmStat = 100; + if(NestFldAsmStat != 100) + mi_RetCode = 0; + + NestFldFoaStat = 100; + if(NestFldFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(NestMethPubStat() != 100) + mi_RetCode = 0; + + if(NestMethFamStat() != 100) + mi_RetCode = 0; + + if(NestMethAsmStat() != 100) + mi_RetCode = 0; + + if(NestMethFoaStat() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + ////////////////////////////// + // Instance Fields + public int Nest2FldPubInst; + + + // TODO: Check if this is covered in IL + // private int Nest2FldPrivInst; + + // TODO: Check if this is covered in IL + //protected int Nest2FldFamInst; //Translates to "family" + internal int Nest2FldAsmInst; //Translates to "assembly" + protected internal int Nest2FldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int Nest2FldPubStat; + + + // TODO: Check if this is covered in IL + // private static int Nest2FldPrivStat; + + // TODO: Check if this is covered in IL + // protected static int Nest2FldFamStat; //family + internal static int Nest2FldAsmStat; //assembly + protected internal static int Nest2FldFoaStat; //famorassem + + ////////////////////////////// + // Instance Nest2Methods + public int Nest2MethPubInst(){ + Console.WriteLine("A::Nest2MethPubInst()"); + return 100; + } + + private int Nest2MethPrivInst(){ + Console.WriteLine("A::Nest2MethPrivInst()"); + return 100; + } + + protected int Nest2MethFamInst(){ + Console.WriteLine("A::Nest2MethFamInst()"); + return 100; + } + + internal int Nest2MethAsmInst(){ + Console.WriteLine("A::Nest2MethAsmInst()"); + return 100; + } + + protected internal int Nest2MethFoaInst(){ + Console.WriteLine("A::Nest2MethFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static Nest2Methods + public static int Nest2MethPubStat(){ + Console.WriteLine("A::Nest2MethPubStat()"); + return 100; + } + + private static int Nest2MethPrivStat(){ + Console.WriteLine("A::Nest2MethPrivStat()"); + return 100; + } + + protected static int Nest2MethFamStat(){ + Console.WriteLine("A::Nest2MethFamStat()"); + return 100; + } + + internal static int Nest2MethAsmStat(){ + Console.WriteLine("A::Nest2MethAsmStat()"); + return 100; + } + + protected internal static int Nest2MethFoaStat(){ + Console.WriteLine("A::Nest2MethFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance Nest2Methods + public virtual int Nest2MethPubVirt(){ + Console.WriteLine("A::Nest2MethPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing Nest2MethPrivVirt() here. + + protected virtual int Nest2MethFamVirt(){ + Console.WriteLine("A::Nest2MethFamVirt()"); + return 100; + } + + internal virtual int Nest2MethAsmVirt(){ + Console.WriteLine("A::Nest2MethAsmVirt()"); + return 100; + } + + protected internal virtual int Nest2MethFoaVirt(){ + Console.WriteLine("A::Nest2MethFoaVirt()"); + return 100; + } + } + } +} + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-6-1.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-6-1.csproj new file mode 100644 index 0000000000..0d2d089c85 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-6-1.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-6-1</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-6-1.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-6-2.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-6-2.csproj new file mode 100644 index 0000000000..230a2444a6 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-6-2.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-6-2</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-6-2D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-6-2D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-6-2D.cs new file mode 100644 index 0000000000..1d7c475f6c --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-6-2D.cs @@ -0,0 +1,408 @@ +// 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. + +#pragma warning disable 414 +using System; + + +class A{ + ////////////////////////////// + // Instance Fields + public int FldPubInst; + private int FldPrivInst; + protected int FldFamInst; //Translates to "family" + internal int FldAsmInst; //Translates to "assembly" + protected internal int FldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int FldPubStat; + private static int FldPrivStat; + protected static int FldFamStat; //family + internal static int FldAsmStat; //assembly + protected internal static int FldFoaStat; //famorassem + + ////////////////////////////////////// + // Instance fields for nested classes + public Cls ClsPubInst = new Cls(); + private Cls ClsPrivInst = new Cls(); + protected Cls ClsFamInst = new Cls(); + internal Cls ClsAsmInst = new Cls(); + protected internal Cls ClsFoaInst = new Cls(); + + ///////////////////////////////////// + // Static fields of nested classes + public static Cls ClsPubStat = new Cls(); + private static Cls ClsPrivStat = new Cls(); + + ////////////////////////////// + // Instance Methods + public int MethPubInst(){ + Console.WriteLine("A::MethPubInst()"); + return 100; + } + + private int MethPrivInst(){ + Console.WriteLine("A::MethPrivInst()"); + return 100; + } + + protected int MethFamInst(){ + Console.WriteLine("A::MethFamInst()"); + return 100; + } + + internal int MethAsmInst(){ + Console.WriteLine("A::MethAsmInst()"); + return 100; + } + + protected internal int MethFoaInst(){ + Console.WriteLine("A::MethFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static Methods + public static int MethPubStat(){ + Console.WriteLine("A::MethPubStat()"); + return 100; + } + + private static int MethPrivStat(){ + Console.WriteLine("A::MethPrivStat()"); + return 100; + } + + protected static int MethFamStat(){ + Console.WriteLine("A::MethFamStat()"); + return 100; + } + + internal static int MethAsmStat(){ + Console.WriteLine("A::MethAsmStat()"); + return 100; + } + + protected internal static int MethFoaStat(){ + Console.WriteLine("A::MethFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance Methods + public virtual int MethPubVirt(){ + Console.WriteLine("A::MethPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing MethPrivVirt() here. + + protected virtual int MethFamVirt(){ + Console.WriteLine("A::MethFamVirt()"); + return 100; + } + + internal virtual int MethAsmVirt(){ + Console.WriteLine("A::MethAsmVirt()"); + return 100; + } + + protected internal virtual int MethFoaVirt(){ + Console.WriteLine("A::MethFoaVirt()"); + return 100; + } + + public class Cls{ + ////////////////////////////// + // Instance Fields + public int NestFldPubInst; + private int NestFldPrivInst; + protected int NestFldFamInst; //Translates to "family" + internal int NestFldAsmInst; //Translates to "assembly" + protected internal int NestFldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int NestFldPubStat; + private static int NestFldPrivStat; + protected static int NestFldFamStat; //family + internal static int NestFldAsmStat; //assembly + protected internal static int NestFldFoaStat; //famorassem + + ////////////////////////////////////// + // Instance fields for nested classes + public Cls2 Cls2PubInst = new Cls2(); + private Cls2 Cls2PrivInst = new Cls2(); + protected Cls2 Cls2FamInst = new Cls2(); + internal Cls2 Cls2AsmInst = new Cls2(); + protected internal Cls2 Cls2FoaInst = new Cls2(); + + ///////////////////////////////////// + // Static fields of nested classes + public static Cls ClsPubStat = new Cls(); + private static Cls ClsPrivStat = new Cls(); + + ////////////////////////////// + // Instance NestMethods + public int NestMethPubInst(){ + Console.WriteLine("A::NestMethPubInst()"); + return 100; + } + + private int NestMethPrivInst(){ + Console.WriteLine("A::NestMethPrivInst()"); + return 100; + } + + protected int NestMethFamInst(){ + Console.WriteLine("A::NestMethFamInst()"); + return 100; + } + + internal int NestMethAsmInst(){ + Console.WriteLine("A::NestMethAsmInst()"); + return 100; + } + + protected internal int NestMethFoaInst(){ + Console.WriteLine("A::NestMethFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethods + public static int NestMethPubStat(){ + Console.WriteLine("A::NestMethPubStat()"); + return 100; + } + + private static int NestMethPrivStat(){ + Console.WriteLine("A::NestMethPrivStat()"); + return 100; + } + + protected static int NestMethFamStat(){ + Console.WriteLine("A::NestMethFamStat()"); + return 100; + } + + internal static int NestMethAsmStat(){ + Console.WriteLine("A::NestMethAsmStat()"); + return 100; + } + + protected internal static int NestMethFoaStat(){ + Console.WriteLine("A::NestMethFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance NestMethods + public virtual int NestMethPubVirt(){ + Console.WriteLine("A::NestMethPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing NestMethPrivVirt() here. + + protected virtual int NestMethFamVirt(){ + Console.WriteLine("A::NestMethFamVirt()"); + return 100; + } + + internal virtual int NestMethAsmVirt(){ + Console.WriteLine("A::NestMethAsmVirt()"); + return 100; + } + + protected internal virtual int NestMethFoaVirt(){ + Console.WriteLine("A::NestMethFoaVirt()"); + return 100; + } + + + public class Cls2{ + public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS ENCLOSING FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + //@csharp - C# will not allow nested classes to access non-static members of their enclosing classes + + ///////////////////////////////// + // Test static field access + FldPubStat = 100; + if(FldPubStat != 100) + mi_RetCode = 0; + + FldFamStat = 100; + if(FldFamStat != 100) + mi_RetCode = 0; + + FldAsmStat = 100; + if(FldAsmStat != 100) + mi_RetCode = 0; + + FldFoaStat = 100; + if(FldFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethPubStat() != 100) + mi_RetCode = 0; + + if(MethFamStat() != 100) + mi_RetCode = 0; + + if(MethAsmStat() != 100) + mi_RetCode = 0; + + if(MethFoaStat() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + //@todo - Look at testing accessing one nested class from another, @bugug - NEED TO ADD SUCH TESTING, access the public nested class fields from here, etc... + + ///////////////////////////////// + // Test static field access + NestFldPubStat = 100; + if(NestFldPubStat != 100) + mi_RetCode = 0; + + NestFldFamStat = 100; + if(NestFldFamStat != 100) + mi_RetCode = 0; + + NestFldAsmStat = 100; + if(NestFldAsmStat != 100) + mi_RetCode = 0; + + NestFldFoaStat = 100; + if(NestFldFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(NestMethPubStat() != 100) + mi_RetCode = 0; + + if(NestMethFamStat() != 100) + mi_RetCode = 0; + + if(NestMethAsmStat() != 100) + mi_RetCode = 0; + + if(NestMethFoaStat() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + ////////////////////////////// + // Instance Fields + public int Nest2FldPubInst; + private int Nest2FldPrivInst; + protected int Nest2FldFamInst; //Translates to "family" + internal int Nest2FldAsmInst; //Translates to "assembly" + protected internal int Nest2FldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int Nest2FldPubStat; + private static int Nest2FldPrivStat; + protected static int Nest2FldFamStat; //family + internal static int Nest2FldAsmStat; //assembly + protected internal static int Nest2FldFoaStat; //famorassem + + ////////////////////////////// + // Instance Nest2Methods + public int Nest2MethPubInst(){ + Console.WriteLine("A::Nest2MethPubInst()"); + return 100; + } + + private int Nest2MethPrivInst(){ + Console.WriteLine("A::Nest2MethPrivInst()"); + return 100; + } + + protected int Nest2MethFamInst(){ + Console.WriteLine("A::Nest2MethFamInst()"); + return 100; + } + + internal int Nest2MethAsmInst(){ + Console.WriteLine("A::Nest2MethAsmInst()"); + return 100; + } + + protected internal int Nest2MethFoaInst(){ + Console.WriteLine("A::Nest2MethFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static Nest2Methods + public static int Nest2MethPubStat(){ + Console.WriteLine("A::Nest2MethPubStat()"); + return 100; + } + + private static int Nest2MethPrivStat(){ + Console.WriteLine("A::Nest2MethPrivStat()"); + return 100; + } + + protected static int Nest2MethFamStat(){ + Console.WriteLine("A::Nest2MethFamStat()"); + return 100; + } + + internal static int Nest2MethAsmStat(){ + Console.WriteLine("A::Nest2MethAsmStat()"); + return 100; + } + + protected internal static int Nest2MethFoaStat(){ + Console.WriteLine("A::Nest2MethFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance Nest2Methods + public virtual int Nest2MethPubVirt(){ + Console.WriteLine("A::Nest2MethPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing Nest2MethPrivVirt() here. + + protected virtual int Nest2MethFamVirt(){ + Console.WriteLine("A::Nest2MethFamVirt()"); + return 100; + } + + internal virtual int Nest2MethAsmVirt(){ + Console.WriteLine("A::Nest2MethAsmVirt()"); + return 100; + } + + protected internal virtual int Nest2MethFoaVirt(){ + Console.WriteLine("A::Nest2MethFoaVirt()"); + return 100; + } + } + } +} + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-6-3.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-6-3.cs new file mode 100644 index 0000000000..006f4bc1c7 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-6-3.cs @@ -0,0 +1,88 @@ +// 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. + +////////////////////////////////////////////////////////// +// L-1-4-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 2-deep nesting in +// the same assembly and module +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +using System; + +class Test{ + public static int Main(){ + int mi_RetCode; + mi_RetCode = B.Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; + } +} + +class B{ + public static int Test(){ + A a = new A(); + + int mi_RetCode = 100; + + ///////////////////////////////// + // Test nested class access + if(Test_Nested(a.ClsPubInst.Cls2PubInst) != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + public static int Test_Nested(A.Cls.Cls2 Nested_Cls){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS NESTED FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + ///////////////////////////////// + // Test instance field access + Nested_Cls.Nest2FldPubInst = 100; + if(Nested_Cls.Nest2FldPubInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + A.Cls.Cls2.Nest2FldPubStat = 100; + if(A.Cls.Cls2.Nest2FldPubStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance method access + if(Nested_Cls.Nest2MethPubInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(A.Cls.Cls2.Nest2MethPubStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test virtual method access + if(Nested_Cls.Nest2MethPubVirt() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + if(Nested_Cls.Test() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } +} diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-6-3.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-6-3.csproj new file mode 100644 index 0000000000..67538ae3a1 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-6-3.csproj @@ -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>L-1-6-3</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-6-3.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <ProjectReference Include="L-1-6-3D.csproj" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-6-3D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-6-3D.cs new file mode 100644 index 0000000000..1e20d4d16f --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-6-3D.cs @@ -0,0 +1,408 @@ +// 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. + +#pragma warning disable 414 +using System; + + +public class A{ + ////////////////////////////// + // Instance Fields + public int FldPubInst; + private int FldPrivInst; + protected int FldFamInst; //Translates to "family" + internal int FldAsmInst; //Translates to "assembly" + protected internal int FldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int FldPubStat; + private static int FldPrivStat; + protected static int FldFamStat; //family + internal static int FldAsmStat; //assembly + protected internal static int FldFoaStat; //famorassem + + ////////////////////////////////////// + // Instance fields for nested classes + public Cls ClsPubInst = new Cls(); + private Cls ClsPrivInst = new Cls(); + protected Cls ClsFamInst = new Cls(); + internal Cls ClsAsmInst = new Cls(); + protected internal Cls ClsFoaInst = new Cls(); + + ///////////////////////////////////// + // Static fields of nested classes + public static Cls ClsPubStat = new Cls(); + private static Cls ClsPrivStat = new Cls(); + + ////////////////////////////// + // Instance Methods + public int MethPubInst(){ + Console.WriteLine("A::MethPubInst()"); + return 100; + } + + private int MethPrivInst(){ + Console.WriteLine("A::MethPrivInst()"); + return 100; + } + + protected int MethFamInst(){ + Console.WriteLine("A::MethFamInst()"); + return 100; + } + + internal int MethAsmInst(){ + Console.WriteLine("A::MethAsmInst()"); + return 100; + } + + protected internal int MethFoaInst(){ + Console.WriteLine("A::MethFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static Methods + public static int MethPubStat(){ + Console.WriteLine("A::MethPubStat()"); + return 100; + } + + private static int MethPrivStat(){ + Console.WriteLine("A::MethPrivStat()"); + return 100; + } + + protected static int MethFamStat(){ + Console.WriteLine("A::MethFamStat()"); + return 100; + } + + internal static int MethAsmStat(){ + Console.WriteLine("A::MethAsmStat()"); + return 100; + } + + protected internal static int MethFoaStat(){ + Console.WriteLine("A::MethFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance Methods + public virtual int MethPubVirt(){ + Console.WriteLine("A::MethPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing MethPrivVirt() here. + + protected virtual int MethFamVirt(){ + Console.WriteLine("A::MethFamVirt()"); + return 100; + } + + internal virtual int MethAsmVirt(){ + Console.WriteLine("A::MethAsmVirt()"); + return 100; + } + + protected internal virtual int MethFoaVirt(){ + Console.WriteLine("A::MethFoaVirt()"); + return 100; + } + + public class Cls{ + ////////////////////////////// + // Instance Fields + public int NestFldPubInst; + private int NestFldPrivInst; + protected int NestFldFamInst; //Translates to "family" + internal int NestFldAsmInst; //Translates to "assembly" + protected internal int NestFldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int NestFldPubStat; + private static int NestFldPrivStat; + protected static int NestFldFamStat; //family + internal static int NestFldAsmStat; //assembly + protected internal static int NestFldFoaStat; //famorassem + + ////////////////////////////////////// + // Instance fields for nested classes + public Cls2 Cls2PubInst = new Cls2(); + private Cls2 Cls2PrivInst = new Cls2(); + protected Cls2 Cls2FamInst = new Cls2(); + internal Cls2 Cls2AsmInst = new Cls2(); + protected internal Cls2 Cls2FoaInst = new Cls2(); + + ///////////////////////////////////// + // Static fields of nested classes + public static Cls ClsPubStat = new Cls(); + private static Cls ClsPrivStat = new Cls(); + + ////////////////////////////// + // Instance NestMethods + public int NestMethPubInst(){ + Console.WriteLine("A::NestMethPubInst()"); + return 100; + } + + private int NestMethPrivInst(){ + Console.WriteLine("A::NestMethPrivInst()"); + return 100; + } + + protected int NestMethFamInst(){ + Console.WriteLine("A::NestMethFamInst()"); + return 100; + } + + internal int NestMethAsmInst(){ + Console.WriteLine("A::NestMethAsmInst()"); + return 100; + } + + protected internal int NestMethFoaInst(){ + Console.WriteLine("A::NestMethFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethods + public static int NestMethPubStat(){ + Console.WriteLine("A::NestMethPubStat()"); + return 100; + } + + private static int NestMethPrivStat(){ + Console.WriteLine("A::NestMethPrivStat()"); + return 100; + } + + protected static int NestMethFamStat(){ + Console.WriteLine("A::NestMethFamStat()"); + return 100; + } + + internal static int NestMethAsmStat(){ + Console.WriteLine("A::NestMethAsmStat()"); + return 100; + } + + protected internal static int NestMethFoaStat(){ + Console.WriteLine("A::NestMethFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance NestMethods + public virtual int NestMethPubVirt(){ + Console.WriteLine("A::NestMethPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing NestMethPrivVirt() here. + + protected virtual int NestMethFamVirt(){ + Console.WriteLine("A::NestMethFamVirt()"); + return 100; + } + + internal virtual int NestMethAsmVirt(){ + Console.WriteLine("A::NestMethAsmVirt()"); + return 100; + } + + protected internal virtual int NestMethFoaVirt(){ + Console.WriteLine("A::NestMethFoaVirt()"); + return 100; + } + + + public class Cls2{ + public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS ENCLOSING FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + //@csharp - C# will not allow nested classes to access non-static members of their enclosing classes + + ///////////////////////////////// + // Test static field access + FldPubStat = 100; + if(FldPubStat != 100) + mi_RetCode = 0; + + FldFamStat = 100; + if(FldFamStat != 100) + mi_RetCode = 0; + + FldAsmStat = 100; + if(FldAsmStat != 100) + mi_RetCode = 0; + + FldFoaStat = 100; + if(FldFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethPubStat() != 100) + mi_RetCode = 0; + + if(MethFamStat() != 100) + mi_RetCode = 0; + + if(MethAsmStat() != 100) + mi_RetCode = 0; + + if(MethFoaStat() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + //@todo - Look at testing accessing one nested class from another, @bugug - NEED TO ADD SUCH TESTING, access the public nested class fields from here, etc... + + ///////////////////////////////// + // Test static field access + NestFldPubStat = 100; + if(NestFldPubStat != 100) + mi_RetCode = 0; + + NestFldFamStat = 100; + if(NestFldFamStat != 100) + mi_RetCode = 0; + + NestFldAsmStat = 100; + if(NestFldAsmStat != 100) + mi_RetCode = 0; + + NestFldFoaStat = 100; + if(NestFldFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(NestMethPubStat() != 100) + mi_RetCode = 0; + + if(NestMethFamStat() != 100) + mi_RetCode = 0; + + if(NestMethAsmStat() != 100) + mi_RetCode = 0; + + if(NestMethFoaStat() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + ////////////////////////////// + // Instance Fields + public int Nest2FldPubInst; + private int Nest2FldPrivInst; + protected int Nest2FldFamInst; //Translates to "family" + internal int Nest2FldAsmInst; //Translates to "assembly" + protected internal int Nest2FldFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int Nest2FldPubStat; + private static int Nest2FldPrivStat; + protected static int Nest2FldFamStat; //family + internal static int Nest2FldAsmStat; //assembly + protected internal static int Nest2FldFoaStat; //famorassem + + ////////////////////////////// + // Instance Nest2Methods + public int Nest2MethPubInst(){ + Console.WriteLine("A::Nest2MethPubInst()"); + return 100; + } + + private int Nest2MethPrivInst(){ + Console.WriteLine("A::Nest2MethPrivInst()"); + return 100; + } + + protected int Nest2MethFamInst(){ + Console.WriteLine("A::Nest2MethFamInst()"); + return 100; + } + + internal int Nest2MethAsmInst(){ + Console.WriteLine("A::Nest2MethAsmInst()"); + return 100; + } + + protected internal int Nest2MethFoaInst(){ + Console.WriteLine("A::Nest2MethFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static Nest2Methods + public static int Nest2MethPubStat(){ + Console.WriteLine("A::Nest2MethPubStat()"); + return 100; + } + + private static int Nest2MethPrivStat(){ + Console.WriteLine("A::Nest2MethPrivStat()"); + return 100; + } + + protected static int Nest2MethFamStat(){ + Console.WriteLine("A::Nest2MethFamStat()"); + return 100; + } + + internal static int Nest2MethAsmStat(){ + Console.WriteLine("A::Nest2MethAsmStat()"); + return 100; + } + + protected internal static int Nest2MethFoaStat(){ + Console.WriteLine("A::Nest2MethFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance Nest2Methods + public virtual int Nest2MethPubVirt(){ + Console.WriteLine("A::Nest2MethPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing Nest2MethPrivVirt() here. + + protected virtual int Nest2MethFamVirt(){ + Console.WriteLine("A::Nest2MethFamVirt()"); + return 100; + } + + internal virtual int Nest2MethAsmVirt(){ + Console.WriteLine("A::Nest2MethAsmVirt()"); + return 100; + } + + protected internal virtual int Nest2MethFoaVirt(){ + Console.WriteLine("A::Nest2MethFoaVirt()"); + return 100; + } + } + } +} + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-6-3D.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-6-3D.csproj new file mode 100644 index 0000000000..df5d38586d --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-6-3D.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-6-3D</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-6-3D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-7-1.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-7-1.cs new file mode 100644 index 0000000000..3c7c78f3dd --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-7-1.cs @@ -0,0 +1,977 @@ +// 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. + +////////////////////////////////////////////////////////// +// L-1-7-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 1-deep nesting in +// the same assembly and module (checking access from a +// class in the same family). +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +#pragma warning disable 414 +using System; + +class L171{ + public static int Main(){ + int mi_RetCode; + mi_RetCode = Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; + } + + public static int Test(){ + int mi_RetCode = 100; + + B.ClsB bc = new B.ClsB(); + A.ClsA ac = new A.ClsA(); + B b = new B(); + + if(Test_Nested(bc) != 100) + mi_RetCode = 0; + + if(Test_Nested(ac) != 100) + mi_RetCode = 0; + + //@csharp - C# simply won't compile non-related private/family/protected access + + if(Test_Nested(b.ClsAPubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsAAsmInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsAFoaInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(B.ClsAPubStat) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsBPubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsBAsmInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsBFoaInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(B.ClsBPubStat) != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + public static int Test_Nested(A.ClsA ac){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance field access + ac.NestFldAPubInst = 100; + if(ac.NestFldAPubInst != 100) + mi_RetCode = 0; + + ac.NestFldAAsmInst = 100; + if(ac.NestFldAAsmInst != 100) + mi_RetCode = 0; + + ac.NestFldAFoaInst = 100; + if(ac.NestFldAFoaInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + A.ClsA.NestFldAPubStat = 100; + if(A.ClsA.NestFldAPubStat != 100) + mi_RetCode = 0; + + A.ClsA.NestFldAAsmStat = 100; + if(A.ClsA.NestFldAAsmStat != 100) + mi_RetCode = 0; + + A.ClsA.NestFldAFoaStat = 100; + if(A.ClsA.NestFldAFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance MethAod access + if(ac.NestMethAPubInst() != 100) + mi_RetCode = 0; + + if(ac.NestMethAAsmInst() != 100) + mi_RetCode = 0; + + if(ac.NestMethAFoaInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static MethAod access + if(A.ClsA.NestMethAPubStat() != 100) + mi_RetCode = 0; + + if(A.ClsA.NestMethAAsmStat() != 100) + mi_RetCode = 0; + + if(A.ClsA.NestMethAFoaStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test virtual MethAod access + if(ac.NestMethAPubVirt() != 100) + mi_RetCode = 0; + + if(ac.NestMethAAsmVirt() != 100) + mi_RetCode = 0; + + if(ac.NestMethAFoaVirt() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + if(ac.Test() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + public static int Test_Nested(B.ClsB bc){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance field access + bc.NestFldBPubInst = 100; + if(bc.NestFldBPubInst != 100) + mi_RetCode = 0; + + bc.NestFldBAsmInst = 100; + if(bc.NestFldBAsmInst != 100) + mi_RetCode = 0; + + bc.NestFldBFoaInst = 100; + if(bc.NestFldBFoaInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + B.ClsB.NestFldBPubStat = 100; + if(B.ClsB.NestFldBPubStat != 100) + mi_RetCode = 0; + + B.ClsB.NestFldBAsmStat = 100; + if(B.ClsB.NestFldBAsmStat != 100) + mi_RetCode = 0; + + B.ClsB.NestFldBFoaStat = 100; + if(B.ClsB.NestFldBFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance method access + if(bc.NestMethBPubInst() != 100) + mi_RetCode = 0; + + if(bc.NestMethBAsmInst() != 100) + mi_RetCode = 0; + + if(bc.NestMethBFoaInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(B.ClsB.NestMethBPubStat() != 100) + mi_RetCode = 0; + + if(B.ClsB.NestMethBAsmStat() != 100) + mi_RetCode = 0; + + if(B.ClsB.NestMethBFoaStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test virtual method access + if(bc.NestMethBPubVirt() != 100) + mi_RetCode = 0; + + if(bc.NestMethBAsmVirt() != 100) + mi_RetCode = 0; + + if(bc.NestMethBFoaVirt() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + if(bc.Test() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + +} + +class A{ + ////////////////////////////// + // Instance Fields + public int FldAPubInst; + private int FldAPrivInst; + protected int FldAFamInst; //Translates to "family" + internal int FldAAsmInst; //Translates to "assembly" + protected internal int FldAFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int FldAPubStat; + private static int FldAPrivStat; + protected static int FldAFamStat; //family + internal static int FldAAsmStat; //assembly + protected internal static int FldAFoaStat; //famorassem + + ////////////////////////////////////// + // Instance fields for nested classes + public ClsA ClsAPubInst = new ClsA(); + private ClsA ClsAPrivInst = new ClsA(); + protected ClsA ClsAFamInst = new ClsA(); + internal ClsA ClsAAsmInst = new ClsA(); + protected internal ClsA ClsAFoaInst = new ClsA(); + + ///////////////////////////////////// + // Static fields of nested classes + public static ClsA ClsAPubStat = new ClsA(); + private static ClsA ClsAPrivStat = new ClsA(); + + ////////////////////////////// + // Instance Methods + public int MethAPubInst(){ + Console.WriteLine("A::MethAPubInst()"); + return 100; + } + + private int MethAPrivInst(){ + Console.WriteLine("A::MethAPrivInst()"); + return 100; + } + + protected int MethAFamInst(){ + Console.WriteLine("A::MethAFamInst()"); + return 100; + } + + internal int MethAAsmInst(){ + Console.WriteLine("A::MethAAsmInst()"); + return 100; + } + + protected internal int MethAFoaInst(){ + Console.WriteLine("A::MethAFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static Methods + public static int MethAPubStat(){ + Console.WriteLine("A::MethAPubStat()"); + return 100; + } + + private static int MethAPrivStat(){ + Console.WriteLine("A::MethAPrivStat()"); + return 100; + } + + protected static int MethAFamStat(){ + Console.WriteLine("A::MethAFamStat()"); + return 100; + } + + internal static int MethAAsmStat(){ + Console.WriteLine("A::MethAAsmStat()"); + return 100; + } + + protected internal static int MethAFoaStat(){ + Console.WriteLine("A::MethAFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance Methods + public virtual int MethAPubVirt(){ + Console.WriteLine("A::MethAPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing MethAPrivVirt() here. + + protected virtual int MethAFamVirt(){ + Console.WriteLine("A::MethAFamVirt()"); + return 100; + } + + internal virtual int MethAAsmVirt(){ + Console.WriteLine("A::MethAAsmVirt()"); + return 100; + } + + protected internal virtual int MethAFoaVirt(){ + Console.WriteLine("A::MethAFoaVirt()"); + return 100; + } + + public class ClsA{ + public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS ENCLOSING FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + //@csharp - C# will not allow nested classes to access non-static members of their enclosing classes + + ///////////////////////////////// + // Test static field access + FldAPubStat = 100; + if(FldAPubStat != 100) + mi_RetCode = 0; + + FldAFamStat = 100; + if(FldAFamStat != 100) + mi_RetCode = 0; + + FldAAsmStat = 100; + if(FldAAsmStat != 100) + mi_RetCode = 0; + + FldAFoaStat = 100; + if(FldAFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethAPubStat() != 100) + mi_RetCode = 0; + + if(MethAFamStat() != 100) + mi_RetCode = 0; + + if(MethAAsmStat() != 100) + mi_RetCode = 0; + + if(MethAFoaStat() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + + ////////////////////////////// + // Instance Fields + public int NestFldAPubInst; + private int NestFldAPrivInst; + protected int NestFldAFamInst; //Translates to "family" + internal int NestFldAAsmInst; //Translates to "assembly" + protected internal int NestFldAFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int NestFldAPubStat; + private static int NestFldAPrivStat; + protected static int NestFldAFamStat; //family + internal static int NestFldAAsmStat; //assembly + protected internal static int NestFldAFoaStat; //famorassem + + ////////////////////////////// + // Instance NestMethAods + public int NestMethAPubInst(){ + Console.WriteLine("A::NestMethAPubInst()"); + return 100; + } + + private int NestMethAPrivInst(){ + Console.WriteLine("A::NestMethAPrivInst()"); + return 100; + } + + protected int NestMethAFamInst(){ + Console.WriteLine("A::NestMethAFamInst()"); + return 100; + } + + internal int NestMethAAsmInst(){ + Console.WriteLine("A::NestMethAAsmInst()"); + return 100; + } + + protected internal int NestMethAFoaInst(){ + Console.WriteLine("A::NestMethAFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethods + public static int NestMethAPubStat(){ + Console.WriteLine("A::NestMethAPubStat()"); + return 100; + } + + private static int NestMethAPrivStat(){ + Console.WriteLine("A::NestMethAPrivStat()"); + return 100; + } + + protected static int NestMethAFamStat(){ + Console.WriteLine("A::NestMethAFamStat()"); + return 100; + } + + internal static int NestMethAAsmStat(){ + Console.WriteLine("A::NestMethAAsmStat()"); + return 100; + } + + protected internal static int NestMethAFoaStat(){ + Console.WriteLine("A::NestMethAFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance NestMethods + public virtual int NestMethAPubVirt(){ + Console.WriteLine("A::NestMethAPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing NestMethAPrivVirt() here. + + protected virtual int NestMethAFamVirt(){ + Console.WriteLine("A::NestMethAFamVirt()"); + return 100; + } + + internal virtual int NestMethAAsmVirt(){ + Console.WriteLine("A::NestMethAAsmVirt()"); + return 100; + } + + protected internal virtual int NestMethAFoaVirt(){ + Console.WriteLine("A::NestMethAFoaVirt()"); + return 100; + } + + } +} + + + +class B : A{ + public int Test(){ + A a = new A(); + + int mi_RetCode = 100; + + ///////////////////////////////// + // Test nested class access + if(Test_Nested(ClsAPubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsAFamInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsAAsmInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsAFoaInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsAPubStat) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsBPubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsBPrivInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsBFamInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsBAsmInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsBFoaInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsBPubStat) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsBPrivStat) != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + public int Test_Nested(ClsA Nested_Cls){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS NESTED FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + ///////////////////////////////// + // Test instance field access + Nested_Cls.NestFldAPubInst = 100; + if(Nested_Cls.NestFldAPubInst != 100) + mi_RetCode = 0; + + Nested_Cls.NestFldAAsmInst = 100; + if(Nested_Cls.NestFldAAsmInst != 100) + mi_RetCode = 0; + + Nested_Cls.NestFldAFoaInst = 100; + if(Nested_Cls.NestFldAFoaInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + A.ClsA.NestFldAPubStat = 100; + if(A.ClsA.NestFldAPubStat != 100) + mi_RetCode = 0; + + A.ClsA.NestFldAAsmStat = 100; + if(A.ClsA.NestFldAAsmStat != 100) + mi_RetCode = 0; + + A.ClsA.NestFldAFoaStat = 100; + if(A.ClsA.NestFldAFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance MethAod access + if(Nested_Cls.NestMethAPubInst() != 100) + mi_RetCode = 0; + + if(Nested_Cls.NestMethAAsmInst() != 100) + mi_RetCode = 0; + + if(Nested_Cls.NestMethAFoaInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static MethAod access + if(A.ClsA.NestMethAPubStat() != 100) + mi_RetCode = 0; + + if(A.ClsA.NestMethAAsmStat() != 100) + mi_RetCode = 0; + + if(A.ClsA.NestMethAFoaStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test virtual MethAod access + if(Nested_Cls.NestMethAPubVirt() != 100) + mi_RetCode = 0; + + if(Nested_Cls.NestMethAAsmVirt() != 100) + mi_RetCode = 0; + + if(Nested_Cls.NestMethAFoaVirt() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + if(Nested_Cls.Test() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + + public static int Test_Nested(ClsB Nested_Cls){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS NESTED FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + ///////////////////////////////// + // Test instance field access + Nested_Cls.NestFldBPubInst = 100; + if(Nested_Cls.NestFldBPubInst != 100) + mi_RetCode = 0; + + Nested_Cls.NestFldBAsmInst = 100; + if(Nested_Cls.NestFldBAsmInst != 100) + mi_RetCode = 0; + + Nested_Cls.NestFldBFoaInst = 100; + if(Nested_Cls.NestFldBFoaInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + B.ClsB.NestFldBPubStat = 100; + if(B.ClsB.NestFldBPubStat != 100) + mi_RetCode = 0; + + B.ClsB.NestFldBAsmStat = 100; + if(B.ClsB.NestFldBAsmStat != 100) + mi_RetCode = 0; + + B.ClsB.NestFldBFoaStat = 100; + if(B.ClsB.NestFldBFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance MethBod access + if(Nested_Cls.NestMethBPubInst() != 100) + mi_RetCode = 0; + + if(Nested_Cls.NestMethBAsmInst() != 100) + mi_RetCode = 0; + + if(Nested_Cls.NestMethBFoaInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static MethBod access + if(B.ClsB.NestMethBPubStat() != 100) + mi_RetCode = 0; + + if(B.ClsB.NestMethBAsmStat() != 100) + mi_RetCode = 0; + + if(B.ClsB.NestMethBFoaStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test virtual MethBod access + if(Nested_Cls.NestMethBPubVirt() != 100) + mi_RetCode = 0; + + if(Nested_Cls.NestMethBAsmVirt() != 100) + mi_RetCode = 0; + + if(Nested_Cls.NestMethBFoaVirt() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + if(Nested_Cls.Test() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + ////////////////////////////// + // Instance Fields + public int FldBPubInst; + private int FldBPrivInst; + protected int FldBFamInst; //Translates to "family" + internal int FldBAsmInst; //Translates to "assembly" + protected internal int FldBFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int FldBPubStat; + private static int FldBPrivStat; + protected static int FldBFamStat; //family + internal static int FldBAsmStat; //assembly + protected internal static int FldBFoaStat; //famorassem + + ////////////////////////////////////// + // Instance fields for nested classes + public ClsB ClsBPubInst = new ClsB(); + private ClsB ClsBPrivInst = new ClsB(); + protected ClsB ClsBFamInst = new ClsB(); + internal ClsB ClsBAsmInst = new ClsB(); + protected internal ClsB ClsBFoaInst = new ClsB(); + + ///////////////////////////////////// + // Static fields of nested classes + public static ClsB ClsBPubStat = new ClsB(); + private static ClsB ClsBPrivStat = new ClsB(); + + ////////////////////////////// + // Instance MethBods + public int MethBPubInst(){ + Console.WriteLine("B::MethBPubInst()"); + return 100; + } + + private int MethBPrivInst(){ + Console.WriteLine("B::MethBPrivInst()"); + return 100; + } + + protected int MethBFamInst(){ + Console.WriteLine("B::MethBFamInst()"); + return 100; + } + + internal int MethBAsmInst(){ + Console.WriteLine("B::MethBAsmInst()"); + return 100; + } + + protected internal int MethBFoaInst(){ + Console.WriteLine("B::MethBFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static MethBods + public static int MethBPubStat(){ + Console.WriteLine("B::MethBPubStat()"); + return 100; + } + + private static int MethBPrivStat(){ + Console.WriteLine("B::MethBPrivStat()"); + return 100; + } + + protected static int MethBFamStat(){ + Console.WriteLine("B::MethBFamStat()"); + return 100; + } + + internal static int MethBAsmStat(){ + Console.WriteLine("B::MethBAsmStat()"); + return 100; + } + + protected internal static int MethBFoaStat(){ + Console.WriteLine("B::MethBFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance MethBods + public virtual int MethBPubVirt(){ + Console.WriteLine("B::MethBPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing MethBPrivVirt() here. + + protected virtual int MethBFamVirt(){ + Console.WriteLine("B::MethBFamVirt()"); + return 100; + } + + internal virtual int MethBAsmVirt(){ + Console.WriteLine("B::MethBAsmVirt()"); + return 100; + } + + protected internal virtual int MethBFoaVirt(){ + Console.WriteLine("B::MethBFoaVirt()"); + return 100; + } + + public class ClsB{ + public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS ENCLOSING FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + //@csharp - C# will not allow nested classes to access non-static members of their enclosing classes + + ///////////////////////////////// + // Test static field access + FldBPubStat = 100; + if(FldBPubStat != 100) + mi_RetCode = 0; + + FldBFamStat = 100; + if(FldBFamStat != 100) + mi_RetCode = 0; + + FldBAsmStat = 100; + if(FldBAsmStat != 100) + mi_RetCode = 0; + + FldBFoaStat = 100; + if(FldBFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethBPubStat() != 100) + mi_RetCode = 0; + + if(MethBFamStat() != 100) + mi_RetCode = 0; + + if(MethBAsmStat() != 100) + mi_RetCode = 0; + + if(MethBFoaStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + FldAPubStat = 100; + if(FldAPubStat != 100) + mi_RetCode = 0; + + FldAFamStat = 100; + if(FldAFamStat != 100) + mi_RetCode = 0; + + FldAAsmStat = 100; + if(FldAAsmStat != 100) + mi_RetCode = 0; + + FldAFoaStat = 100; + if(FldAFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethAPubStat() != 100) + mi_RetCode = 0; + + if(MethAFamStat() != 100) + mi_RetCode = 0; + + if(MethAAsmStat() != 100) + mi_RetCode = 0; + + if(MethAFoaStat() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + if(ClsAPubStat.Test() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + ////////////////////////////// + // Instance Fields + public int NestFldBPubInst; + private int NestFldBPrivInst; + protected int NestFldBFamInst; //Translates to "family" + internal int NestFldBAsmInst; //Translates to "assembly" + protected internal int NestFldBFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int NestFldBPubStat; + private static int NestFldBPrivStat; + protected static int NestFldBFamStat; //family + internal static int NestFldBAsmStat; //assembly + protected internal static int NestFldBFoaStat; //famorassem + + ////////////////////////////// + // Instance NestMethods + public int NestMethBPubInst(){ + Console.WriteLine("B::NestMethBPubInst()"); + return 100; + } + + private int NestMethBPrivInst(){ + Console.WriteLine("B::NestMethBPrivInst()"); + return 100; + } + + protected int NestMethBFamInst(){ + Console.WriteLine("B::NestMethBFamInst()"); + return 100; + } + + internal int NestMethBAsmInst(){ + Console.WriteLine("B::NestMethBAsmInst()"); + return 100; + } + + protected internal int NestMethBFoaInst(){ + Console.WriteLine("B::NestMethBFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethBods + public static int NestMethBPubStat(){ + Console.WriteLine("B::NestMethBPubStat()"); + return 100; + } + + private static int NestMethBPrivStat(){ + Console.WriteLine("B::NestMethBPrivStat()"); + return 100; + } + + protected static int NestMethBFamStat(){ + Console.WriteLine("B::NestMethBFamStat()"); + return 100; + } + + internal static int NestMethBAsmStat(){ + Console.WriteLine("B::NestMethBAsmStat()"); + return 100; + } + + protected internal static int NestMethBFoaStat(){ + Console.WriteLine("B::NestMethBFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance NestMethods + public virtual int NestMethBPubVirt(){ + Console.WriteLine("B::NestMethBPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing NestMethBPrivVirt() here. + + protected virtual int NestMethBFamVirt(){ + Console.WriteLine("B::NestMethBFamVirt()"); + return 100; + } + + internal virtual int NestMethBAsmVirt(){ + Console.WriteLine("B::NestMethBAsmVirt()"); + return 100; + } + + protected internal virtual int NestMethBFoaVirt(){ + Console.WriteLine("B::NestMethBFoaVirt()"); + return 100; + } + + } +} + + + + + + + + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-7-1.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-7-1.csproj new file mode 100644 index 0000000000..e77c88baeb --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-7-1.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-7-1</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-7-1.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-7-2.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-7-2.csproj new file mode 100644 index 0000000000..b5ce444040 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-7-2.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-7-2</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-7-2D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-7-2D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-7-2D.cs new file mode 100644 index 0000000000..7086b9bba9 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-7-2D.cs @@ -0,0 +1,262 @@ +// 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. + +#pragma warning disable 414 +using System; + + +class A{ + ////////////////////////////// + // Instance Fields + public int FldAPubInst; + private int FldAPrivInst; + protected int FldAFamInst; //Translates to "family" + internal int FldAAsmInst; //Translates to "assembly" + protected internal int FldAFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int FldAPubStat; + private static int FldAPrivStat; + protected static int FldAFamStat; //family + internal static int FldAAsmStat; //assembly + protected internal static int FldAFoaStat; //famorassem + + ////////////////////////////////////// + // Instance fields for nested classes + public ClsA ClsAPubInst = new ClsA(); + private ClsA ClsAPrivInst = new ClsA(); + protected ClsA ClsAFamInst = new ClsA(); + internal ClsA ClsAAsmInst = new ClsA(); + protected internal ClsA ClsAFoaInst = new ClsA(); + + ///////////////////////////////////// + // Static fields of nested classes + public static ClsA ClsAPubStat = new ClsA(); + private static ClsA ClsAPrivStat = new ClsA(); + + ////////////////////////////// + // Instance Methods + public int MethAPubInst(){ + Console.WriteLine("A::MethAPubInst()"); + return 100; + } + + private int MethAPrivInst(){ + Console.WriteLine("A::MethAPrivInst()"); + return 100; + } + + protected int MethAFamInst(){ + Console.WriteLine("A::MethAFamInst()"); + return 100; + } + + internal int MethAAsmInst(){ + Console.WriteLine("A::MethAAsmInst()"); + return 100; + } + + protected internal int MethAFoaInst(){ + Console.WriteLine("A::MethAFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static Methods + public static int MethAPubStat(){ + Console.WriteLine("A::MethAPubStat()"); + return 100; + } + + private static int MethAPrivStat(){ + Console.WriteLine("A::MethAPrivStat()"); + return 100; + } + + protected static int MethAFamStat(){ + Console.WriteLine("A::MethAFamStat()"); + return 100; + } + + internal static int MethAAsmStat(){ + Console.WriteLine("A::MethAAsmStat()"); + return 100; + } + + protected internal static int MethAFoaStat(){ + Console.WriteLine("A::MethAFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance Methods + public virtual int MethAPubVirt(){ + Console.WriteLine("A::MethAPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing MethAPrivVirt() here. + + protected virtual int MethAFamVirt(){ + Console.WriteLine("A::MethAFamVirt()"); + return 100; + } + + internal virtual int MethAAsmVirt(){ + Console.WriteLine("A::MethAAsmVirt()"); + return 100; + } + + protected internal virtual int MethAFoaVirt(){ + Console.WriteLine("A::MethAFoaVirt()"); + return 100; + } + + public class ClsA{ + public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS ENCLOSING FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + //@csharp - C# will not allow nested classes to access non-static members of their enclosing classes + + ///////////////////////////////// + // Test static field access + FldAPubStat = 100; + if(FldAPubStat != 100) + mi_RetCode = 0; + + FldAFamStat = 100; + if(FldAFamStat != 100) + mi_RetCode = 0; + + FldAAsmStat = 100; + if(FldAAsmStat != 100) + mi_RetCode = 0; + + FldAFoaStat = 100; + if(FldAFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethAPubStat() != 100) + mi_RetCode = 0; + + if(MethAFamStat() != 100) + mi_RetCode = 0; + + if(MethAAsmStat() != 100) + mi_RetCode = 0; + + if(MethAFoaStat() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + + ////////////////////////////// + // Instance Fields + public int NestFldAPubInst; + private int NestFldAPrivInst; + protected int NestFldAFamInst; //Translates to "family" + internal int NestFldAAsmInst; //Translates to "assembly" + protected internal int NestFldAFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int NestFldAPubStat; + private static int NestFldAPrivStat; + protected static int NestFldAFamStat; //family + internal static int NestFldAAsmStat; //assembly + protected internal static int NestFldAFoaStat; //famorassem + + ////////////////////////////// + // Instance NestMethAods + public int NestMethAPubInst(){ + Console.WriteLine("A::NestMethAPubInst()"); + return 100; + } + + private int NestMethAPrivInst(){ + Console.WriteLine("A::NestMethAPrivInst()"); + return 100; + } + + protected int NestMethAFamInst(){ + Console.WriteLine("A::NestMethAFamInst()"); + return 100; + } + + internal int NestMethAAsmInst(){ + Console.WriteLine("A::NestMethAAsmInst()"); + return 100; + } + + protected internal int NestMethAFoaInst(){ + Console.WriteLine("A::NestMethAFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethods + public static int NestMethAPubStat(){ + Console.WriteLine("A::NestMethAPubStat()"); + return 100; + } + + private static int NestMethAPrivStat(){ + Console.WriteLine("A::NestMethAPrivStat()"); + return 100; + } + + protected static int NestMethAFamStat(){ + Console.WriteLine("A::NestMethAFamStat()"); + return 100; + } + + internal static int NestMethAAsmStat(){ + Console.WriteLine("A::NestMethAAsmStat()"); + return 100; + } + + protected internal static int NestMethAFoaStat(){ + Console.WriteLine("A::NestMethAFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance NestMethods + public virtual int NestMethAPubVirt(){ + Console.WriteLine("A::NestMethAPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing NestMethAPrivVirt() here. + + protected virtual int NestMethAFamVirt(){ + Console.WriteLine("A::NestMethAFamVirt()"); + return 100; + } + + internal virtual int NestMethAAsmVirt(){ + Console.WriteLine("A::NestMethAAsmVirt()"); + return 100; + } + + protected internal virtual int NestMethAFoaVirt(){ + Console.WriteLine("A::NestMethAFoaVirt()"); + return 100; + } + + } +} diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-7-3.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-7-3.cs new file mode 100644 index 0000000000..b6fe3a05e9 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-7-3.cs @@ -0,0 +1,639 @@ +// 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. + +////////////////////////////////////////////////////////// +// L-1-7-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 1-deep nesting in +// the same assembly and module (checking access from a +// class in the same family). +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +using System; + +class L171{ + public static int Main(){ + int mi_RetCode; + mi_RetCode = Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; + } + + public static int Test(){ + int mi_RetCode = 100; + + B.ClsB bc = new B.ClsB(); + A.ClsA ac = new A.ClsA(); + B b = new B(); + + if(Test_Nested(bc) != 100) + mi_RetCode = 0; + + if(Test_Nested(ac) != 100) + mi_RetCode = 0; + + //@csharp - C# simply won't compile non-related private/family/protected access + + if(Test_Nested(b.ClsAPubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(B.ClsAPubStat) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsBPubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsBAsmInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsBFoaInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(B.ClsBPubStat) != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + public static int Test_Nested(A.ClsA ac){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance field access + ac.NestFldAPubInst = 100; + if(ac.NestFldAPubInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + A.ClsA.NestFldAPubStat = 100; + if(A.ClsA.NestFldAPubStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance MethAod access + if(ac.NestMethAPubInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static MethAod access + if(A.ClsA.NestMethAPubStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test virtual MethAod access + if(ac.NestMethAPubVirt() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + if(ac.Test() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + public static int Test_Nested(B.ClsB bc){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance field access + bc.NestFldBPubInst = 100; + if(bc.NestFldBPubInst != 100) + mi_RetCode = 0; + + bc.NestFldBAsmInst = 100; + if(bc.NestFldBAsmInst != 100) + mi_RetCode = 0; + + bc.NestFldBFoaInst = 100; + if(bc.NestFldBFoaInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + B.ClsB.NestFldBPubStat = 100; + if(B.ClsB.NestFldBPubStat != 100) + mi_RetCode = 0; + + B.ClsB.NestFldBAsmStat = 100; + if(B.ClsB.NestFldBAsmStat != 100) + mi_RetCode = 0; + + B.ClsB.NestFldBFoaStat = 100; + if(B.ClsB.NestFldBFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance method access + if(bc.NestMethBPubInst() != 100) + mi_RetCode = 0; + + if(bc.NestMethBAsmInst() != 100) + mi_RetCode = 0; + + if(bc.NestMethBFoaInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(B.ClsB.NestMethBPubStat() != 100) + mi_RetCode = 0; + + if(B.ClsB.NestMethBAsmStat() != 100) + mi_RetCode = 0; + + if(B.ClsB.NestMethBFoaStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test virtual method access + if(bc.NestMethBPubVirt() != 100) + mi_RetCode = 0; + + if(bc.NestMethBAsmVirt() != 100) + mi_RetCode = 0; + + if(bc.NestMethBFoaVirt() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + if(bc.Test() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + +} + + +class B : A{ + public int Test(){ + A a = new A(); + + int mi_RetCode = 100; + + ///////////////////////////////// + // Test nested class access + if(Test_Nested(ClsAPubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsAFamInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsAFoaInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsAPubStat) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsBPubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsBPrivInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsBFamInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsBAsmInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsBFoaInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsBPubStat) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsBPrivStat) != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + public int Test_Nested(ClsA Nested_Cls){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS NESTED FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + ///////////////////////////////// + // Test instance field access + Nested_Cls.NestFldAPubInst = 100; + if(Nested_Cls.NestFldAPubInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + A.ClsA.NestFldAPubStat = 100; + if(A.ClsA.NestFldAPubStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance MethAod access + if(Nested_Cls.NestMethAPubInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static MethAod access + if(A.ClsA.NestMethAPubStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test virtual MethAod access + if(Nested_Cls.NestMethAPubVirt() != 100) + mi_RetCode = 0; + +//@csharp - @todo - @bugbug - This is coded poorly in L-1-7-3 and L-1-8-3, we should be able to access assembly and famorassem members, but because of they way it's coded that's illegal according to C#, fix this up + + //////////////////////////////////////////// + // Test access from within the nested class + if(Nested_Cls.Test() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + + public static int Test_Nested(ClsB Nested_Cls){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS NESTED FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + ///////////////////////////////// + // Test instance field access + Nested_Cls.NestFldBPubInst = 100; + if(Nested_Cls.NestFldBPubInst != 100) + mi_RetCode = 0; + + Nested_Cls.NestFldBAsmInst = 100; + if(Nested_Cls.NestFldBAsmInst != 100) + mi_RetCode = 0; + + Nested_Cls.NestFldBFoaInst = 100; + if(Nested_Cls.NestFldBFoaInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + B.ClsB.NestFldBPubStat = 100; + if(B.ClsB.NestFldBPubStat != 100) + mi_RetCode = 0; + + B.ClsB.NestFldBAsmStat = 100; + if(B.ClsB.NestFldBAsmStat != 100) + mi_RetCode = 0; + + B.ClsB.NestFldBFoaStat = 100; + if(B.ClsB.NestFldBFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance MethBod access + if(Nested_Cls.NestMethBPubInst() != 100) + mi_RetCode = 0; + + if(Nested_Cls.NestMethBAsmInst() != 100) + mi_RetCode = 0; + + if(Nested_Cls.NestMethBFoaInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static MethBod access + if(B.ClsB.NestMethBPubStat() != 100) + mi_RetCode = 0; + + if(B.ClsB.NestMethBAsmStat() != 100) + mi_RetCode = 0; + + if(B.ClsB.NestMethBFoaStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test virtual MethBod access + if(Nested_Cls.NestMethBPubVirt() != 100) + mi_RetCode = 0; + + if(Nested_Cls.NestMethBAsmVirt() != 100) + mi_RetCode = 0; + + if(Nested_Cls.NestMethBFoaVirt() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + if(Nested_Cls.Test() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + + ////////////////////////////// + // Instance Fields + public int FldBPubInst; + private int FldBPrivInst; + protected int FldBFamInst; //Translates to "family" + internal int FldBAsmInst; //Translates to "assembly" + protected internal int FldBFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int FldBPubStat; + private static int FldBPrivStat; + protected static int FldBFamStat; //family + internal static int FldBAsmStat; //assembly + protected internal static int FldBFoaStat; //famorassem + + ////////////////////////////////////// + // Instance fields for nested classes + public ClsB ClsBPubInst = new ClsB(); + private ClsB ClsBPrivInst = new ClsB(); + protected ClsB ClsBFamInst = new ClsB(); + internal ClsB ClsBAsmInst = new ClsB(); + protected internal ClsB ClsBFoaInst = new ClsB(); + + ///////////////////////////////////// + // Static fields of nested classes + public static ClsB ClsBPubStat = new ClsB(); + private static ClsB ClsBPrivStat = new ClsB(); + + ////////////////////////////// + // Instance MethBods + public int MethBPubInst(){ + Console.WriteLine("B::MethBPubInst()"); + return 100; + } + + private int MethBPrivInst(){ + Console.WriteLine("B::MethBPrivInst()"); + return 100; + } + + protected int MethBFamInst(){ + Console.WriteLine("B::MethBFamInst()"); + return 100; + } + + internal int MethBAsmInst(){ + Console.WriteLine("B::MethBAsmInst()"); + return 100; + } + + protected internal int MethBFoaInst(){ + Console.WriteLine("B::MethBFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static MethBods + public static int MethBPubStat(){ + Console.WriteLine("B::MethBPubStat()"); + return 100; + } + + private static int MethBPrivStat(){ + Console.WriteLine("B::MethBPrivStat()"); + return 100; + } + + protected static int MethBFamStat(){ + Console.WriteLine("B::MethBFamStat()"); + return 100; + } + + internal static int MethBAsmStat(){ + Console.WriteLine("B::MethBAsmStat()"); + return 100; + } + + protected internal static int MethBFoaStat(){ + Console.WriteLine("B::MethBFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance MethBods + public virtual int MethBPubVirt(){ + Console.WriteLine("B::MethBPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing MethBPrivVirt() here. + + protected virtual int MethBFamVirt(){ + Console.WriteLine("B::MethBFamVirt()"); + return 100; + } + + internal virtual int MethBAsmVirt(){ + Console.WriteLine("B::MethBAsmVirt()"); + return 100; + } + + protected internal virtual int MethBFoaVirt(){ + Console.WriteLine("B::MethBFoaVirt()"); + return 100; + } + + public class ClsB{ + public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS ENCLOSING FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + //@csharp - C# will not allow nested classes to access non-static members of their enclosing classes + + ///////////////////////////////// + // Test static field access + FldBPubStat = 100; + if(FldBPubStat != 100) + mi_RetCode = 0; + + FldBFamStat = 100; + if(FldBFamStat != 100) + mi_RetCode = 0; + + FldBAsmStat = 100; + if(FldBAsmStat != 100) + mi_RetCode = 0; + + FldBFoaStat = 100; + if(FldBFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethBPubStat() != 100) + mi_RetCode = 0; + + if(MethBFamStat() != 100) + mi_RetCode = 0; + + if(MethBAsmStat() != 100) + mi_RetCode = 0; + + if(MethBFoaStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + FldAPubStat = 100; + if(FldAPubStat != 100) + mi_RetCode = 0; + + FldAFamStat = 100; + if(FldAFamStat != 100) + mi_RetCode = 0; + + FldAFoaStat = 100; + if(FldAFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethAPubStat() != 100) + mi_RetCode = 0; + + if(MethAFamStat() != 100) + mi_RetCode = 0; + + if(MethAFoaStat() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + if(ClsAPubStat.Test() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + ////////////////////////////// + // Instance Fields + public int NestFldBPubInst; + private int NestFldBPrivInst; + protected int NestFldBFamInst; //Translates to "family" + internal int NestFldBAsmInst; //Translates to "assembly" + protected internal int NestFldBFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int NestFldBPubStat; + private static int NestFldBPrivStat; + protected static int NestFldBFamStat; //family + internal static int NestFldBAsmStat; //assembly + protected internal static int NestFldBFoaStat; //famorassem + + ////////////////////////////// + // Instance NestMethods + public int NestMethBPubInst(){ + Console.WriteLine("B::NestMethBPubInst()"); + return 100; + } + + private int NestMethBPrivInst(){ + Console.WriteLine("B::NestMethBPrivInst()"); + return 100; + } + + protected int NestMethBFamInst(){ + Console.WriteLine("B::NestMethBFamInst()"); + return 100; + } + + internal int NestMethBAsmInst(){ + Console.WriteLine("B::NestMethBAsmInst()"); + return 100; + } + + protected internal int NestMethBFoaInst(){ + Console.WriteLine("B::NestMethBFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethBods + public static int NestMethBPubStat(){ + Console.WriteLine("B::NestMethBPubStat()"); + return 100; + } + + private static int NestMethBPrivStat(){ + Console.WriteLine("B::NestMethBPrivStat()"); + return 100; + } + + protected static int NestMethBFamStat(){ + Console.WriteLine("B::NestMethBFamStat()"); + return 100; + } + + internal static int NestMethBAsmStat(){ + Console.WriteLine("B::NestMethBAsmStat()"); + return 100; + } + + protected internal static int NestMethBFoaStat(){ + Console.WriteLine("B::NestMethBFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance NestMethods + public virtual int NestMethBPubVirt(){ + Console.WriteLine("B::NestMethBPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing NestMethBPrivVirt() here. + + protected virtual int NestMethBFamVirt(){ + Console.WriteLine("B::NestMethBFamVirt()"); + return 100; + } + + internal virtual int NestMethBAsmVirt(){ + Console.WriteLine("B::NestMethBAsmVirt()"); + return 100; + } + + protected internal virtual int NestMethBFoaVirt(){ + Console.WriteLine("B::NestMethBFoaVirt()"); + return 100; + } + + } +} + + + + + + + + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-7-3.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-7-3.csproj new file mode 100644 index 0000000000..959c4e5662 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-7-3.csproj @@ -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>L-1-7-3</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-7-3.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <ProjectReference Include="L-1-7-3D.csproj" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-7-3D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-7-3D.cs new file mode 100644 index 0000000000..bea92d3d18 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-7-3D.cs @@ -0,0 +1,262 @@ +// 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. + +#pragma warning disable 414 +using System; + + +public class A{ + ////////////////////////////// + // Instance Fields + public int FldAPubInst; + private int FldAPrivInst; + protected int FldAFamInst; //Translates to "family" + internal int FldAAsmInst; //Translates to "assembly" + protected internal int FldAFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int FldAPubStat; + private static int FldAPrivStat; + protected static int FldAFamStat; //family + internal static int FldAAsmStat; //assembly + protected internal static int FldAFoaStat; //famorassem + + ////////////////////////////////////// + // Instance fields for nested classes + public ClsA ClsAPubInst = new ClsA(); + private ClsA ClsAPrivInst = new ClsA(); + protected ClsA ClsAFamInst = new ClsA(); + internal ClsA ClsAAsmInst = new ClsA(); + protected internal ClsA ClsAFoaInst = new ClsA(); + + ///////////////////////////////////// + // Static fields of nested classes + public static ClsA ClsAPubStat = new ClsA(); + private static ClsA ClsAPrivStat = new ClsA(); + + ////////////////////////////// + // Instance Methods + public int MethAPubInst(){ + Console.WriteLine("A::MethAPubInst()"); + return 100; + } + + private int MethAPrivInst(){ + Console.WriteLine("A::MethAPrivInst()"); + return 100; + } + + protected int MethAFamInst(){ + Console.WriteLine("A::MethAFamInst()"); + return 100; + } + + internal int MethAAsmInst(){ + Console.WriteLine("A::MethAAsmInst()"); + return 100; + } + + protected internal int MethAFoaInst(){ + Console.WriteLine("A::MethAFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static Methods + public static int MethAPubStat(){ + Console.WriteLine("A::MethAPubStat()"); + return 100; + } + + private static int MethAPrivStat(){ + Console.WriteLine("A::MethAPrivStat()"); + return 100; + } + + protected static int MethAFamStat(){ + Console.WriteLine("A::MethAFamStat()"); + return 100; + } + + internal static int MethAAsmStat(){ + Console.WriteLine("A::MethAAsmStat()"); + return 100; + } + + protected internal static int MethAFoaStat(){ + Console.WriteLine("A::MethAFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance Methods + public virtual int MethAPubVirt(){ + Console.WriteLine("A::MethAPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing MethAPrivVirt() here. + + protected virtual int MethAFamVirt(){ + Console.WriteLine("A::MethAFamVirt()"); + return 100; + } + + internal virtual int MethAAsmVirt(){ + Console.WriteLine("A::MethAAsmVirt()"); + return 100; + } + + protected internal virtual int MethAFoaVirt(){ + Console.WriteLine("A::MethAFoaVirt()"); + return 100; + } + + public class ClsA{ + public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS ENCLOSING FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + //@csharp - C# will not allow nested classes to access non-static members of their enclosing classes + + ///////////////////////////////// + // Test static field access + FldAPubStat = 100; + if(FldAPubStat != 100) + mi_RetCode = 0; + + FldAFamStat = 100; + if(FldAFamStat != 100) + mi_RetCode = 0; + + FldAAsmStat = 100; + if(FldAAsmStat != 100) + mi_RetCode = 0; + + FldAFoaStat = 100; + if(FldAFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethAPubStat() != 100) + mi_RetCode = 0; + + if(MethAFamStat() != 100) + mi_RetCode = 0; + + if(MethAAsmStat() != 100) + mi_RetCode = 0; + + if(MethAFoaStat() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + + ////////////////////////////// + // Instance Fields + public int NestFldAPubInst; + private int NestFldAPrivInst; + protected int NestFldAFamInst; //Translates to "family" + internal int NestFldAAsmInst; //Translates to "assembly" + protected internal int NestFldAFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int NestFldAPubStat; + private static int NestFldAPrivStat; + protected static int NestFldAFamStat; //family + internal static int NestFldAAsmStat; //assembly + protected internal static int NestFldAFoaStat; //famorassem + + ////////////////////////////// + // Instance NestMethAods + public int NestMethAPubInst(){ + Console.WriteLine("A::NestMethAPubInst()"); + return 100; + } + + private int NestMethAPrivInst(){ + Console.WriteLine("A::NestMethAPrivInst()"); + return 100; + } + + protected int NestMethAFamInst(){ + Console.WriteLine("A::NestMethAFamInst()"); + return 100; + } + + internal int NestMethAAsmInst(){ + Console.WriteLine("A::NestMethAAsmInst()"); + return 100; + } + + protected internal int NestMethAFoaInst(){ + Console.WriteLine("A::NestMethAFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethods + public static int NestMethAPubStat(){ + Console.WriteLine("A::NestMethAPubStat()"); + return 100; + } + + private static int NestMethAPrivStat(){ + Console.WriteLine("A::NestMethAPrivStat()"); + return 100; + } + + protected static int NestMethAFamStat(){ + Console.WriteLine("A::NestMethAFamStat()"); + return 100; + } + + internal static int NestMethAAsmStat(){ + Console.WriteLine("A::NestMethAAsmStat()"); + return 100; + } + + protected internal static int NestMethAFoaStat(){ + Console.WriteLine("A::NestMethAFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance NestMethods + public virtual int NestMethAPubVirt(){ + Console.WriteLine("A::NestMethAPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing NestMethAPrivVirt() here. + + protected virtual int NestMethAFamVirt(){ + Console.WriteLine("A::NestMethAFamVirt()"); + return 100; + } + + internal virtual int NestMethAAsmVirt(){ + Console.WriteLine("A::NestMethAAsmVirt()"); + return 100; + } + + protected internal virtual int NestMethAFoaVirt(){ + Console.WriteLine("A::NestMethAFoaVirt()"); + return 100; + } + + } +} diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-7-3D.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-7-3D.csproj new file mode 100644 index 0000000000..fffab84af3 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-7-3D.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-7-3D</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-7-3D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-8-1.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-8-1.cs new file mode 100644 index 0000000000..e1711af816 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-8-1.cs @@ -0,0 +1,1066 @@ +// 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. + +////////////////////////////////////////////////////////// +// L-1-8-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 2-deep nesting in +// the same assembly and module (checking access from a +// class in the same family). +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +#pragma warning disable 414 +using System; + +class L171{ + public static int Main(){ + int mi_RetCode; + mi_RetCode = Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; + } + + public static int Test(){ + int mi_RetCode = 100; + + B.ClsB.ClsB2 bc = new B.ClsB.ClsB2(); + A.ClsA.ClsA2 ac = new A.ClsA.ClsA2(); + B b = new B(); + + if(Test_Nested(bc) != 100) + mi_RetCode = 0; + + if(Test_Nested(ac) != 100) + mi_RetCode = 0; + + //@csharp - C# simply won't compile non-related private/family/protected access + + if(Test_Nested(b.ClsAPubInst.ClsA2PubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsAPubInst.ClsA2AsmInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsAPubInst.ClsA2FoaInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsAAsmInst.ClsA2PubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsAAsmInst.ClsA2AsmInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsAAsmInst.ClsA2FoaInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsAFoaInst.ClsA2PubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsAFoaInst.ClsA2AsmInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsAFoaInst.ClsA2FoaInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(B.ClsAPubStat.ClsA2PubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(B.ClsAPubStat.ClsA2AsmInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(B.ClsAPubStat.ClsA2FoaInst) != 100) + mi_RetCode = 0; + + //---------------------------------------------------- + + if(Test_Nested(b.ClsBPubInst.ClsB2PubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsBPubInst.ClsB2AsmInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsBPubInst.ClsB2FoaInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsBAsmInst.ClsB2PubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsBAsmInst.ClsB2AsmInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsBAsmInst.ClsB2FoaInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsBFoaInst.ClsB2PubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsBFoaInst.ClsB2AsmInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsBFoaInst.ClsB2FoaInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(B.ClsBPubStat.ClsB2PubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(B.ClsBPubStat.ClsB2AsmInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(B.ClsBPubStat.ClsB2FoaInst) != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + public static int Test_Nested(A.ClsA.ClsA2 ac){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance field access + ac.NestFldA2PubInst = 100; + if(ac.NestFldA2PubInst != 100) + mi_RetCode = 0; + + ac.NestFldA2AsmInst = 100; + if(ac.NestFldA2AsmInst != 100) + mi_RetCode = 0; + + ac.NestFldA2FoaInst = 100; + if(ac.NestFldA2FoaInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + A.ClsA.ClsA2.NestFldA2PubStat = 100; + if(A.ClsA.ClsA2.NestFldA2PubStat != 100) + mi_RetCode = 0; + + A.ClsA.ClsA2.NestFldA2AsmStat = 100; + if(A.ClsA.ClsA2.NestFldA2AsmStat != 100) + mi_RetCode = 0; + + A.ClsA.ClsA2.NestFldA2FoaStat = 100; + if(A.ClsA.ClsA2.NestFldA2FoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance MethA2od access + if(ac.NestMethA2PubInst() != 100) + mi_RetCode = 0; + + if(ac.NestMethA2AsmInst() != 100) + mi_RetCode = 0; + + if(ac.NestMethA2FoaInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static MethA2od access + if(A.ClsA.ClsA2.NestMethA2PubStat() != 100) + mi_RetCode = 0; + + if(A.ClsA.ClsA2.NestMethA2AsmStat() != 100) + mi_RetCode = 0; + + if(A.ClsA.ClsA2.NestMethA2FoaStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test virtual MethA2od access + if(ac.NestMethA2PubVirt() != 100) + mi_RetCode = 0; + + if(ac.NestMethA2AsmVirt() != 100) + mi_RetCode = 0; + + if(ac.NestMethA2FoaVirt() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + if(ac.Test() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + public static int Test_Nested(B.ClsB.ClsB2 bc){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance field access + bc.NestFldB2PubInst = 100; + if(bc.NestFldB2PubInst != 100) + mi_RetCode = 0; + + bc.NestFldB2AsmInst = 100; + if(bc.NestFldB2AsmInst != 100) + mi_RetCode = 0; + + bc.NestFldB2FoaInst = 100; + if(bc.NestFldB2FoaInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + B.ClsB.ClsB2.NestFldB2PubStat = 100; + if(B.ClsB.ClsB2.NestFldB2PubStat != 100) + mi_RetCode = 0; + + B.ClsB.ClsB2.NestFldB2AsmStat = 100; + if(B.ClsB.ClsB2.NestFldB2AsmStat != 100) + mi_RetCode = 0; + + B.ClsB.ClsB2.NestFldB2FoaStat = 100; + if(B.ClsB.ClsB2.NestFldB2FoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance method access + if(bc.NestMethB2PubInst() != 100) + mi_RetCode = 0; + + if(bc.NestMethB2AsmInst() != 100) + mi_RetCode = 0; + + if(bc.NestMethB2FoaInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(B.ClsB.ClsB2.NestMethB2PubStat() != 100) + mi_RetCode = 0; + + if(B.ClsB.ClsB2.NestMethB2AsmStat() != 100) + mi_RetCode = 0; + + if(B.ClsB.ClsB2.NestMethB2FoaStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test virtual method access + if(bc.NestMethB2PubVirt() != 100) + mi_RetCode = 0; + + if(bc.NestMethB2AsmVirt() != 100) + mi_RetCode = 0; + + if(bc.NestMethB2FoaVirt() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + if(bc.Test() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + +} + +class A{ + ////////////////////////////// + // Instance Fields + public int FldAPubInst; + private int FldAPrivInst; + protected int FldAFamInst; //Translates to "family" + internal int FldAAsmInst; //Translates to "assembly" + protected internal int FldAFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int FldAPubStat; + private static int FldAPrivStat; + protected static int FldAFamStat; //family + internal static int FldAAsmStat; //assembly + protected internal static int FldAFoaStat; //famorassem + + ////////////////////////////////////// + // Instance fields for nested classes + public ClsA ClsAPubInst = new ClsA(); + private ClsA ClsAPrivInst = new ClsA(); + protected ClsA ClsAFamInst = new ClsA(); + internal ClsA ClsAAsmInst = new ClsA(); + protected internal ClsA ClsAFoaInst = new ClsA(); + + ///////////////////////////////////// + // Static fields of nested classes + public static ClsA ClsAPubStat = new ClsA(); + private static ClsA ClsAPrivStat = new ClsA(); + + ////////////////////////////// + // Instance Methods + public int MethAPubInst(){ + Console.WriteLine("A::MethAPubInst()"); + return 100; + } + + private int MethAPrivInst(){ + Console.WriteLine("A::MethAPrivInst()"); + return 100; + } + + protected int MethAFamInst(){ + Console.WriteLine("A::MethAFamInst()"); + return 100; + } + + internal int MethAAsmInst(){ + Console.WriteLine("A::MethAAsmInst()"); + return 100; + } + + protected internal int MethAFoaInst(){ + Console.WriteLine("A::MethAFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static Methods + public static int MethAPubStat(){ + Console.WriteLine("A::MethAPubStat()"); + return 100; + } + + private static int MethAPrivStat(){ + Console.WriteLine("A::MethAPrivStat()"); + return 100; + } + + protected static int MethAFamStat(){ + Console.WriteLine("A::MethAFamStat()"); + return 100; + } + + internal static int MethAAsmStat(){ + Console.WriteLine("A::MethAAsmStat()"); + return 100; + } + + protected internal static int MethAFoaStat(){ + Console.WriteLine("A::MethAFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance Methods + public virtual int MethAPubVirt(){ + Console.WriteLine("A::MethAPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing MethAPrivVirt() here. + + protected virtual int MethAFamVirt(){ + Console.WriteLine("A::MethAFamVirt()"); + return 100; + } + + internal virtual int MethAAsmVirt(){ + Console.WriteLine("A::MethAAsmVirt()"); + return 100; + } + + protected internal virtual int MethAFoaVirt(){ + Console.WriteLine("A::MethAFoaVirt()"); + return 100; + } + + public class ClsA{ + ////////////////////////////// + // Instance Fields + public int NestFldAPubInst; + private int NestFldAPrivInst; + protected int NestFldAFamInst; //Translates to "family" + internal int NestFldAAsmInst; //Translates to "assembly" + protected internal int NestFldAFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int NestFldAPubStat; + private static int NestFldAPrivStat; + protected static int NestFldAFamStat; //family + internal static int NestFldAAsmStat; //assembly + protected internal static int NestFldAFoaStat; //famorassem + + ////////////////////////////////////// + // Instance fields for nested classes + public ClsA2 ClsA2PubInst = new ClsA2(); + private ClsA2 ClsA2PrivInst = new ClsA2(); + protected ClsA2 ClsA2FamInst = new ClsA2(); + internal ClsA2 ClsA2AsmInst = new ClsA2(); + protected internal ClsA2 ClsA2FoaInst = new ClsA2(); + + ///////////////////////////////////// + // Static fields of nested classes + public static ClsA2 ClsA2PubStat = new ClsA2(); + private static ClsA2 ClsA2PrivStat = new ClsA2(); + + ////////////////////////////// + // Instance NestMethAods + public int NestMethAPubInst(){ + Console.WriteLine("A::NestMethAPubInst()"); + return 100; + } + + private int NestMethAPrivInst(){ + Console.WriteLine("A::NestMethAPrivInst()"); + return 100; + } + + protected int NestMethAFamInst(){ + Console.WriteLine("A::NestMethAFamInst()"); + return 100; + } + + internal int NestMethAAsmInst(){ + Console.WriteLine("A::NestMethAAsmInst()"); + return 100; + } + + protected internal int NestMethAFoaInst(){ + Console.WriteLine("A::NestMethAFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethods + public static int NestMethAPubStat(){ + Console.WriteLine("A::NestMethAPubStat()"); + return 100; + } + + private static int NestMethAPrivStat(){ + Console.WriteLine("A::NestMethAPrivStat()"); + return 100; + } + + protected static int NestMethAFamStat(){ + Console.WriteLine("A::NestMethAFamStat()"); + return 100; + } + + internal static int NestMethAAsmStat(){ + Console.WriteLine("A::NestMethAAsmStat()"); + return 100; + } + + protected internal static int NestMethAFoaStat(){ + Console.WriteLine("A::NestMethAFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance NestMethods + public virtual int NestMethAPubVirt(){ + Console.WriteLine("A::NestMethAPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing NestMethAPrivVirt() here. + + protected virtual int NestMethAFamVirt(){ + Console.WriteLine("A::NestMethAFamVirt()"); + return 100; + } + + internal virtual int NestMethAAsmVirt(){ + Console.WriteLine("A::NestMethAAsmVirt()"); + return 100; + } + + protected internal virtual int NestMethAFoaVirt(){ + Console.WriteLine("A::NestMethAFoaVirt()"); + return 100; + } + + public class ClsA2{ + public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS ENCLOSING FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + //@csharp - C# will not allow nested classes to access non-static members of their enclosing classes + + ///////////////////////////////// + // Test static field access + NestFldA2PubStat = 100; + if(NestFldA2PubStat != 100) + mi_RetCode = 0; + + NestFldA2FamStat = 100; + if(NestFldA2FamStat != 100) + mi_RetCode = 0; + + NestFldA2AsmStat = 100; + if(NestFldA2AsmStat != 100) + mi_RetCode = 0; + + NestFldA2FoaStat = 100; + if(NestFldA2FoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(NestMethA2PubStat() != 100) + mi_RetCode = 0; + + if(NestMethA2FamStat() != 100) + mi_RetCode = 0; + + if(NestMethA2AsmStat() != 100) + mi_RetCode = 0; + + if(NestMethA2FoaStat() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + + ////////////////////////////// + // Instance Fields + public int NestFldA2PubInst; + private int NestFldA2PrivInst; + protected int NestFldA2FamInst; //Translates to "family" + internal int NestFldA2AsmInst; //Translates to "assembly" + protected internal int NestFldA2FoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int NestFldA2PubStat; + private static int NestFldA2PrivStat; + protected static int NestFldA2FamStat; //family + internal static int NestFldA2AsmStat; //assembly + protected internal static int NestFldA2FoaStat; //famorassem + + ////////////////////////////// + // Instance NestMethA2ods + public int NestMethA2PubInst(){ + Console.WriteLine("A::NestMethA2PubInst()"); + return 100; + } + + private int NestMethA2PrivInst(){ + Console.WriteLine("A::NestMethA2PrivInst()"); + return 100; + } + + protected int NestMethA2FamInst(){ + Console.WriteLine("A::NestMethA2FamInst()"); + return 100; + } + + internal int NestMethA2AsmInst(){ + Console.WriteLine("A::NestMethA2AsmInst()"); + return 100; + } + + protected internal int NestMethA2FoaInst(){ + Console.WriteLine("A::NestMethA2FoaInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethods + public static int NestMethA2PubStat(){ + Console.WriteLine("A::NestMethA2PubStat()"); + return 100; + } + + private static int NestMethA2PrivStat(){ + Console.WriteLine("A::NestMethA2PrivStat()"); + return 100; + } + + protected static int NestMethA2FamStat(){ + Console.WriteLine("A::NestMethA2FamStat()"); + return 100; + } + + internal static int NestMethA2AsmStat(){ + Console.WriteLine("A::NestMethA2AsmStat()"); + return 100; + } + + protected internal static int NestMethA2FoaStat(){ + Console.WriteLine("A::NestMethA2FoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance NestMethods + public virtual int NestMethA2PubVirt(){ + Console.WriteLine("A::NestMethA2PubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing NestMethA2PrivVirt() here. + + protected virtual int NestMethA2FamVirt(){ + Console.WriteLine("A::NestMethA2FamVirt()"); + return 100; + } + + internal virtual int NestMethA2AsmVirt(){ + Console.WriteLine("A::NestMethA2AsmVirt()"); + return 100; + } + + protected internal virtual int NestMethA2FoaVirt(){ + Console.WriteLine("A::NestMethA2FoaVirt()"); + return 100; + } + + } + } +} + + + +class B : A{ + ////////////////////////////// + // Instance Fields + public int FldBPubInst; + private int FldBPrivInst; + protected int FldBFamInst; //Translates to "family" + internal int FldBAsmInst; //Translates to "assembly" + protected internal int FldBFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int FldBPubStat; + private static int FldBPrivStat; + protected static int FldBFamStat; //family + internal static int FldBAsmStat; //assembly + protected internal static int FldBFoaStat; //famorassem + + ////////////////////////////////////// + // Instance fields for nested classes + public ClsB ClsBPubInst = new ClsB(); + private ClsB ClsBPrivInst = new ClsB(); + protected ClsB ClsBFamInst = new ClsB(); + internal ClsB ClsBAsmInst = new ClsB(); + protected internal ClsB ClsBFoaInst = new ClsB(); + + ///////////////////////////////////// + // Static fields of nested classes + public static ClsB ClsBPubStat = new ClsB(); + private static ClsB ClsBPrivStat = new ClsB(); + + ////////////////////////////// + // Instance MethBods + public int MethBPubInst(){ + Console.WriteLine("B::MethBPubInst()"); + return 100; + } + + private int MethBPrivInst(){ + Console.WriteLine("B::MethBPrivInst()"); + return 100; + } + + protected int MethBFamInst(){ + Console.WriteLine("B::MethBFamInst()"); + return 100; + } + + internal int MethBAsmInst(){ + Console.WriteLine("B::MethBAsmInst()"); + return 100; + } + + protected internal int MethBFoaInst(){ + Console.WriteLine("B::MethBFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static MethBods + public static int MethBPubStat(){ + Console.WriteLine("B::MethBPubStat()"); + return 100; + } + + private static int MethBPrivStat(){ + Console.WriteLine("B::MethBPrivStat()"); + return 100; + } + + protected static int MethBFamStat(){ + Console.WriteLine("B::MethBFamStat()"); + return 100; + } + + internal static int MethBAsmStat(){ + Console.WriteLine("B::MethBAsmStat()"); + return 100; + } + + protected internal static int MethBFoaStat(){ + Console.WriteLine("B::MethBFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance MethBods + public virtual int MethBPubVirt(){ + Console.WriteLine("B::MethBPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing MethBPrivVirt() here. + + protected virtual int MethBFamVirt(){ + Console.WriteLine("B::MethBFamVirt()"); + return 100; + } + + internal virtual int MethBAsmVirt(){ + Console.WriteLine("B::MethBAsmVirt()"); + return 100; + } + + protected internal virtual int MethBFoaVirt(){ + Console.WriteLine("B::MethBFoaVirt()"); + return 100; + } + + public class ClsB{ + ////////////////////////////// + // Instance Fields + public int NestFldBPubInst; + private int NestFldBPrivInst; + protected int NestFldBFamInst; //Translates to "family" + internal int NestFldBAsmInst; //Translates to "assembly" + protected internal int NestFldBFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int NestFldBPubStat; + private static int NestFldBPrivStat; + protected static int NestFldBFamStat; //family + internal static int NestFldBAsmStat; //assembly + protected internal static int NestFldBFoaStat; //famorassem + + ////////////////////////////////////// + // Instance fields for nested classes + public ClsB2 ClsB2PubInst = new ClsB2(); + private ClsB2 ClsB2PrivInst = new ClsB2(); + protected ClsB2 ClsB2FamInst = new ClsB2(); + internal ClsB2 ClsB2AsmInst = new ClsB2(); + protected internal ClsB2 ClsB2FoaInst = new ClsB2(); + + ///////////////////////////////////// + // Static fields of nested classes + public static ClsB2 ClsB2PubStat = new ClsB2(); + private static ClsB2 ClsB2PrivStat = new ClsB2(); + + ////////////////////////////// + // Instance NestMethods + public int NestMethBPubInst(){ + Console.WriteLine("B::NestMethBPubInst()"); + return 100; + } + + private int NestMethBPrivInst(){ + Console.WriteLine("B::NestMethBPrivInst()"); + return 100; + } + + protected int NestMethBFamInst(){ + Console.WriteLine("B::NestMethBFamInst()"); + return 100; + } + + internal int NestMethBAsmInst(){ + Console.WriteLine("B::NestMethBAsmInst()"); + return 100; + } + + protected internal int NestMethBFoaInst(){ + Console.WriteLine("B::NestMethBFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethBods + public static int NestMethBPubStat(){ + Console.WriteLine("B::NestMethBPubStat()"); + return 100; + } + + private static int NestMethBPrivStat(){ + Console.WriteLine("B::NestMethBPrivStat()"); + return 100; + } + + protected static int NestMethBFamStat(){ + Console.WriteLine("B::NestMethBFamStat()"); + return 100; + } + + internal static int NestMethBAsmStat(){ + Console.WriteLine("B::NestMethBAsmStat()"); + return 100; + } + + protected internal static int NestMethBFoaStat(){ + Console.WriteLine("B::NestMethBFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance NestMethods + public virtual int NestMethBPubVirt(){ + Console.WriteLine("B::NestMethBPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing NestMethBPrivVirt() here. + + protected virtual int NestMethBFamVirt(){ + Console.WriteLine("B::NestMethBFamVirt()"); + return 100; + } + + internal virtual int NestMethBAsmVirt(){ + Console.WriteLine("B::NestMethBAsmVirt()"); + return 100; + } + + protected internal virtual int NestMethBFoaVirt(){ + Console.WriteLine("B::NestMethBFoaVirt()"); + return 100; + } + + public class ClsB2{ + public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS ENCLOSING FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + //@csharp - C# will not allow nested classes to access non-static members of their enclosing classes + + ///////////////////////////////// + // Test static field access + FldBPubStat = 100; + if(FldBPubStat != 100) + mi_RetCode = 0; + + FldBFamStat = 100; + if(FldBFamStat != 100) + mi_RetCode = 0; + + FldBAsmStat = 100; + if(FldBAsmStat != 100) + mi_RetCode = 0; + + FldBFoaStat = 100; + if(FldBFoaStat != 100) + mi_RetCode = 0; + + NestFldBPubStat = 100; + if(NestFldBPubStat != 100) + mi_RetCode = 0; + + NestFldBFamStat = 100; + if(NestFldBFamStat != 100) + mi_RetCode = 0; + + NestFldBAsmStat = 100; + if(NestFldBAsmStat != 100) + mi_RetCode = 0; + + NestFldBFoaStat = 100; + if(NestFldBFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethBPubStat() != 100) + mi_RetCode = 0; + + if(MethBFamStat() != 100) + mi_RetCode = 0; + + if(MethBAsmStat() != 100) + mi_RetCode = 0; + + if(MethBFoaStat() != 100) + mi_RetCode = 0; + + if(NestMethBPubStat() != 100) + mi_RetCode = 0; + + if(NestMethBFamStat() != 100) + mi_RetCode = 0; + + if(NestMethBAsmStat() != 100) + mi_RetCode = 0; + + if(NestMethBFoaStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + FldAPubStat = 100; + if(FldAPubStat != 100) + mi_RetCode = 0; + + FldAFamStat = 100; + if(FldAFamStat != 100) + mi_RetCode = 0; + + FldAAsmStat = 100; + if(FldAAsmStat != 100) + mi_RetCode = 0; + + FldAFoaStat = 100; + if(FldAFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethAPubStat() != 100) + mi_RetCode = 0; + + if(MethAFamStat() != 100) + mi_RetCode = 0; + + if(MethAAsmStat() != 100) + mi_RetCode = 0; + + if(MethAFoaStat() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + //if(ClsAPubStat.ClsA2PubStat.Test() != 100) - @todo - Why won't this work? + // mi_RetCode = 0; + + return mi_RetCode; + } + + + ////////////////////////////// + // Instance Fields + public int NestFldB2PubInst; + private int NestFldB2PrivInst; + protected int NestFldB2FamInst; //Translates to "family" + internal int NestFldB2AsmInst; //Translates to "assembly" + protected internal int NestFldB2FoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int NestFldB2PubStat; + private static int NestFldB2PrivStat; + protected static int NestFldB2FamStat; //family + internal static int NestFldB2AsmStat; //assembly + protected internal static int NestFldB2FoaStat; //famorassem + + ////////////////////////////// + // Instance NestMethB2ods + public int NestMethB2PubInst(){ + Console.WriteLine("A::NestMethB2PubInst()"); + return 100; + } + + private int NestMethB2PrivInst(){ + Console.WriteLine("A::NestMethB2PrivInst()"); + return 100; + } + + protected int NestMethB2FamInst(){ + Console.WriteLine("A::NestMethB2FamInst()"); + return 100; + } + + internal int NestMethB2AsmInst(){ + Console.WriteLine("A::NestMethB2AsmInst()"); + return 100; + } + + protected internal int NestMethB2FoaInst(){ + Console.WriteLine("A::NestMethB2FoaInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethods + public static int NestMethB2PubStat(){ + Console.WriteLine("A::NestMethB2PubStat()"); + return 100; + } + + private static int NestMethB2PrivStat(){ + Console.WriteLine("A::NestMethB2PrivStat()"); + return 100; + } + + protected static int NestMethB2FamStat(){ + Console.WriteLine("A::NestMethB2FamStat()"); + return 100; + } + + internal static int NestMethB2AsmStat(){ + Console.WriteLine("A::NestMethB2AsmStat()"); + return 100; + } + + protected internal static int NestMethB2FoaStat(){ + Console.WriteLine("A::NestMethB2FoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance NestMethods + public virtual int NestMethB2PubVirt(){ + Console.WriteLine("A::NestMethB2PubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing NestMethB2PrivVirt() here. + + protected virtual int NestMethB2FamVirt(){ + Console.WriteLine("A::NestMethB2FamVirt()"); + return 100; + } + + internal virtual int NestMethB2AsmVirt(){ + Console.WriteLine("A::NestMethB2AsmVirt()"); + return 100; + } + + protected internal virtual int NestMethB2FoaVirt(){ + Console.WriteLine("A::NestMethB2FoaVirt()"); + return 100; + } + + } + + } +} diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-8-1.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-8-1.csproj new file mode 100644 index 0000000000..9fece6c58d --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-8-1.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-8-1</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-8-1.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-8-2.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-8-2.csproj new file mode 100644 index 0000000000..531162c6da --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-8-2.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-8-2</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-8-2D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-8-2D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-8-2D.cs new file mode 100644 index 0000000000..1fbbaa664d --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-8-2D.cs @@ -0,0 +1,373 @@ +// 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. + +#pragma warning disable 414 +using System; + + +class A{ + ////////////////////////////// + // Instance Fields + public int FldAPubInst; + private int FldAPrivInst; + protected int FldAFamInst; //Translates to "family" + internal int FldAAsmInst; //Translates to "assembly" + protected internal int FldAFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int FldAPubStat; + private static int FldAPrivStat; + protected static int FldAFamStat; //family + internal static int FldAAsmStat; //assembly + protected internal static int FldAFoaStat; //famorassem + + ////////////////////////////////////// + // Instance fields for nested classes + public ClsA ClsAPubInst = new ClsA(); + private ClsA ClsAPrivInst = new ClsA(); + protected ClsA ClsAFamInst = new ClsA(); + internal ClsA ClsAAsmInst = new ClsA(); + protected internal ClsA ClsAFoaInst = new ClsA(); + + ///////////////////////////////////// + // Static fields of nested classes + public static ClsA ClsAPubStat = new ClsA(); + private static ClsA ClsAPrivStat = new ClsA(); + + ////////////////////////////// + // Instance Methods + public int MethAPubInst(){ + Console.WriteLine("A::MethAPubInst()"); + return 100; + } + + private int MethAPrivInst(){ + Console.WriteLine("A::MethAPrivInst()"); + return 100; + } + + protected int MethAFamInst(){ + Console.WriteLine("A::MethAFamInst()"); + return 100; + } + + internal int MethAAsmInst(){ + Console.WriteLine("A::MethAAsmInst()"); + return 100; + } + + protected internal int MethAFoaInst(){ + Console.WriteLine("A::MethAFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static Methods + public static int MethAPubStat(){ + Console.WriteLine("A::MethAPubStat()"); + return 100; + } + + private static int MethAPrivStat(){ + Console.WriteLine("A::MethAPrivStat()"); + return 100; + } + + protected static int MethAFamStat(){ + Console.WriteLine("A::MethAFamStat()"); + return 100; + } + + internal static int MethAAsmStat(){ + Console.WriteLine("A::MethAAsmStat()"); + return 100; + } + + protected internal static int MethAFoaStat(){ + Console.WriteLine("A::MethAFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance Methods + public virtual int MethAPubVirt(){ + Console.WriteLine("A::MethAPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing MethAPrivVirt() here. + + protected virtual int MethAFamVirt(){ + Console.WriteLine("A::MethAFamVirt()"); + return 100; + } + + internal virtual int MethAAsmVirt(){ + Console.WriteLine("A::MethAAsmVirt()"); + return 100; + } + + protected internal virtual int MethAFoaVirt(){ + Console.WriteLine("A::MethAFoaVirt()"); + return 100; + } + + public class ClsA{ + ////////////////////////////// + // Instance Fields + public int NestFldAPubInst; + private int NestFldAPrivInst; + protected int NestFldAFamInst; //Translates to "family" + internal int NestFldAAsmInst; //Translates to "assembly" + protected internal int NestFldAFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int NestFldAPubStat; + private static int NestFldAPrivStat; + protected static int NestFldAFamStat; //family + internal static int NestFldAAsmStat; //assembly + protected internal static int NestFldAFoaStat; //famorassem + + ////////////////////////////////////// + // Instance fields for nested classes + public ClsA2 ClsA2PubInst = new ClsA2(); + private ClsA2 ClsA2PrivInst = new ClsA2(); + protected ClsA2 ClsA2FamInst = new ClsA2(); + internal ClsA2 ClsA2AsmInst = new ClsA2(); + protected internal ClsA2 ClsA2FoaInst = new ClsA2(); + + ///////////////////////////////////// + // Static fields of nested classes + public static ClsA2 ClsA2PubStat = new ClsA2(); + private static ClsA2 ClsA2PrivStat = new ClsA2(); + + ////////////////////////////// + // Instance NestMethAods + public int NestMethAPubInst(){ + Console.WriteLine("A::NestMethAPubInst()"); + return 100; + } + + private int NestMethAPrivInst(){ + Console.WriteLine("A::NestMethAPrivInst()"); + return 100; + } + + protected int NestMethAFamInst(){ + Console.WriteLine("A::NestMethAFamInst()"); + return 100; + } + + internal int NestMethAAsmInst(){ + Console.WriteLine("A::NestMethAAsmInst()"); + return 100; + } + + protected internal int NestMethAFoaInst(){ + Console.WriteLine("A::NestMethAFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethods + public static int NestMethAPubStat(){ + Console.WriteLine("A::NestMethAPubStat()"); + return 100; + } + + private static int NestMethAPrivStat(){ + Console.WriteLine("A::NestMethAPrivStat()"); + return 100; + } + + protected static int NestMethAFamStat(){ + Console.WriteLine("A::NestMethAFamStat()"); + return 100; + } + + internal static int NestMethAAsmStat(){ + Console.WriteLine("A::NestMethAAsmStat()"); + return 100; + } + + protected internal static int NestMethAFoaStat(){ + Console.WriteLine("A::NestMethAFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance NestMethods + public virtual int NestMethAPubVirt(){ + Console.WriteLine("A::NestMethAPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing NestMethAPrivVirt() here. + + protected virtual int NestMethAFamVirt(){ + Console.WriteLine("A::NestMethAFamVirt()"); + return 100; + } + + internal virtual int NestMethAAsmVirt(){ + Console.WriteLine("A::NestMethAAsmVirt()"); + return 100; + } + + protected internal virtual int NestMethAFoaVirt(){ + Console.WriteLine("A::NestMethAFoaVirt()"); + return 100; + } + + public class ClsA2{ + public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS ENCLOSING FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + //@csharp - C# will not allow nested classes to access non-static members of their enclosing classes + + ///////////////////////////////// + // Test static field access + NestFldA2PubStat = 100; + if(NestFldA2PubStat != 100) + mi_RetCode = 0; + + NestFldA2FamStat = 100; + if(NestFldA2FamStat != 100) + mi_RetCode = 0; + + NestFldA2AsmStat = 100; + if(NestFldA2AsmStat != 100) + mi_RetCode = 0; + + NestFldA2FoaStat = 100; + if(NestFldA2FoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(NestMethA2PubStat() != 100) + mi_RetCode = 0; + + if(NestMethA2FamStat() != 100) + mi_RetCode = 0; + + if(NestMethA2AsmStat() != 100) + mi_RetCode = 0; + + if(NestMethA2FoaStat() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + + ////////////////////////////// + // Instance Fields + public int NestFldA2PubInst; + private int NestFldA2PrivInst; + protected int NestFldA2FamInst; //Translates to "family" + internal int NestFldA2AsmInst; //Translates to "assembly" + protected internal int NestFldA2FoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int NestFldA2PubStat; + private static int NestFldA2PrivStat; + protected static int NestFldA2FamStat; //family + internal static int NestFldA2AsmStat; //assembly + protected internal static int NestFldA2FoaStat; //famorassem + + ////////////////////////////// + // Instance NestMethA2ods + public int NestMethA2PubInst(){ + Console.WriteLine("A::NestMethA2PubInst()"); + return 100; + } + + private int NestMethA2PrivInst(){ + Console.WriteLine("A::NestMethA2PrivInst()"); + return 100; + } + + protected int NestMethA2FamInst(){ + Console.WriteLine("A::NestMethA2FamInst()"); + return 100; + } + + internal int NestMethA2AsmInst(){ + Console.WriteLine("A::NestMethA2AsmInst()"); + return 100; + } + + protected internal int NestMethA2FoaInst(){ + Console.WriteLine("A::NestMethA2FoaInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethods + public static int NestMethA2PubStat(){ + Console.WriteLine("A::NestMethA2PubStat()"); + return 100; + } + + private static int NestMethA2PrivStat(){ + Console.WriteLine("A::NestMethA2PrivStat()"); + return 100; + } + + protected static int NestMethA2FamStat(){ + Console.WriteLine("A::NestMethA2FamStat()"); + return 100; + } + + internal static int NestMethA2AsmStat(){ + Console.WriteLine("A::NestMethA2AsmStat()"); + return 100; + } + + protected internal static int NestMethA2FoaStat(){ + Console.WriteLine("A::NestMethA2FoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance NestMethods + public virtual int NestMethA2PubVirt(){ + Console.WriteLine("A::NestMethA2PubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing NestMethA2PrivVirt() here. + + protected virtual int NestMethA2FamVirt(){ + Console.WriteLine("A::NestMethA2FamVirt()"); + return 100; + } + + internal virtual int NestMethA2AsmVirt(){ + Console.WriteLine("A::NestMethA2AsmVirt()"); + return 100; + } + + protected internal virtual int NestMethA2FoaVirt(){ + Console.WriteLine("A::NestMethA2FoaVirt()"); + return 100; + } + + } + } +} + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-8-3.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-8-3.cs new file mode 100644 index 0000000000..b224f900a6 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-8-3.cs @@ -0,0 +1,629 @@ +// 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. + +////////////////////////////////////////////////////////// +// L-1-8-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 2-deep nesting in +// the same assembly and module (checking access from a +// class in the same family). +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +#pragma warning disable 414 +using System; + +class L171{ + public static int Main(){ + int mi_RetCode; + mi_RetCode = Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; + } + + public static int Test(){ + int mi_RetCode = 100; + + B.ClsB.ClsB2 bc = new B.ClsB.ClsB2(); + A.ClsA.ClsA2 ac = new A.ClsA.ClsA2(); + B b = new B(); + + if(Test_Nested(bc) != 100) + mi_RetCode = 0; + + if(Test_Nested(ac) != 100) + mi_RetCode = 0; + + //@csharp - C# simply won't compile non-related private/family/protected access + + if(Test_Nested(b.ClsAPubInst.ClsA2PubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(B.ClsAPubStat.ClsA2PubInst) != 100) + mi_RetCode = 0; + + //---------------------------------------------------- + + if(Test_Nested(b.ClsBPubInst.ClsB2PubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsBPubInst.ClsB2AsmInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsBPubInst.ClsB2FoaInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsBAsmInst.ClsB2PubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsBAsmInst.ClsB2AsmInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsBAsmInst.ClsB2FoaInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsBFoaInst.ClsB2PubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsBFoaInst.ClsB2AsmInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(b.ClsBFoaInst.ClsB2FoaInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(B.ClsBPubStat.ClsB2PubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(B.ClsBPubStat.ClsB2AsmInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(B.ClsBPubStat.ClsB2FoaInst) != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + public static int Test_Nested(A.ClsA.ClsA2 ac){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance field access + ac.NestFldA2PubInst = 100; + if(ac.NestFldA2PubInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + A.ClsA.ClsA2.NestFldA2PubStat = 100; + if(A.ClsA.ClsA2.NestFldA2PubStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance MethA2od access + if(ac.NestMethA2PubInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static MethA2od access + if(A.ClsA.ClsA2.NestMethA2PubStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test virtual MethA2od access + if(ac.NestMethA2PubVirt() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + if(ac.Test() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + public static int Test_Nested(B.ClsB.ClsB2 bc){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance field access + bc.NestFldB2PubInst = 100; + if(bc.NestFldB2PubInst != 100) + mi_RetCode = 0; + + bc.NestFldB2AsmInst = 100; + if(bc.NestFldB2AsmInst != 100) + mi_RetCode = 0; + + bc.NestFldB2FoaInst = 100; + if(bc.NestFldB2FoaInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + B.ClsB.ClsB2.NestFldB2PubStat = 100; + if(B.ClsB.ClsB2.NestFldB2PubStat != 100) + mi_RetCode = 0; + + B.ClsB.ClsB2.NestFldB2AsmStat = 100; + if(B.ClsB.ClsB2.NestFldB2AsmStat != 100) + mi_RetCode = 0; + + B.ClsB.ClsB2.NestFldB2FoaStat = 100; + if(B.ClsB.ClsB2.NestFldB2FoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance method access + if(bc.NestMethB2PubInst() != 100) + mi_RetCode = 0; + + if(bc.NestMethB2AsmInst() != 100) + mi_RetCode = 0; + + if(bc.NestMethB2FoaInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(B.ClsB.ClsB2.NestMethB2PubStat() != 100) + mi_RetCode = 0; + + if(B.ClsB.ClsB2.NestMethB2AsmStat() != 100) + mi_RetCode = 0; + + if(B.ClsB.ClsB2.NestMethB2FoaStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test virtual method access + if(bc.NestMethB2PubVirt() != 100) + mi_RetCode = 0; + + if(bc.NestMethB2AsmVirt() != 100) + mi_RetCode = 0; + + if(bc.NestMethB2FoaVirt() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + if(bc.Test() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + +} + + +class B : A{ + ////////////////////////////// + // Instance Fields + public int FldBPubInst; + private int FldBPrivInst; + protected int FldBFamInst; //Translates to "family" + internal int FldBAsmInst; //Translates to "assembly" + protected internal int FldBFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int FldBPubStat; + private static int FldBPrivStat; + protected static int FldBFamStat; //family + internal static int FldBAsmStat; //assembly + protected internal static int FldBFoaStat; //famorassem + + ////////////////////////////////////// + // Instance fields for nested classes + public ClsB ClsBPubInst = new ClsB(); + private ClsB ClsBPrivInst = new ClsB(); + protected ClsB ClsBFamInst = new ClsB(); + internal ClsB ClsBAsmInst = new ClsB(); + protected internal ClsB ClsBFoaInst = new ClsB(); + + ///////////////////////////////////// + // Static fields of nested classes + public static ClsB ClsBPubStat = new ClsB(); + private static ClsB ClsBPrivStat = new ClsB(); + + ////////////////////////////// + // Instance MethBods + public int MethBPubInst(){ + Console.WriteLine("B::MethBPubInst()"); + return 100; + } + + private int MethBPrivInst(){ + Console.WriteLine("B::MethBPrivInst()"); + return 100; + } + + protected int MethBFamInst(){ + Console.WriteLine("B::MethBFamInst()"); + return 100; + } + + internal int MethBAsmInst(){ + Console.WriteLine("B::MethBAsmInst()"); + return 100; + } + + protected internal int MethBFoaInst(){ + Console.WriteLine("B::MethBFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static MethBods + public static int MethBPubStat(){ + Console.WriteLine("B::MethBPubStat()"); + return 100; + } + + private static int MethBPrivStat(){ + Console.WriteLine("B::MethBPrivStat()"); + return 100; + } + + protected static int MethBFamStat(){ + Console.WriteLine("B::MethBFamStat()"); + return 100; + } + + internal static int MethBAsmStat(){ + Console.WriteLine("B::MethBAsmStat()"); + return 100; + } + + protected internal static int MethBFoaStat(){ + Console.WriteLine("B::MethBFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance MethBods + public virtual int MethBPubVirt(){ + Console.WriteLine("B::MethBPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing MethBPrivVirt() here. + + protected virtual int MethBFamVirt(){ + Console.WriteLine("B::MethBFamVirt()"); + return 100; + } + + internal virtual int MethBAsmVirt(){ + Console.WriteLine("B::MethBAsmVirt()"); + return 100; + } + + protected internal virtual int MethBFoaVirt(){ + Console.WriteLine("B::MethBFoaVirt()"); + return 100; + } + + public class ClsB{ + ////////////////////////////// + // Instance Fields + public int NestFldBPubInst; + private int NestFldBPrivInst; + protected int NestFldBFamInst; //Translates to "family" + internal int NestFldBAsmInst; //Translates to "assembly" + protected internal int NestFldBFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int NestFldBPubStat; + private static int NestFldBPrivStat; + protected static int NestFldBFamStat; //family + internal static int NestFldBAsmStat; //assembly + protected internal static int NestFldBFoaStat; //famorassem + + ////////////////////////////////////// + // Instance fields for nested classes + public ClsB2 ClsB2PubInst = new ClsB2(); + private ClsB2 ClsB2PrivInst = new ClsB2(); + protected ClsB2 ClsB2FamInst = new ClsB2(); + internal ClsB2 ClsB2AsmInst = new ClsB2(); + protected internal ClsB2 ClsB2FoaInst = new ClsB2(); + + ///////////////////////////////////// + // Static fields of nested classes + public static ClsB2 ClsB2PubStat = new ClsB2(); + private static ClsB2 ClsB2PrivStat = new ClsB2(); + + ////////////////////////////// + // Instance NestMethods + public int NestMethBPubInst(){ + Console.WriteLine("B::NestMethBPubInst()"); + return 100; + } + + private int NestMethBPrivInst(){ + Console.WriteLine("B::NestMethBPrivInst()"); + return 100; + } + + protected int NestMethBFamInst(){ + Console.WriteLine("B::NestMethBFamInst()"); + return 100; + } + + internal int NestMethBAsmInst(){ + Console.WriteLine("B::NestMethBAsmInst()"); + return 100; + } + + protected internal int NestMethBFoaInst(){ + Console.WriteLine("B::NestMethBFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethBods + public static int NestMethBPubStat(){ + Console.WriteLine("B::NestMethBPubStat()"); + return 100; + } + + private static int NestMethBPrivStat(){ + Console.WriteLine("B::NestMethBPrivStat()"); + return 100; + } + + protected static int NestMethBFamStat(){ + Console.WriteLine("B::NestMethBFamStat()"); + return 100; + } + + internal static int NestMethBAsmStat(){ + Console.WriteLine("B::NestMethBAsmStat()"); + return 100; + } + + protected internal static int NestMethBFoaStat(){ + Console.WriteLine("B::NestMethBFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance NestMethods + public virtual int NestMethBPubVirt(){ + Console.WriteLine("B::NestMethBPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing NestMethBPrivVirt() here. + + protected virtual int NestMethBFamVirt(){ + Console.WriteLine("B::NestMethBFamVirt()"); + return 100; + } + + internal virtual int NestMethBAsmVirt(){ + Console.WriteLine("B::NestMethBAsmVirt()"); + return 100; + } + + protected internal virtual int NestMethBFoaVirt(){ + Console.WriteLine("B::NestMethBFoaVirt()"); + return 100; + } + + public class ClsB2{ + public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS ENCLOSING FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + //@csharp - C# will not allow nested classes to access non-static members of their enclosing classes + + ///////////////////////////////// + // Test static field access + FldBPubStat = 100; + if(FldBPubStat != 100) + mi_RetCode = 0; + + FldBFamStat = 100; + if(FldBFamStat != 100) + mi_RetCode = 0; + + FldBAsmStat = 100; + if(FldBAsmStat != 100) + mi_RetCode = 0; + + FldBFoaStat = 100; + if(FldBFoaStat != 100) + mi_RetCode = 0; + + NestFldBPubStat = 100; + if(NestFldBPubStat != 100) + mi_RetCode = 0; + + NestFldBFamStat = 100; + if(NestFldBFamStat != 100) + mi_RetCode = 0; + + NestFldBAsmStat = 100; + if(NestFldBAsmStat != 100) + mi_RetCode = 0; + + NestFldBFoaStat = 100; + if(NestFldBFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethBPubStat() != 100) + mi_RetCode = 0; + + if(MethBFamStat() != 100) + mi_RetCode = 0; + + if(MethBAsmStat() != 100) + mi_RetCode = 0; + + if(MethBFoaStat() != 100) + mi_RetCode = 0; + + if(NestMethBPubStat() != 100) + mi_RetCode = 0; + + if(NestMethBFamStat() != 100) + mi_RetCode = 0; + + if(NestMethBAsmStat() != 100) + mi_RetCode = 0; + + if(NestMethBFoaStat() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + FldAPubStat = 100; + if(FldAPubStat != 100) + mi_RetCode = 0; + + FldAFamStat = 100; + if(FldAFamStat != 100) + mi_RetCode = 0; + + FldAFoaStat = 100; + if(FldAFoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethAPubStat() != 100) + mi_RetCode = 0; + + if(MethAFamStat() != 100) + mi_RetCode = 0; + + if(MethAFoaStat() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + //if(ClsAPubStat.ClsA2PubStat.Test() != 100) - @todo - Why won't this work? + // mi_RetCode = 0; + + return mi_RetCode; + } + + + ////////////////////////////// + // Instance Fields + public int NestFldB2PubInst; + private int NestFldB2PrivInst; + protected int NestFldB2FamInst; //Translates to "family" + internal int NestFldB2AsmInst; //Translates to "assembly" + protected internal int NestFldB2FoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int NestFldB2PubStat; + private static int NestFldB2PrivStat; + protected static int NestFldB2FamStat; //family + internal static int NestFldB2AsmStat; //assembly + protected internal static int NestFldB2FoaStat; //famorassem + + ////////////////////////////// + // Instance NestMethB2ods + public int NestMethB2PubInst(){ + Console.WriteLine("A::NestMethB2PubInst()"); + return 100; + } + + private int NestMethB2PrivInst(){ + Console.WriteLine("A::NestMethB2PrivInst()"); + return 100; + } + + protected int NestMethB2FamInst(){ + Console.WriteLine("A::NestMethB2FamInst()"); + return 100; + } + + internal int NestMethB2AsmInst(){ + Console.WriteLine("A::NestMethB2AsmInst()"); + return 100; + } + + protected internal int NestMethB2FoaInst(){ + Console.WriteLine("A::NestMethB2FoaInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethods + public static int NestMethB2PubStat(){ + Console.WriteLine("A::NestMethB2PubStat()"); + return 100; + } + + private static int NestMethB2PrivStat(){ + Console.WriteLine("A::NestMethB2PrivStat()"); + return 100; + } + + protected static int NestMethB2FamStat(){ + Console.WriteLine("A::NestMethB2FamStat()"); + return 100; + } + + internal static int NestMethB2AsmStat(){ + Console.WriteLine("A::NestMethB2AsmStat()"); + return 100; + } + + protected internal static int NestMethB2FoaStat(){ + Console.WriteLine("A::NestMethB2FoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance NestMethods + public virtual int NestMethB2PubVirt(){ + Console.WriteLine("A::NestMethB2PubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing NestMethB2PrivVirt() here. + + protected virtual int NestMethB2FamVirt(){ + Console.WriteLine("A::NestMethB2FamVirt()"); + return 100; + } + + internal virtual int NestMethB2AsmVirt(){ + Console.WriteLine("A::NestMethB2AsmVirt()"); + return 100; + } + + protected internal virtual int NestMethB2FoaVirt(){ + Console.WriteLine("A::NestMethB2FoaVirt()"); + return 100; + } + + } + + } +} diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-8-3.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-8-3.csproj new file mode 100644 index 0000000000..ef190c8028 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-8-3.csproj @@ -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>L-1-8-3</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-8-3.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <ProjectReference Include="L-1-8-3D.csproj" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-8-3D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-8-3D.cs new file mode 100644 index 0000000000..72c9af82cd --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-8-3D.cs @@ -0,0 +1,373 @@ +// 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. + +#pragma warning disable 414 +using System; + + +public class A{ + ////////////////////////////// + // Instance Fields + public int FldAPubInst; + private int FldAPrivInst; + protected int FldAFamInst; //Translates to "family" + internal int FldAAsmInst; //Translates to "assembly" + protected internal int FldAFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int FldAPubStat; + private static int FldAPrivStat; + protected static int FldAFamStat; //family + internal static int FldAAsmStat; //assembly + protected internal static int FldAFoaStat; //famorassem + + ////////////////////////////////////// + // Instance fields for nested classes + public ClsA ClsAPubInst = new ClsA(); + private ClsA ClsAPrivInst = new ClsA(); + protected ClsA ClsAFamInst = new ClsA(); + internal ClsA ClsAAsmInst = new ClsA(); + protected internal ClsA ClsAFoaInst = new ClsA(); + + ///////////////////////////////////// + // Static fields of nested classes + public static ClsA ClsAPubStat = new ClsA(); + private static ClsA ClsAPrivStat = new ClsA(); + + ////////////////////////////// + // Instance Methods + public int MethAPubInst(){ + Console.WriteLine("A::MethAPubInst()"); + return 100; + } + + private int MethAPrivInst(){ + Console.WriteLine("A::MethAPrivInst()"); + return 100; + } + + protected int MethAFamInst(){ + Console.WriteLine("A::MethAFamInst()"); + return 100; + } + + internal int MethAAsmInst(){ + Console.WriteLine("A::MethAAsmInst()"); + return 100; + } + + protected internal int MethAFoaInst(){ + Console.WriteLine("A::MethAFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static Methods + public static int MethAPubStat(){ + Console.WriteLine("A::MethAPubStat()"); + return 100; + } + + private static int MethAPrivStat(){ + Console.WriteLine("A::MethAPrivStat()"); + return 100; + } + + protected static int MethAFamStat(){ + Console.WriteLine("A::MethAFamStat()"); + return 100; + } + + internal static int MethAAsmStat(){ + Console.WriteLine("A::MethAAsmStat()"); + return 100; + } + + protected internal static int MethAFoaStat(){ + Console.WriteLine("A::MethAFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance Methods + public virtual int MethAPubVirt(){ + Console.WriteLine("A::MethAPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing MethAPrivVirt() here. + + protected virtual int MethAFamVirt(){ + Console.WriteLine("A::MethAFamVirt()"); + return 100; + } + + internal virtual int MethAAsmVirt(){ + Console.WriteLine("A::MethAAsmVirt()"); + return 100; + } + + protected internal virtual int MethAFoaVirt(){ + Console.WriteLine("A::MethAFoaVirt()"); + return 100; + } + + public class ClsA{ + ////////////////////////////// + // Instance Fields + public int NestFldAPubInst; + private int NestFldAPrivInst; + protected int NestFldAFamInst; //Translates to "family" + internal int NestFldAAsmInst; //Translates to "assembly" + protected internal int NestFldAFoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int NestFldAPubStat; + private static int NestFldAPrivStat; + protected static int NestFldAFamStat; //family + internal static int NestFldAAsmStat; //assembly + protected internal static int NestFldAFoaStat; //famorassem + + ////////////////////////////////////// + // Instance fields for nested classes + public ClsA2 ClsA2PubInst = new ClsA2(); + private ClsA2 ClsA2PrivInst = new ClsA2(); + protected ClsA2 ClsA2FamInst = new ClsA2(); + internal ClsA2 ClsA2AsmInst = new ClsA2(); + protected internal ClsA2 ClsA2FoaInst = new ClsA2(); + + ///////////////////////////////////// + // Static fields of nested classes + public static ClsA2 ClsA2PubStat = new ClsA2(); + private static ClsA2 ClsA2PrivStat = new ClsA2(); + + ////////////////////////////// + // Instance NestMethAods + public int NestMethAPubInst(){ + Console.WriteLine("A::NestMethAPubInst()"); + return 100; + } + + private int NestMethAPrivInst(){ + Console.WriteLine("A::NestMethAPrivInst()"); + return 100; + } + + protected int NestMethAFamInst(){ + Console.WriteLine("A::NestMethAFamInst()"); + return 100; + } + + internal int NestMethAAsmInst(){ + Console.WriteLine("A::NestMethAAsmInst()"); + return 100; + } + + protected internal int NestMethAFoaInst(){ + Console.WriteLine("A::NestMethAFoaInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethods + public static int NestMethAPubStat(){ + Console.WriteLine("A::NestMethAPubStat()"); + return 100; + } + + private static int NestMethAPrivStat(){ + Console.WriteLine("A::NestMethAPrivStat()"); + return 100; + } + + protected static int NestMethAFamStat(){ + Console.WriteLine("A::NestMethAFamStat()"); + return 100; + } + + internal static int NestMethAAsmStat(){ + Console.WriteLine("A::NestMethAAsmStat()"); + return 100; + } + + protected internal static int NestMethAFoaStat(){ + Console.WriteLine("A::NestMethAFoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance NestMethods + public virtual int NestMethAPubVirt(){ + Console.WriteLine("A::NestMethAPubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing NestMethAPrivVirt() here. + + protected virtual int NestMethAFamVirt(){ + Console.WriteLine("A::NestMethAFamVirt()"); + return 100; + } + + internal virtual int NestMethAAsmVirt(){ + Console.WriteLine("A::NestMethAAsmVirt()"); + return 100; + } + + protected internal virtual int NestMethAFoaVirt(){ + Console.WriteLine("A::NestMethAFoaVirt()"); + return 100; + } + + public class ClsA2{ + public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS ENCLOSING FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + //@csharp - C# will not allow nested classes to access non-static members of their enclosing classes + + ///////////////////////////////// + // Test static field access + NestFldA2PubStat = 100; + if(NestFldA2PubStat != 100) + mi_RetCode = 0; + + NestFldA2FamStat = 100; + if(NestFldA2FamStat != 100) + mi_RetCode = 0; + + NestFldA2AsmStat = 100; + if(NestFldA2AsmStat != 100) + mi_RetCode = 0; + + NestFldA2FoaStat = 100; + if(NestFldA2FoaStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(NestMethA2PubStat() != 100) + mi_RetCode = 0; + + if(NestMethA2FamStat() != 100) + mi_RetCode = 0; + + if(NestMethA2AsmStat() != 100) + mi_RetCode = 0; + + if(NestMethA2FoaStat() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + + ////////////////////////////// + // Instance Fields + public int NestFldA2PubInst; + private int NestFldA2PrivInst; + protected int NestFldA2FamInst; //Translates to "family" + internal int NestFldA2AsmInst; //Translates to "assembly" + protected internal int NestFldA2FoaInst; //Translates to "famorassem" + + ////////////////////////////// + // Static Fields + public static int NestFldA2PubStat; + private static int NestFldA2PrivStat; + protected static int NestFldA2FamStat; //family + internal static int NestFldA2AsmStat; //assembly + protected internal static int NestFldA2FoaStat; //famorassem + + ////////////////////////////// + // Instance NestMethA2ods + public int NestMethA2PubInst(){ + Console.WriteLine("A::NestMethA2PubInst()"); + return 100; + } + + private int NestMethA2PrivInst(){ + Console.WriteLine("A::NestMethA2PrivInst()"); + return 100; + } + + protected int NestMethA2FamInst(){ + Console.WriteLine("A::NestMethA2FamInst()"); + return 100; + } + + internal int NestMethA2AsmInst(){ + Console.WriteLine("A::NestMethA2AsmInst()"); + return 100; + } + + protected internal int NestMethA2FoaInst(){ + Console.WriteLine("A::NestMethA2FoaInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethods + public static int NestMethA2PubStat(){ + Console.WriteLine("A::NestMethA2PubStat()"); + return 100; + } + + private static int NestMethA2PrivStat(){ + Console.WriteLine("A::NestMethA2PrivStat()"); + return 100; + } + + protected static int NestMethA2FamStat(){ + Console.WriteLine("A::NestMethA2FamStat()"); + return 100; + } + + internal static int NestMethA2AsmStat(){ + Console.WriteLine("A::NestMethA2AsmStat()"); + return 100; + } + + protected internal static int NestMethA2FoaStat(){ + Console.WriteLine("A::NestMethA2FoaStat()"); + return 100; + } + + ////////////////////////////// + // Virtual Instance NestMethods + public virtual int NestMethA2PubVirt(){ + Console.WriteLine("A::NestMethA2PubVirt()"); + return 100; + } + + //@csharp - Note that C# won't compile an illegal private virtual function + //So there is no negative testing NestMethA2PrivVirt() here. + + protected virtual int NestMethA2FamVirt(){ + Console.WriteLine("A::NestMethA2FamVirt()"); + return 100; + } + + internal virtual int NestMethA2AsmVirt(){ + Console.WriteLine("A::NestMethA2AsmVirt()"); + return 100; + } + + protected internal virtual int NestMethA2FoaVirt(){ + Console.WriteLine("A::NestMethA2FoaVirt()"); + return 100; + } + + } + } +} + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-8-3D.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-8-3D.csproj new file mode 100644 index 0000000000..c687d7eb66 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-8-3D.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-8-3D</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-8-3D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-9-1.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-9-1.cs new file mode 100644 index 0000000000..223fd7207b --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-9-1.cs @@ -0,0 +1,62 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +////////////////////////////////////////////////////////// +// L-1-9-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 1-deep implementation in +// the same assembly and module +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +//@csharp C# doesn't allow much flexibility here in terms of negative testing on interfaces... +//THIS NEEDS MORE COVERAGE + +using System; + +class Test{ +public static int Main(){ + int mi_RetCode; + B b = new B(); + mi_RetCode = b.Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; +} +} + +interface A{ + + ////////////////////////////// + // Instance Methods +int MethPubInst(); +} + +class B : A{ +public int MethPubInst(){ + Console.WriteLine("B::MethPubInst()"); + return 100; +} + +public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance method access + if(MethPubInst() != 100) + mi_RetCode = 0; + + return mi_RetCode; +} +} + + + + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-9-1.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-9-1.csproj new file mode 100644 index 0000000000..99beebe37a --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-9-1.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-9-1</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-9-1.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-9-2.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-9-2.csproj new file mode 100644 index 0000000000..e227927654 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-9-2.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-9-2</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-9-2D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-9-2D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-9-2D.cs new file mode 100644 index 0000000000..745f8da6cf --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-9-2D.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +interface A{ + + ////////////////////////////// + // Instance Methods +int MethPubInst(); +} + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-9-3.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-9-3.cs new file mode 100644 index 0000000000..5043a9e432 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-9-3.cs @@ -0,0 +1,55 @@ +// 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. + +////////////////////////////////////////////////////////// +// L-1-9-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 1-deep implementation in +// the same assembly and module +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +//@csharp C# doesn't allow much flexibility here in terms of negative testing on interfaces... +//THIS NEEDS MORE COVERAGE + +using System; + +class Test{ +public static int Main(){ + int mi_RetCode; + B b = new B(); + mi_RetCode = b.Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; +} +} + +class B : A{ +public int MethPubInst(){ + Console.WriteLine("B::MethPubInst()"); + return 100; +} + +public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance method access + if(MethPubInst() != 100) + mi_RetCode = 0; + + return mi_RetCode; +} +} + + + + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-9-3.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-9-3.csproj new file mode 100644 index 0000000000..161330898f --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-9-3.csproj @@ -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>L-1-9-3</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-9-3.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <ProjectReference Include="L-1-9-3D.csproj" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-9-3D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-9-3D.cs new file mode 100644 index 0000000000..ef3e1c468a --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-9-3D.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +public interface A{ + + ////////////////////////////// + // Instance Methods +int MethPubInst(); +} + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-9-3D.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-9-3D.csproj new file mode 100644 index 0000000000..f0a82522a8 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-1-9-3D.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-1-9-3D</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-9-3D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-10-1.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-10-1.cs new file mode 100644 index 0000000000..9b6a98a0a2 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-10-1.cs @@ -0,0 +1,71 @@ +// 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. + +////////////////////////////////////////////////////////// +// L-1-9-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 1-deep implementation in +// the same assembly and module +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +//@csharp C# doesn't allow much flexibility here in terms of negative testing on interfaces... +//THIS NEEDS MORE COVERAGE + +using System; + +class Test{ +public static int Main(){ + int mi_RetCode; + C c = new C(); + mi_RetCode = c.Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; +} +} + +interface A{ +int MethPubInst(); +} + +interface B : A{ +int MethPubInstB(); +} + +struct C : B{ +public int MethPubInst(){ + Console.WriteLine("B::MethPubInst()"); + return 100; +} + +public int MethPubInstB(){ + Console.WriteLine("B::MethPubInstB()"); + return 100; +} + +public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance method access + if(MethPubInst() != 100) + mi_RetCode = 0; + + if(MethPubInstB() != 100) + mi_RetCode = 0; + + return mi_RetCode; +} +} + + + + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-10-1.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-10-1.csproj new file mode 100644 index 0000000000..1909b439e3 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-10-1.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-2-10-1</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-2-10-1.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-10-2.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-10-2.csproj new file mode 100644 index 0000000000..9eef325b03 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-10-2.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-2-10-2</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-2-10-2D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-10-2D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-10-2D.cs new file mode 100644 index 0000000000..736ddcdeff --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-10-2D.cs @@ -0,0 +1,12 @@ +// 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. + +interface A{ +int MethPubInst(); +} + +interface B : A{ +int MethPubInstB(); +} + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-10-3.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-10-3.cs new file mode 100644 index 0000000000..6198303833 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-10-3.cs @@ -0,0 +1,63 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +////////////////////////////////////////////////////////// +// L-1-9-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 1-deep implementation in +// the same assembly and module +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +//@csharp C# doesn't allow much flexibility here in terms of negative testing on interfaces... +//THIS NEEDS MORE COVERAGE + +using System; + +class Test{ +public static int Main(){ + int mi_RetCode; + C c = new C(); + mi_RetCode = c.Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; +} +} + +struct C : B{ +public int MethPubInst(){ + Console.WriteLine("B::MethPubInst()"); + return 100; +} + +public int MethPubInstB(){ + Console.WriteLine("B::MethPubInstB()"); + return 100; +} + +public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance method access + if(MethPubInst() != 100) + mi_RetCode = 0; + + if(MethPubInstB() != 100) + mi_RetCode = 0; + + return mi_RetCode; +} +} + + + + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-10-3.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-10-3.csproj new file mode 100644 index 0000000000..1daf7e7e3d --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-10-3.csproj @@ -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>L-2-10-3</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-2-10-3.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <ProjectReference Include="L-2-10-3D.csproj" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-10-3D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-10-3D.cs new file mode 100644 index 0000000000..62199596fb --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-10-3D.cs @@ -0,0 +1,12 @@ +// 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. + +public interface A{ +int MethPubInst(); +} + +public interface B : A{ +int MethPubInstB(); +} + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-10-3D.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-10-3D.csproj new file mode 100644 index 0000000000..886ba405d7 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-10-3D.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-2-10-3D</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-2-10-3D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-11-1.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-11-1.cs new file mode 100644 index 0000000000..7a4e5027c9 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-11-1.cs @@ -0,0 +1,259 @@ +// 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. + +////////////////////////////////////////////////////////// +// L-1-11-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes two unrelated classes in +// the same assembly and module +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +using System; + +class Test{ +public static int Main(){ + int mi_RetCode = 100; + A a = new A(); + B b = new B(); + + if(a.Test(b) != 100) + mi_RetCode = 0; + + if(b.Test(a) != 100) + mi_RetCode = 0; + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; +} +} + +struct A{ +public int Test(B b){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance field access + b.FldPubInst = 100; + if(b.FldPubInst != 100) + mi_RetCode = 0; + + //@csharp - Note that C# will not compile an illegal access of b.FldPrivInst + //So there is no negative test here, it should be covered elsewhere and + //should throw a FielAccessException within the runtime. (IL sources is + //the most logical, only?, choice) + + //@csharp - C# Won't compile illegal family access from non-family members + + b.FldAsmInst = 100; + if(b.FldAsmInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + B.FldPubStat = 100; + if(B.FldPubStat != 100) + mi_RetCode = 0; + + //@csharp - Again, note C# won't do private field access + + //@csharp - C# Won't compile illegal family access from non-family members + + B.FldAsmStat = 100; + if(B.FldAsmStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance b.Method access + if(b.MethPubInst() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private b.Method access + + //@csharp - C# Won't compile illegal family access from non-family members + + if(b.MethAsmInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static b.Method access + if(B.MethPubStat() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private b.Method access + + //@csharp - C# Won't compile illegal family access from non-family members + + if(B.MethAsmStat() != 100) + mi_RetCode = 0; + + return mi_RetCode; +} + + ////////////////////////////// + // Instance Fields +public int FldPubInst; +private int FldPrivInst; +internal int FldAsmInst; //Translates to "assembly" + + ////////////////////////////// + // Static Fields +public static int FldPubStat; +private static int FldPrivStat; +internal static int FldAsmStat; //assembly + + ////////////////////////////// + // Instance Methods +public int MethPubInst(){ + Console.WriteLine("A::MethPubInst()"); + return 100; +} + +private int MethPrivInst(){ + Console.WriteLine("A::MethPrivInst()"); + return 100; +} + +internal int MethAsmInst(){ + Console.WriteLine("A::MethAsmInst()"); + return 100; +} + + ////////////////////////////// + // Static Methods +public static int MethPubStat(){ + Console.WriteLine("A::MethPubStat()"); + return 100; +} + +private static int MethPrivStat(){ + Console.WriteLine("A::MethPrivStat()"); + return 100; +} + +internal static int MethAsmStat(){ + Console.WriteLine("A::MethAsmStat()"); + return 100; +} +} + +struct B{ +public int Test(A a){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance field access + a.FldPubInst = 100; + if(a.FldPubInst != 100) + mi_RetCode = 0; + + //@csharp - Note that C# will not compile an illegal access of a.FldPrivInst + //So there is no negative test here, it should be covered elsewhere and + //should throw a FielAccessException within the runtime. (IL sources is + //the most logical, only?, choice) + + //@csharp - C# Won't compile illegal family access from non-family members + + a.FldAsmInst = 100; + if(a.FldAsmInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + A.FldPubStat = 100; + if(A.FldPubStat != 100) + mi_RetCode = 0; + + //@csharp - Again, note C# won't do private field access + + //@csharp - C# Won't compile illegal family access from non-family members + + A.FldAsmStat = 100; + if(A.FldAsmStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance a.Method access + if(a.MethPubInst() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private a.Method access + + //@csharp - C# Won't compile illegal family access from non-family members + + if(a.MethAsmInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static a.Method access + if(A.MethPubStat() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private a.Method access + + //@csharp - C# Won't compile illegal family access from non-family members + + if(A.MethAsmStat() != 100) + mi_RetCode = 0; + + return mi_RetCode; +} + + + ////////////////////////////// + // Instance Fields +public int FldPubInst; +private int FldPrivInst; +internal int FldAsmInst; //Translates to "assembly" + + ////////////////////////////// + // Static Fields +public static int FldPubStat; +private static int FldPrivStat; +internal static int FldAsmStat; //assembly + + ////////////////////////////// + // Instance Methods +public int MethPubInst(){ + Console.WriteLine("B::MethPubInst()"); + return 100; +} + +private int MethPrivInst(){ + Console.WriteLine("B::MethPrivInst()"); + return 100; +} + +internal int MethAsmInst(){ + Console.WriteLine("B::MethAsmInst()"); + return 100; +} + + ////////////////////////////// + // Static Methods +public static int MethPubStat(){ + Console.WriteLine("B::MethPubStat()"); + return 100; +} + +private static int MethPrivStat(){ + Console.WriteLine("B::MethPrivStat()"); + return 100; +} + +internal static int MethAsmStat(){ + Console.WriteLine("B::MethAsmStat()"); + return 100; +} +} + + + + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-11-1.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-11-1.csproj new file mode 100644 index 0000000000..12eebfa587 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-11-1.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-2-11-1</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-2-11-1.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-11-2.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-11-2.csproj new file mode 100644 index 0000000000..c30aac1fa6 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-11-2.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-2-11-2</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-1-11-2D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-11-3.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-11-3.cs new file mode 100644 index 0000000000..e14f90e8ca --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-11-3.cs @@ -0,0 +1,137 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +////////////////////////////////////////////////////////// +// L-1-11-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes two unrelated classes in +// the same assembly and module +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +using System; + +class Test{ +public static int Main(){ + int mi_RetCode = 100; + A a = new A(); + B b = new B(); + +// if(a.Test(b) != 100) +// mi_RetCode = 0; + + if(b.Test(a) != 100) + mi_RetCode = 0; + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; +} +} + + +struct B{ +public int Test(A a){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance field access + a.FldPubInst = 100; + if(a.FldPubInst != 100) + mi_RetCode = 0; + + //@csharp - Note that C# will not compile an illegal access of a.FldPrivInst + //So there is no negative test here, it should be covered elsewhere and + //should throw a FielAccessException within the runtime. (IL sources is + //the most logical, only?, choice) + + //@csharp - C# Won't compile illegal family access from non-family members + + ///////////////////////////////// + // Test static field access + A.FldPubStat = 100; + if(A.FldPubStat != 100) + mi_RetCode = 0; + + //@csharp - Again, note C# won't do private field access + + //@csharp - C# Won't compile illegal family access from non-family members + + ///////////////////////////////// + // Test instance a.Method access + if(a.MethPubInst() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private a.Method access + + //@csharp - C# Won't compile illegal family access from non-family members + + ///////////////////////////////// + // Test static a.Method access + if(A.MethPubStat() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private a.Method access + + //@csharp - C# Won't compile illegal family access from non-family members + + return mi_RetCode; +} + + + ////////////////////////////// + // Instance Fields +public int FldPubInst; +private int FldPrivInst; +internal int FldAsmInst; //Translates to "assembly" + + ////////////////////////////// + // Static Fields +public static int FldPubStat; +private static int FldPrivStat; +internal static int FldAsmStat; //assembly + + ////////////////////////////// + // Instance Methods +public int MethPubInst(){ + Console.WriteLine("B::MethPubInst()"); + return 100; +} + +private int MethPrivInst(){ + Console.WriteLine("B::MethPrivInst()"); + return 100; +} + +internal int MethAsmInst(){ + Console.WriteLine("B::MethAsmInst()"); + return 100; +} + + ////////////////////////////// + // Static Methods +public static int MethPubStat(){ + Console.WriteLine("B::MethPubStat()"); + return 100; +} + +private static int MethPrivStat(){ + Console.WriteLine("B::MethPrivStat()"); + return 100; +} + +internal static int MethAsmStat(){ + Console.WriteLine("B::MethAsmStat()"); + return 100; +} +} + + + + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-11-3.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-11-3.csproj new file mode 100644 index 0000000000..b018102645 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-11-3.csproj @@ -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>L-2-11-3</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-2-11-3.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <ProjectReference Include="L-2-11-3D.csproj" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-11-3D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-11-3D.cs new file mode 100644 index 0000000000..095ba0f8ab --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-11-3D.cs @@ -0,0 +1,114 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +public struct A{ +/*public int Test(B b){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance field access + b.FldPubInst = 100; + if(b.FldPubInst != 100) + mi_RetCode = 0; + + //@csharp - Note that C# will not compile an illegal access of b.FldPrivInst + //So there is no negative test here, it should be covered elsewhere and + //should throw a FielAccessException within the runtime. (IL sources is + //the most logical, only?, choice) + + //@csharp - C# Won't compile illegal family access from non-family members + + b.FldAsmInst = 100; + if(b.FldAsmInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + B.FldPubStat = 100; + if(B.FldPubStat != 100) + mi_RetCode = 0; + + //@csharp - Again, note C# won't do private field access + + //@csharp - C# Won't compile illegal family access from non-family members + + B.FldAsmStat = 100; + if(B.FldAsmStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance b.Method access + if(b.MethPubInst() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private b.Method access + + //@csharp - C# Won't compile illegal family access from non-family members + + if(b.MethAsmInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static b.Method access + if(B.MethPubStat() != 100) + mi_RetCode = 0; + + //@csharp - C# won't do private b.Method access + + //@csharp - C# Won't compile illegal family access from non-family members + + if(B.MethAsmStat() != 100) + mi_RetCode = 0; + + return mi_RetCode; +} +*/ + ////////////////////////////// + // Instance Fields +public int FldPubInst; +private int FldPrivInst; +internal int FldAsmInst; //Translates to "assembly" + + ////////////////////////////// + // Static Fields +public static int FldPubStat; +private static int FldPrivStat; +internal static int FldAsmStat; //assembly + + ////////////////////////////// + // Instance Methods +public int MethPubInst(){ + Console.WriteLine("A::MethPubInst()"); + return 100; +} + +private int MethPrivInst(){ + Console.WriteLine("A::MethPrivInst()"); + return 100; +} + +internal int MethAsmInst(){ + Console.WriteLine("A::MethAsmInst()"); + return 100; +} + + ////////////////////////////// + // Static Methods +public static int MethPubStat(){ + Console.WriteLine("A::MethPubStat()"); + return 100; +} + +private static int MethPrivStat(){ + Console.WriteLine("A::MethPrivStat()"); + return 100; +} + +internal static int MethAsmStat(){ + Console.WriteLine("A::MethAsmStat()"); + return 100; +} +} diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-11-3D.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-11-3D.csproj new file mode 100644 index 0000000000..8cc9c6822e --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-11-3D.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-2-11-3D</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-2-11-3D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-12-1.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-12-1.cs new file mode 100644 index 0000000000..1a4b740915 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-12-1.cs @@ -0,0 +1,74 @@ +// 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. + +////////////////////////////////////////////////////////// +// L-1-9-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 1-deep implementation in +// the same assembly and module +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +//@csharp C# doesn't allow much flexibility here in terms of negative testing on interfaces... +//THIS NEEDS MORE COVERAGE + +using System; + +class Test{ +public static int Main(){ + int mi_RetCode; + C c = new C(); + mi_RetCode = c.Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; +} +} + +interface A{ + + ////////////////////////////// + // Instance Methods +int MethPubInst(); +} + +interface B{ +int MethPubInst2(); +} + +struct C : A, B{ +public int MethPubInst(){ + Console.WriteLine("B::MethPubInst()"); + return 100; +} + +public int MethPubInst2(){ + Console.WriteLine("C::MethPubInst2()"); + return 100; +} + +public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance method access + if(MethPubInst() != 100) + mi_RetCode = 0; + + if(MethPubInst2() != 100) + mi_RetCode = 0; + + return mi_RetCode; +} +} + + + + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-12-1.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-12-1.csproj new file mode 100644 index 0000000000..1c8f676566 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-12-1.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-2-12-1</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-2-12-1.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-12-2.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-12-2.csproj new file mode 100644 index 0000000000..f9a249e597 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-12-2.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-2-12-2</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-2-12-2D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-12-2D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-12-2D.cs new file mode 100644 index 0000000000..44bf3b55c2 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-12-2D.cs @@ -0,0 +1,14 @@ +// 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. + +interface A{ + + ////////////////////////////// + // Instance Methods +int MethPubInst(); +} + +interface B{ +int MethPubInst2(); +} diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-12-3.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-12-3.cs new file mode 100644 index 0000000000..eb006f6d11 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-12-3.cs @@ -0,0 +1,63 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +////////////////////////////////////////////////////////// +// L-1-9-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 1-deep implementation in +// the same assembly and module +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +//@csharp C# doesn't allow much flexibility here in terms of negative testing on interfaces... +//THIS NEEDS MORE COVERAGE + +using System; + +class Test{ +public static int Main(){ + int mi_RetCode; + C c = new C(); + mi_RetCode = c.Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; +} +} + +struct C : A, B{ +public int MethPubInst(){ + Console.WriteLine("B::MethPubInst()"); + return 100; +} + +public int MethPubInst2(){ + Console.WriteLine("C::MethPubInst2()"); + return 100; +} + +public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance method access + if(MethPubInst() != 100) + mi_RetCode = 0; + + if(MethPubInst2() != 100) + mi_RetCode = 0; + + return mi_RetCode; +} +} + + + + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-12-3.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-12-3.csproj new file mode 100644 index 0000000000..0407033cab --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-12-3.csproj @@ -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>L-2-12-3</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-2-12-3.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <ProjectReference Include="L-2-12-3D.csproj" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-12-3D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-12-3D.cs new file mode 100644 index 0000000000..9ee05ce65a --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-12-3D.cs @@ -0,0 +1,14 @@ +// 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. + +public interface A{ + + ////////////////////////////// + // Instance Methods +int MethPubInst(); +} + +public interface B{ +int MethPubInst2(); +} diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-12-3D.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-12-3D.csproj new file mode 100644 index 0000000000..617c7c4b2e --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-12-3D.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-2-12-3D</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-2-12-3D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-3-1.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-3-1.cs new file mode 100644 index 0000000000..8f327bd7c1 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-3-1.cs @@ -0,0 +1,261 @@ +// 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. + +////////////////////////////////////////////////////////// +// L-1-3-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 1-deep nesting in +// the same assembly and module +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +using System; + +class Test{ + public static int Main(){ + int mi_RetCode; + A a = new A(); + mi_RetCode = a.Test(); + + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; + } +} + +struct A{ +//@csharp - C# will not allow family or famorassem accessibility on value class members + + public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test nested class access + if(Test_Nested(ClsPubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsPrivInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsAsmInst) != 100) + mi_RetCode = 0; + + // to get rid of compiler warning + // warning CS0414: The private field 'A.ClsPrivStat' is assigned but its value is never used + A.ClsPubStat.ToString(); + A.ClsPrivStat.ToString(); + + return mi_RetCode; + } + + public int Test_Nested(Cls Nested_Cls){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS NESTED FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + ///////////////////////////////// + // Test instance field access + Nested_Cls.NestFldPubInst = 100; + if(Nested_Cls.NestFldPubInst != 100) + mi_RetCode = 0; + + Nested_Cls.NestFldAsmInst = 100; + if(Nested_Cls.NestFldAsmInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + Cls.NestFldPubStat = 100; + if(Cls.NestFldPubStat != 100) + mi_RetCode = 0; + + Cls.NestFldAsmStat = 100; + if(Cls.NestFldAsmStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance method access + if(Nested_Cls.NestMethPubInst() != 100) + mi_RetCode = 0; + + if(Nested_Cls.NestMethAsmInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(Cls.NestMethPubStat() != 100) + mi_RetCode = 0; + + if(Cls.NestMethAsmStat() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + if(Nested_Cls.Test() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + + ////////////////////////////// + // Instance Fields + public int FldPubInst; + private int FldPrivInst; + internal int FldAsmInst; //Translates to "assembly" + + ////////////////////////////// + // Static Fields + public static int FldPubStat; + private static int FldPrivStat; + internal static int FldAsmStat; //assembly + + ////////////////////////////////////// + // Instance fields for nested classes + public Cls ClsPubInst; + private Cls ClsPrivInst; + internal Cls ClsAsmInst; + + ///////////////////////////////////// + // Static fields of nested classes + public static Cls ClsPubStat = new Cls(); + private static Cls ClsPrivStat = new Cls(); + + ////////////////////////////// + // Instance Methods + public int MethPubInst(){ + Console.WriteLine("A::MethPubInst()"); + return 100; + } + + private int MethPrivInst(){ + Console.WriteLine("A::MethPrivInst()"); + return 100; + } + + internal int MethAsmInst(){ + Console.WriteLine("A::MethAsmInst()"); + return 100; + } + + ////////////////////////////// + // Static Methods + public static int MethPubStat(){ + Console.WriteLine("A::MethPubStat()"); + return 100; + } + + private static int MethPrivStat(){ + Console.WriteLine("A::MethPrivStat()"); + return 100; + } + + internal static int MethAsmStat(){ + Console.WriteLine("A::MethAsmStat()"); + return 100; + } + + + public struct Cls{ + public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS ENCLOSING FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + //@csharp - C# will not allow nested classes to access non-static members of their enclosing classes + + ///////////////////////////////// + // Test static field access + FldPubStat = 100; + if(FldPubStat != 100) + mi_RetCode = 0; + + FldAsmStat = 100; + if(FldAsmStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethPubStat() != 100) + mi_RetCode = 0; + + if(MethAsmStat() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + //@todo - Look at testing accessing one nested class from another, @bugug - NEED TO ADD SUCH TESTING, access the public nested class fields from here, etc... + + return mi_RetCode; + } + + ////////////////////////////// + // Instance Fields + public int NestFldPubInst; + private int NestFldPrivInst; + internal int NestFldAsmInst; //Translates to "assembly" + + ////////////////////////////// + // Static Fields + public static int NestFldPubStat; + private static int NestFldPrivStat; + internal static int NestFldAsmStat; //assembly + + ////////////////////////////// + // Instance NestMethods + public int NestMethPubInst(){ + Console.WriteLine("A::NestMethPubInst()"); + return 100; + } + + private int NestMethPrivInst(){ + Console.WriteLine("A::NestMethPrivInst()"); + return 100; + } + + internal int NestMethAsmInst(){ + Console.WriteLine("A::NestMethAsmInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethods + public static int NestMethPubStat(){ + Console.WriteLine("A::NestMethPubStat()"); + return 100; + } + + private static int NestMethPrivStat(){ + Console.WriteLine("A::NestMethPrivStat()"); + return 100; + } + + internal static int NestMethAsmStat(){ + Console.WriteLine("A::NestMethAsmStat()"); + return 100; + } + } +} + + + + + + + + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-3-1.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-3-1.csproj new file mode 100644 index 0000000000..106dd1d14d --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-3-1.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-2-3-1</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-2-3-1.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-4-1.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-4-1.cs new file mode 100644 index 0000000000..8f04d3c1e4 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-4-1.cs @@ -0,0 +1,456 @@ +// 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. + +////////////////////////////////////////////////////////// +// L-2-4-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of value classes using 2-deep nesting in +// the same assembly and module +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +using System; + +class Test{ + public static int Main(){ + int mi_RetCode; + A a = new A(); + mi_RetCode = a.Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; + } +} + +struct A{ +//@csharp - C# again, family or famorassem members not allowed in value classes + public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test nested class access + if(Test_Nested(ClsPubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsPrivInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(ClsAsmInst) != 100) + mi_RetCode = 0; + + // to get rid of compiler warning + // warning CS0414: The private field 'A.ClsPrivStat' is assigned but its value is never used + A.ClsPubStat.ToString(); + A.ClsPrivStat.ToString(); + + return mi_RetCode; + } + + public int Test_Nested(Cls Nested_Cls){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS NESTED FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + ///////////////////////////////// + // Test instance field access + Nested_Cls.NestFldPubInst = 100; + if(Nested_Cls.NestFldPubInst != 100) + mi_RetCode = 0; + + //@csharp - Note, CSharp won't allow access of family or private members of a nested class... + //from it's enclosing class. + + Nested_Cls.NestFldAsmInst = 100; + if(Nested_Cls.NestFldAsmInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + Cls.NestFldPubStat = 100; + if(Cls.NestFldPubStat != 100) + mi_RetCode = 0; + + //@csharp - See last @csharp + + Cls.NestFldAsmStat = 100; + if(Cls.NestFldAsmStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance method access + if(Nested_Cls.NestMethPubInst() != 100) + mi_RetCode = 0; + + //@csharp - See last @csharp + + if(Nested_Cls.NestMethAsmInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(Cls.NestMethPubStat() != 100) + mi_RetCode = 0; + + //@csharp - See last @csharp + + if(Cls.NestMethAsmStat() != 100) + mi_RetCode = 0; + + + //////////////////////////////////////////// + // Test access from within the nested class + if(Nested_Cls.Test() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + + ////////////////////////////// + // Instance Fields + public int FldPubInst; + private int FldPrivInst; + internal int FldAsmInst; //Translates to "assembly" + + ////////////////////////////// + // Static Fields + public static int FldPubStat; + private static int FldPrivStat; + internal static int FldAsmStat; //assembly + + ////////////////////////////////////// + // Instance fields for nested classes + public Cls ClsPubInst; + private Cls ClsPrivInst; + internal Cls ClsAsmInst; + + ///////////////////////////////////// + // Static fields of nested classes + public static Cls ClsPubStat = new Cls(); + private static Cls ClsPrivStat = new Cls(); + + ////////////////////////////// + // Instance Methods + public int MethPubInst(){ + Console.WriteLine("A::MethPubInst()"); + return 100; + } + + private int MethPrivInst(){ + Console.WriteLine("A::MethPrivInst()"); + return 100; + } + + internal int MethAsmInst(){ + Console.WriteLine("A::MethAsmInst()"); + return 100; + } + + ////////////////////////////// + // Static Methods + public static int MethPubStat(){ + Console.WriteLine("A::MethPubStat()"); + return 100; + } + + private static int MethPrivStat(){ + Console.WriteLine("A::MethPrivStat()"); + return 100; + } + + internal static int MethAsmStat(){ + Console.WriteLine("A::MethAsmStat()"); + return 100; + } + + + public struct Cls{ + public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS ENCLOSING FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + //@csharp - C# will not allow nested classes to access non-static members of their enclosing classes + + ///////////////////////////////// + // Test static field access + FldPubStat = 100; + if(FldPubStat != 100) + mi_RetCode = 0; + + FldAsmStat = 100; + if(FldAsmStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethPubStat() != 100) + mi_RetCode = 0; + + if(MethAsmStat() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + //@todo - Look at testing accessing one nested class from another, @bugug - NEED TO ADD SUCH TESTING, access the public nested class fields from here, etc... + + ///////////////////////////////// + // Test nested class access + if(Test_Nested(Cls2PubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(Cls2PrivInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(Cls2AsmInst) != 100) + mi_RetCode = 0; + + // to get rid of compiler warning + // warning CS0414: The private field 'A.ClsPrivStat' is assigned but its value is never used + Cls.ClsPubStat.ToString(); + Cls.ClsPrivStat.ToString(); + + + + return mi_RetCode; + } + + public int Test_Nested(Cls2 Nested_Cls2){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS NESTED FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + ///////////////////////////////// + // Test instance field access + Nested_Cls2.Nest2FldPubInst = 100; + if(Nested_Cls2.Nest2FldPubInst != 100) + mi_RetCode = 0; + + //@csharp - Note, CSharp won't allow access of family or private members of a nested class... + //from it's enclosing class. + + Nested_Cls2.Nest2FldAsmInst = 100; + if(Nested_Cls2.Nest2FldAsmInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + Cls2.Nest2FldPubStat = 100; + if(Cls2.Nest2FldPubStat != 100) + mi_RetCode = 0; + + //@csharp - See last @csharp + + Cls2.Nest2FldAsmStat = 100; + if(Cls2.Nest2FldAsmStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance method access + if(Nested_Cls2.Nest2MethPubInst() != 100) + mi_RetCode = 0; + + //@csharp - See last @csharp + + if(Nested_Cls2.Nest2MethAsmInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(Cls2.Nest2MethPubStat() != 100) + mi_RetCode = 0; + + //@csharp - See last @csharp + + if(Cls2.Nest2MethAsmStat() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + if(Nested_Cls2.Test() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + ////////////////////////////// + // Instance Fields + public int NestFldPubInst; + private int NestFldPrivInst; + internal int NestFldAsmInst; //Translates to "assembly" + + ////////////////////////////// + // Static Fields + public static int NestFldPubStat; + private static int NestFldPrivStat; + internal static int NestFldAsmStat; //assembly + + ////////////////////////////////////// + // Instance fields for nested classes + public Cls2 Cls2PubInst; + private Cls2 Cls2PrivInst; + internal Cls2 Cls2AsmInst; + + ///////////////////////////////////// + // Static fields of nested classes + public static Cls ClsPubStat = new Cls(); + private static Cls ClsPrivStat = new Cls(); + + ////////////////////////////// + // Instance NestMethods + public int NestMethPubInst(){ + Console.WriteLine("A::NestMethPubInst()"); + return 100; + } + + private int NestMethPrivInst(){ + Console.WriteLine("A::NestMethPrivInst()"); + return 100; + } + + internal int NestMethAsmInst(){ + Console.WriteLine("A::NestMethAsmInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethods + public static int NestMethPubStat(){ + Console.WriteLine("A::NestMethPubStat()"); + return 100; + } + + private static int NestMethPrivStat(){ + Console.WriteLine("A::NestMethPrivStat()"); + return 100; + } + + internal static int NestMethAsmStat(){ + Console.WriteLine("A::NestMethAsmStat()"); + return 100; + } + + + public struct Cls2{ + public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS ENCLOSING FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + //@csharp - C# will not allow nested classes to access non-static members of their enclosing classes + + ///////////////////////////////// + // Test static field access + FldPubStat = 100; + if(FldPubStat != 100) + mi_RetCode = 0; + + FldAsmStat = 100; + if(FldAsmStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethPubStat() != 100) + mi_RetCode = 0; + + if(MethAsmStat() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + //@todo - Look at testing accessing one nested class from another, @bugug - NEED TO ADD SUCH TESTING, access the public nested class fields from here, etc... + + ///////////////////////////////// + // Test static field access + NestFldPubStat = 100; + if(NestFldPubStat != 100) + mi_RetCode = 0; + + NestFldAsmStat = 100; + if(NestFldAsmStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(NestMethPubStat() != 100) + mi_RetCode = 0; + + if(NestMethAsmStat() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + ////////////////////////////// + // Instance Fields + public int Nest2FldPubInst; + private int Nest2FldPrivInst; + internal int Nest2FldAsmInst; //Translates to "assembly" + + ////////////////////////////// + // Static Fields + public static int Nest2FldPubStat; + private static int Nest2FldPrivStat; + internal static int Nest2FldAsmStat; //assembly + + ////////////////////////////// + // Instance Nest2Methods + public int Nest2MethPubInst(){ + Console.WriteLine("A::Nest2MethPubInst()"); + return 100; + } + + private int Nest2MethPrivInst(){ + Console.WriteLine("A::Nest2MethPrivInst()"); + return 100; + } + + internal int Nest2MethAsmInst(){ + Console.WriteLine("A::Nest2MethAsmInst()"); + return 100; + } + + ////////////////////////////// + // Static Nest2Methods + public static int Nest2MethPubStat(){ + Console.WriteLine("A::Nest2MethPubStat()"); + return 100; + } + + private static int Nest2MethPrivStat(){ + Console.WriteLine("A::Nest2MethPrivStat()"); + return 100; + } + + internal static int Nest2MethAsmStat(){ + Console.WriteLine("A::Nest2MethAsmStat()"); + return 100; + } + } + } +} + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-4-1.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-4-1.csproj new file mode 100644 index 0000000000..c99f80d27a --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-4-1.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-2-4-1</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-2-4-1.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-5-1.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-5-1.cs new file mode 100644 index 0000000000..295dd07d05 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-5-1.cs @@ -0,0 +1,257 @@ +// 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. + +////////////////////////////////////////////////////////// +// L-1-5-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 1-deep nesting in +// the same assembly and module (checking access from an +// unrelated class). +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +using System; + +class Test{ + public static int Main(){ + int mi_RetCode; + mi_RetCode = B.Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; + } +} + +struct B{ + public static int Test(){ + int mi_RetCode = 100; + + A.Cls ac = new A.Cls(); + A a = new A(); + + if(Test_Nested(ac) != 100) + mi_RetCode = 0; + + //@csharp - C# simply won't compile non-related private/family/protected access + + if(Test_Nested(a.ClsPubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(a.ClsAsmInst) != 100) + mi_RetCode = 0; + + + return mi_RetCode; + } + + public static int Test_Nested(A.Cls ac){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance field access + ac.NestFldPubInst = 100; + if(ac.NestFldPubInst != 100) + mi_RetCode = 0; + + ac.NestFldAsmInst = 100; + if(ac.NestFldAsmInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + A.Cls.NestFldPubStat = 100; + if(A.Cls.NestFldPubStat != 100) + mi_RetCode = 0; + + A.Cls.NestFldAsmStat = 100; + if(A.Cls.NestFldAsmStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance method access + if(ac.NestMethPubInst() != 100) + mi_RetCode = 0; + + if(ac.NestMethAsmInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(A.Cls.NestMethPubStat() != 100) + mi_RetCode = 0; + + if(A.Cls.NestMethAsmStat() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + if(ac.Test() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } +} + +struct A{ + ////////////////////////////// + // Instance Fields + public int FldPubInst; + private int FldPrivInst; + internal int FldAsmInst; //Translates to "assembly" + + ////////////////////////////// + // Static Fields + public static int FldPubStat; + private static int FldPrivStat; + internal static int FldAsmStat; //assembly + + ////////////////////////////////////// + // Instance fields for nested classes + public Cls ClsPubInst; + private Cls ClsPrivInst; + internal Cls ClsAsmInst; + + ///////////////////////////////////// + // Static fields of nested classes + public static Cls ClsPubStat = new Cls(); + private static Cls ClsPrivStat = new Cls(); + + ////////////////////////////// + // Instance Methods + public int MethPubInst(){ + Console.WriteLine("A::MethPubInst()"); + return 100; + } + + private int MethPrivInst(){ + Console.WriteLine("A::MethPrivInst()"); + return 100; + } + + internal int MethAsmInst(){ + Console.WriteLine("A::MethAsmInst()"); + return 100; + } + + ////////////////////////////// + // Static Methods + public static int MethPubStat(){ + Console.WriteLine("A::MethPubStat()"); + return 100; + } + + private static int MethPrivStat(){ + Console.WriteLine("A::MethPrivStat()"); + return 100; + } + + internal static int MethAsmStat(){ + Console.WriteLine("A::MethAsmStat()"); + return 100; + } + + public struct Cls{ + public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS ENCLOSING FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + //@csharp - C# will not allow nested classes to access non-static members of their enclosing classes + + ///////////////////////////////// + // Test static field access + FldPubStat = 100; + if(FldPubStat != 100) + mi_RetCode = 0; + + FldAsmStat = 100; + if(FldAsmStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethPubStat() != 100) + mi_RetCode = 0; + + if(MethAsmStat() != 100) + mi_RetCode = 0; + + // to get rid of compiler warning + // warning CS0414: The private field 'A.ClsPrivStat' is assigned but its value is never used + A.ClsPubStat.ToString(); + A.ClsPrivStat.ToString(); + + //////////////////////////////////////////// + // Test access from within the nested class + //@todo - Look at testing accessing one nested class from another, @bugug - NEED TO ADD SUCH TESTING, access the public nested class fields from here, etc... + + return mi_RetCode; + } + + ////////////////////////////// + // Instance Fields + public int NestFldPubInst; + private int NestFldPrivInst; + internal int NestFldAsmInst; //Translates to "assembly" + + ////////////////////////////// + // Static Fields + public static int NestFldPubStat; + private static int NestFldPrivStat; + internal static int NestFldAsmStat; //assembly + + ////////////////////////////// + // Instance NestMethods + public int NestMethPubInst(){ + Console.WriteLine("A::NestMethPubInst()"); + return 100; + } + + private int NestMethPrivInst(){ + Console.WriteLine("A::NestMethPrivInst()"); + return 100; + } + + internal int NestMethAsmInst(){ + Console.WriteLine("A::NestMethAsmInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethods + public static int NestMethPubStat(){ + Console.WriteLine("A::NestMethPubStat()"); + return 100; + } + + private static int NestMethPrivStat(){ + Console.WriteLine("A::NestMethPrivStat()"); + return 100; + } + + internal static int NestMethAsmStat(){ + Console.WriteLine("A::NestMethAsmStat()"); + return 100; + } + + } +} + + + + + + + + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-5-1.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-5-1.csproj new file mode 100644 index 0000000000..728a7361a2 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-5-1.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-2-5-1</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-2-5-1.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-5-2.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-5-2.csproj new file mode 100644 index 0000000000..2f8aacb7b6 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-5-2.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-2-5-2</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-2-5-2D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-5-2D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-5-2D.cs new file mode 100644 index 0000000000..10852f3e30 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-5-2D.cs @@ -0,0 +1,166 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +public struct A{ + ////////////////////////////// + // Instance Fields + public int FldPubInst; + private int FldPrivInst; + internal int FldAsmInst; //Translates to "assembly" + + ////////////////////////////// + // Static Fields + public static int FldPubStat; + private static int FldPrivStat; + internal static int FldAsmStat; //assembly + + ////////////////////////////////////// + // Instance fields for nested classes + public Cls ClsPubInst; + private Cls ClsPrivInst; + internal Cls ClsAsmInst; + + ///////////////////////////////////// + // Static fields of nested classes + public static Cls ClsPubStat = new Cls(); + private static Cls ClsPrivStat = new Cls(); + + public static Cls getClsPrivStat() + { + return ClsPrivStat; + } + + ////////////////////////////// + // Instance Methods + public int MethPubInst(){ + Console.WriteLine("A::MethPubInst()"); + return 100; + } + + private int MethPrivInst(){ + Console.WriteLine("A::MethPrivInst()"); + return 100; + } + + internal int MethAsmInst(){ + Console.WriteLine("A::MethAsmInst()"); + return 100; + } + + ////////////////////////////// + // Static Methods + public static int MethPubStat(){ + Console.WriteLine("A::MethPubStat()"); + return 100; + } + + private static int MethPrivStat(){ + Console.WriteLine("A::MethPrivStat()"); + return 100; + } + + internal static int MethAsmStat(){ + Console.WriteLine("A::MethAsmStat()"); + return 100; + } + + public struct Cls{ + public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS ENCLOSING FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + //@csharp - C# will not allow nested classes to access non-static members of their enclosing classes + + ///////////////////////////////// + // Test static field access + FldPubStat = 100; + if(FldPubStat != 100) + mi_RetCode = 0; + + FldAsmStat = 100; + if(FldAsmStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethPubStat() != 100) + mi_RetCode = 0; + + if(MethAsmStat() != 100) + mi_RetCode = 0; + + // to get rid of compiler warning + // warning CS0414: The private field 'A.ClsPrivStat' is assigned but its value is never used + A.getClsPrivStat().ToString(); + + //////////////////////////////////////////// + // Test access from within the nested class + //@todo - Look at testing accessing one nested class from another, @bugug - NEED TO ADD SUCH TESTING, access the public nested class fields from here, etc... + + return mi_RetCode; + } + + ////////////////////////////// + // Instance Fields + public int NestFldPubInst; + private int NestFldPrivInst; + internal int NestFldAsmInst; //Translates to "assembly" + + ////////////////////////////// + // Static Fields + public static int NestFldPubStat; + private static int NestFldPrivStat; + internal static int NestFldAsmStat; //assembly + + ////////////////////////////// + // Instance NestMethods + public int NestMethPubInst(){ + Console.WriteLine("A::NestMethPubInst()"); + return 100; + } + + private int NestMethPrivInst(){ + Console.WriteLine("A::NestMethPrivInst()"); + return 100; + } + + internal int NestMethAsmInst(){ + Console.WriteLine("A::NestMethAsmInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethods + public static int NestMethPubStat(){ + Console.WriteLine("A::NestMethPubStat()"); + return 100; + } + + private static int NestMethPrivStat(){ + Console.WriteLine("A::NestMethPrivStat()"); + return 100; + } + + internal static int NestMethAsmStat(){ + Console.WriteLine("A::NestMethAsmStat()"); + return 100; + } + + } +} + + + + + + + + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-5-3.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-5-3.cs new file mode 100644 index 0000000000..2f48d97ffe --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-5-3.cs @@ -0,0 +1,82 @@ +// 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. + +////////////////////////////////////////////////////////// +// L-1-5-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 1-deep nesting in +// the same assembly and module (checking access from an +// unrelated class). +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +using System; + +class Test{ + public static int Main(){ + int mi_RetCode; + mi_RetCode = B.Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; + } +} + +struct B{ + public static int Test(){ + int mi_RetCode = 100; + + A.Cls ac = new A.Cls(); + A a = new A(); + + if(Test_Nested(ac) != 100) + mi_RetCode = 0; + + //@csharp - C# simply won't compile non-related private/family/protected access + + if(Test_Nested(a.ClsPubInst) != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + public static int Test_Nested(A.Cls ac){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance field access + ac.NestFldPubInst = 100; + if(ac.NestFldPubInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + A.Cls.NestFldPubStat = 100; + if(A.Cls.NestFldPubStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance method access + if(ac.NestMethPubInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(A.Cls.NestMethPubStat() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + if(ac.Test() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } +} diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-5-3.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-5-3.csproj new file mode 100644 index 0000000000..a5ef86b4e0 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-5-3.csproj @@ -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>L-2-5-3</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-2-5-3.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <ProjectReference Include="L-2-5-3D.csproj" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-5-3D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-5-3D.cs new file mode 100644 index 0000000000..10852f3e30 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-5-3D.cs @@ -0,0 +1,166 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +public struct A{ + ////////////////////////////// + // Instance Fields + public int FldPubInst; + private int FldPrivInst; + internal int FldAsmInst; //Translates to "assembly" + + ////////////////////////////// + // Static Fields + public static int FldPubStat; + private static int FldPrivStat; + internal static int FldAsmStat; //assembly + + ////////////////////////////////////// + // Instance fields for nested classes + public Cls ClsPubInst; + private Cls ClsPrivInst; + internal Cls ClsAsmInst; + + ///////////////////////////////////// + // Static fields of nested classes + public static Cls ClsPubStat = new Cls(); + private static Cls ClsPrivStat = new Cls(); + + public static Cls getClsPrivStat() + { + return ClsPrivStat; + } + + ////////////////////////////// + // Instance Methods + public int MethPubInst(){ + Console.WriteLine("A::MethPubInst()"); + return 100; + } + + private int MethPrivInst(){ + Console.WriteLine("A::MethPrivInst()"); + return 100; + } + + internal int MethAsmInst(){ + Console.WriteLine("A::MethAsmInst()"); + return 100; + } + + ////////////////////////////// + // Static Methods + public static int MethPubStat(){ + Console.WriteLine("A::MethPubStat()"); + return 100; + } + + private static int MethPrivStat(){ + Console.WriteLine("A::MethPrivStat()"); + return 100; + } + + internal static int MethAsmStat(){ + Console.WriteLine("A::MethAsmStat()"); + return 100; + } + + public struct Cls{ + public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS ENCLOSING FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + //@csharp - C# will not allow nested classes to access non-static members of their enclosing classes + + ///////////////////////////////// + // Test static field access + FldPubStat = 100; + if(FldPubStat != 100) + mi_RetCode = 0; + + FldAsmStat = 100; + if(FldAsmStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethPubStat() != 100) + mi_RetCode = 0; + + if(MethAsmStat() != 100) + mi_RetCode = 0; + + // to get rid of compiler warning + // warning CS0414: The private field 'A.ClsPrivStat' is assigned but its value is never used + A.getClsPrivStat().ToString(); + + //////////////////////////////////////////// + // Test access from within the nested class + //@todo - Look at testing accessing one nested class from another, @bugug - NEED TO ADD SUCH TESTING, access the public nested class fields from here, etc... + + return mi_RetCode; + } + + ////////////////////////////// + // Instance Fields + public int NestFldPubInst; + private int NestFldPrivInst; + internal int NestFldAsmInst; //Translates to "assembly" + + ////////////////////////////// + // Static Fields + public static int NestFldPubStat; + private static int NestFldPrivStat; + internal static int NestFldAsmStat; //assembly + + ////////////////////////////// + // Instance NestMethods + public int NestMethPubInst(){ + Console.WriteLine("A::NestMethPubInst()"); + return 100; + } + + private int NestMethPrivInst(){ + Console.WriteLine("A::NestMethPrivInst()"); + return 100; + } + + internal int NestMethAsmInst(){ + Console.WriteLine("A::NestMethAsmInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethods + public static int NestMethPubStat(){ + Console.WriteLine("A::NestMethPubStat()"); + return 100; + } + + private static int NestMethPrivStat(){ + Console.WriteLine("A::NestMethPrivStat()"); + return 100; + } + + internal static int NestMethAsmStat(){ + Console.WriteLine("A::NestMethAsmStat()"); + return 100; + } + + } +} + + + + + + + + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-5-3D.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-5-3D.csproj new file mode 100644 index 0000000000..7c205570d0 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-5-3D.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-2-5-3D</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-2-5-3D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-6-1.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-6-1.cs new file mode 100644 index 0000000000..d37da7c3b4 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-6-1.cs @@ -0,0 +1,355 @@ +// 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. + +////////////////////////////////////////////////////////// +// L-1-4-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 2-deep nesting in +// the same assembly and module +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +using System; + +class Test{ + public static int Main(){ + int mi_RetCode; + mi_RetCode = B.Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; + } +} + +struct B{ + public static int Test(){ + A a = new A(); + + int mi_RetCode = 100; + + ///////////////////////////////// + // Test nested class access + if(Test_Nested(a.ClsPubInst.Cls2PubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(a.ClsPubInst.Cls2AsmInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(a.ClsAsmInst.Cls2PubInst) != 100) + mi_RetCode = 0; + + if(Test_Nested(a.ClsAsmInst.Cls2AsmInst) != 100) + mi_RetCode = 0; + + // to get rid of compiler warning + // warning CS0414: The private field 'A.ClsPrivStat' is assigned but its value is never used + A.getClsPrivStat().ToString(); + + // to get rid of compiler warning + // warning CS0414: The private field 'A.ClsPrivStat' is assigned but its value is never used + A.Cls.getClsPrivStat().ToString(); + + return mi_RetCode; + } + + public static int Test_Nested(A.Cls.Cls2 Nested_Cls){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS NESTED FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + ///////////////////////////////// + // Test instance field access + Nested_Cls.Nest2FldPubInst = 100; + if(Nested_Cls.Nest2FldPubInst != 100) + mi_RetCode = 0; + + Nested_Cls.Nest2FldAsmInst = 100; + if(Nested_Cls.Nest2FldAsmInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + A.Cls.Cls2.Nest2FldPubStat = 100; + if(A.Cls.Cls2.Nest2FldPubStat != 100) + mi_RetCode = 0; + + A.Cls.Cls2.Nest2FldAsmStat = 100; + if(A.Cls.Cls2.Nest2FldAsmStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance method access + if(Nested_Cls.Nest2MethPubInst() != 100) + mi_RetCode = 0; + + if(Nested_Cls.Nest2MethAsmInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(A.Cls.Cls2.Nest2MethPubStat() != 100) + mi_RetCode = 0; + + if(A.Cls.Cls2.Nest2MethAsmStat() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + if(Nested_Cls.Test() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } +} + + +struct A{ + ////////////////////////////// + // Instance Fields + public int FldPubInst; + private int FldPrivInst; + internal int FldAsmInst; //Translates to "assembly" + + ////////////////////////////// + // Static Fields + public static int FldPubStat; + private static int FldPrivStat; + internal static int FldAsmStat; //assembly + + ////////////////////////////////////// + // Instance fields for nested classes + public Cls ClsPubInst; + private Cls ClsPrivInst; + internal Cls ClsAsmInst; + + ///////////////////////////////////// + // Static fields of nested classes + +#pragma warning disable 0414 + public static Cls ClsPubStat = new Cls(); + private static Cls ClsPrivStat = new Cls(); +#pragma warning restore 0414 + + public static Cls getClsPrivStat() + { + return ClsPrivStat; + } + + ////////////////////////////// + // Instance Methods + public int MethPubInst(){ + Console.WriteLine("A::MethPubInst()"); + return 100; + } + + private int MethPrivInst(){ + Console.WriteLine("A::MethPrivInst()"); + return 100; + } + + internal int MethAsmInst(){ + Console.WriteLine("A::MethAsmInst()"); + return 100; + } + + ////////////////////////////// + // Static Methods + public static int MethPubStat(){ + Console.WriteLine("A::MethPubStat()"); + return 100; + } + + private static int MethPrivStat(){ + Console.WriteLine("A::MethPrivStat()"); + return 100; + } + + internal static int MethAsmStat(){ + Console.WriteLine("A::MethAsmStat()"); + return 100; + } + + + public struct Cls{ + ////////////////////////////// + // Instance Fields + public int NestFldPubInst; + private int NestFldPrivInst; + internal int NestFldAsmInst; //Translates to "assembly" + + ////////////////////////////// + // Static Fields + public static int NestFldPubStat; + private static int NestFldPrivStat; + internal static int NestFldAsmStat; //assembly + + ////////////////////////////////////// + // Instance fields for nested classes + public Cls2 Cls2PubInst; + private Cls2 Cls2PrivInst; + internal Cls2 Cls2AsmInst; + + ///////////////////////////////////// + // Static fields of nested classes +#pragma warning disable 0414 + public static Cls ClsPubStat = new Cls(); + private static Cls ClsPrivStat = new Cls(); +#pragma warning restore 0414 + public static Cls getClsPrivStat() + { + return ClsPrivStat; + } + + ////////////////////////////// + // Instance NestMethods + public int NestMethPubInst(){ + Console.WriteLine("A::NestMethPubInst()"); + return 100; + } + + private int NestMethPrivInst(){ + Console.WriteLine("A::NestMethPrivInst()"); + return 100; + } + + internal int NestMethAsmInst(){ + Console.WriteLine("A::NestMethAsmInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethods + public static int NestMethPubStat(){ + Console.WriteLine("A::NestMethPubStat()"); + return 100; + } + + private static int NestMethPrivStat(){ + Console.WriteLine("A::NestMethPrivStat()"); + return 100; + } + + internal static int NestMethAsmStat(){ + Console.WriteLine("A::NestMethAsmStat()"); + return 100; + } + + + + public struct Cls2{ + public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS ENCLOSING FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + //@csharp - C# will not allow nested classes to access non-static members of their enclosing classes + + ///////////////////////////////// + // Test static field access + FldPubStat = 100; + if(FldPubStat != 100) + mi_RetCode = 0; + + FldAsmStat = 100; + if(FldAsmStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethPubStat() != 100) + mi_RetCode = 0; + + if(MethAsmStat() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + //@todo - Look at testing accessing one nested class from another, @bugug - NEED TO ADD SUCH TESTING, access the public nested class fields from here, etc... + + ///////////////////////////////// + // Test static field access + NestFldPubStat = 100; + if(NestFldPubStat != 100) + mi_RetCode = 0; + + NestFldAsmStat = 100; + if(NestFldAsmStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(NestMethPubStat() != 100) + mi_RetCode = 0; + + if(NestMethAsmStat() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + ////////////////////////////// + // Instance Fields + public int Nest2FldPubInst; + private int Nest2FldPrivInst; + internal int Nest2FldAsmInst; //Translates to "assembly" + + ////////////////////////////// + // Static Fields + public static int Nest2FldPubStat; + private static int Nest2FldPrivStat; + internal static int Nest2FldAsmStat; //assembly + + ////////////////////////////// + // Instance Nest2Methods + public int Nest2MethPubInst(){ + Console.WriteLine("A::Nest2MethPubInst()"); + return 100; + } + + private int Nest2MethPrivInst(){ + Console.WriteLine("A::Nest2MethPrivInst()"); + return 100; + } + + internal int Nest2MethAsmInst(){ + Console.WriteLine("A::Nest2MethAsmInst()"); + return 100; + } + + ////////////////////////////// + // Static Nest2Methods + public static int Nest2MethPubStat(){ + Console.WriteLine("A::Nest2MethPubStat()"); + return 100; + } + + private static int Nest2MethPrivStat(){ + Console.WriteLine("A::Nest2MethPrivStat()"); + return 100; + } + + internal static int Nest2MethAsmStat(){ + Console.WriteLine("A::Nest2MethAsmStat()"); + return 100; + } + + + } + } +} + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-6-1.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-6-1.csproj new file mode 100644 index 0000000000..15da3ebd73 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-6-1.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-2-6-1</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-2-6-1.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-6-2.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-6-2.csproj new file mode 100644 index 0000000000..96c0b066db --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-6-2.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-2-6-2</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-2-6-2D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-6-2D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-6-2D.cs new file mode 100644 index 0000000000..ca6ba5871d --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-6-2D.cs @@ -0,0 +1,253 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +public struct A{ + ////////////////////////////// + // Instance Fields + public int FldPubInst; + private int FldPrivInst; + internal int FldAsmInst; //Translates to "assembly" + + ////////////////////////////// + // Static Fields + public static int FldPubStat; + private static int FldPrivStat; + internal static int FldAsmStat; //assembly + + ////////////////////////////////////// + // Instance fields for nested classes + public Cls ClsPubInst; + private Cls ClsPrivInst; + internal Cls ClsAsmInst; + + ///////////////////////////////////// + // Static fields of nested classes + public static Cls ClsPubStat = new Cls(); + private static Cls ClsPrivStat = new Cls(); + + + public static Cls getClsPrivStat() + { + return ClsPrivStat; + } + + + ////////////////////////////// + // Instance Methods + public int MethPubInst(){ + Console.WriteLine("A::MethPubInst()"); + return 100; + } + + private int MethPrivInst(){ + Console.WriteLine("A::MethPrivInst()"); + return 100; + } + + internal int MethAsmInst(){ + Console.WriteLine("A::MethAsmInst()"); + return 100; + } + + ////////////////////////////// + // Static Methods + public static int MethPubStat(){ + Console.WriteLine("A::MethPubStat()"); + return 100; + } + + private static int MethPrivStat(){ + Console.WriteLine("A::MethPrivStat()"); + return 100; + } + + internal static int MethAsmStat(){ + Console.WriteLine("A::MethAsmStat()"); + return 100; + } + + + public struct Cls{ + ////////////////////////////// + // Instance Fields + public int NestFldPubInst; + private int NestFldPrivInst; + internal int NestFldAsmInst; //Translates to "assembly" + + ////////////////////////////// + // Static Fields + public static int NestFldPubStat; + private static int NestFldPrivStat; + internal static int NestFldAsmStat; //assembly + + ////////////////////////////////////// + // Instance fields for nested classes + public Cls2 Cls2PubInst; + private Cls2 Cls2PrivInst; + internal Cls2 Cls2AsmInst; + + ///////////////////////////////////// + // Static fields of nested classes + public static Cls ClsPubStat = new Cls(); + private static Cls ClsPrivStat = new Cls(); + + + public static Cls getClsPrivStat() + { + return ClsPrivStat; + } + + + ////////////////////////////// + // Instance NestMethods + public int NestMethPubInst(){ + Console.WriteLine("A::NestMethPubInst()"); + return 100; + } + + private int NestMethPrivInst(){ + Console.WriteLine("A::NestMethPrivInst()"); + return 100; + } + + internal int NestMethAsmInst(){ + Console.WriteLine("A::NestMethAsmInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethods + public static int NestMethPubStat(){ + Console.WriteLine("A::NestMethPubStat()"); + return 100; + } + + private static int NestMethPrivStat(){ + Console.WriteLine("A::NestMethPrivStat()"); + return 100; + } + + internal static int NestMethAsmStat(){ + Console.WriteLine("A::NestMethAsmStat()"); + return 100; + } + + + + public struct Cls2{ + public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS ENCLOSING FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + //@csharp - C# will not allow nested classes to access non-static members of their enclosing classes + + ///////////////////////////////// + // Test static field access + FldPubStat = 100; + if(FldPubStat != 100) + mi_RetCode = 0; + + FldAsmStat = 100; + if(FldAsmStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethPubStat() != 100) + mi_RetCode = 0; + + if(MethAsmStat() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + //@todo - Look at testing accessing one nested class from another, @bugug - NEED TO ADD SUCH TESTING, access the public nested class fields from here, etc... + + ///////////////////////////////// + // Test static field access + NestFldPubStat = 100; + if(NestFldPubStat != 100) + mi_RetCode = 0; + + NestFldAsmStat = 100; + if(NestFldAsmStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(NestMethPubStat() != 100) + mi_RetCode = 0; + + if(NestMethAsmStat() != 100) + mi_RetCode = 0; + + + // to get rid of compiler warning + // warning CS0414: The private field 'A.ClsPrivStat' is assigned but its value is never used + A.Cls.getClsPrivStat().ToString(); + + // to get rid of compiler warning + // warning CS0414: The private field 'A.ClsPrivStat' is assigned but its value is never used + A.getClsPrivStat().ToString(); + + return mi_RetCode; + } + + ////////////////////////////// + // Instance Fields + public int Nest2FldPubInst; + private int Nest2FldPrivInst; + internal int Nest2FldAsmInst; //Translates to "assembly" + + ////////////////////////////// + // Static Fields + public static int Nest2FldPubStat; + private static int Nest2FldPrivStat; + internal static int Nest2FldAsmStat; //assembly + + ////////////////////////////// + // Instance Nest2Methods + public int Nest2MethPubInst(){ + Console.WriteLine("A::Nest2MethPubInst()"); + return 100; + } + + private int Nest2MethPrivInst(){ + Console.WriteLine("A::Nest2MethPrivInst()"); + return 100; + } + + internal int Nest2MethAsmInst(){ + Console.WriteLine("A::Nest2MethAsmInst()"); + return 100; + } + + ////////////////////////////// + // Static Nest2Methods + public static int Nest2MethPubStat(){ + Console.WriteLine("A::Nest2MethPubStat()"); + return 100; + } + + private static int Nest2MethPrivStat(){ + Console.WriteLine("A::Nest2MethPrivStat()"); + return 100; + } + + internal static int Nest2MethAsmStat(){ + Console.WriteLine("A::Nest2MethAsmStat()"); + return 100; + } + + + } + } +} diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-6-3.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-6-3.cs new file mode 100644 index 0000000000..d2a1e8a720 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-6-3.cs @@ -0,0 +1,84 @@ +// 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. + +////////////////////////////////////////////////////////// +// L-1-4-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 2-deep nesting in +// the same assembly and module +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +using System; + +class Test{ + public static int Main(){ + int mi_RetCode; + mi_RetCode = B.Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; + } +} + +struct B{ + public static int Test(){ + A a = new A(); + + int mi_RetCode = 100; + + ///////////////////////////////// + // Test nested class access + if(Test_Nested(a.ClsPubInst.Cls2PubInst) != 100) + mi_RetCode = 0; + + return mi_RetCode; + } + + public static int Test_Nested(A.Cls.Cls2 Nested_Cls){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS NESTED FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + ///////////////////////////////// + // Test instance field access + Nested_Cls.Nest2FldPubInst = 100; + if(Nested_Cls.Nest2FldPubInst != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static field access + A.Cls.Cls2.Nest2FldPubStat = 100; + if(A.Cls.Cls2.Nest2FldPubStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test instance method access + if(Nested_Cls.Nest2MethPubInst() != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(A.Cls.Cls2.Nest2MethPubStat() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + if(Nested_Cls.Test() != 100) + mi_RetCode = 0; + + return mi_RetCode; + } +} + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-6-3.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-6-3.csproj new file mode 100644 index 0000000000..a3e4856447 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-6-3.csproj @@ -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>L-2-6-3</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-2-6-3.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <ProjectReference Include="L-2-6-3D.csproj" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-6-3D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-6-3D.cs new file mode 100644 index 0000000000..1ebb77d9d6 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-6-3D.cs @@ -0,0 +1,247 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +public struct A{ + ////////////////////////////// + // Instance Fields + public int FldPubInst; + private int FldPrivInst; + internal int FldAsmInst; //Translates to "assembly" + + ////////////////////////////// + // Static Fields + public static int FldPubStat; + private static int FldPrivStat; + internal static int FldAsmStat; //assembly + + ////////////////////////////////////// + // Instance fields for nested classes + public Cls ClsPubInst; + private Cls ClsPrivInst; + internal Cls ClsAsmInst; + + ///////////////////////////////////// + // Static fields of nested classes + public static Cls ClsPubStat = new Cls(); + private static Cls ClsPrivStat = new Cls(); + + public static Cls getClsPrivStat() + { + return ClsPrivStat; + } + + ////////////////////////////// + // Instance Methods + public int MethPubInst(){ + Console.WriteLine("A::MethPubInst()"); + return 100; + } + + private int MethPrivInst(){ + Console.WriteLine("A::MethPrivInst()"); + return 100; + } + + internal int MethAsmInst(){ + Console.WriteLine("A::MethAsmInst()"); + return 100; + } + + ////////////////////////////// + // Static Methods + public static int MethPubStat(){ + Console.WriteLine("A::MethPubStat()"); + return 100; + } + + private static int MethPrivStat(){ + Console.WriteLine("A::MethPrivStat()"); + return 100; + } + + internal static int MethAsmStat(){ + Console.WriteLine("A::MethAsmStat()"); + return 100; + } + + + public struct Cls{ + ////////////////////////////// + // Instance Fields + public int NestFldPubInst; + private int NestFldPrivInst; + internal int NestFldAsmInst; //Translates to "assembly" + + ////////////////////////////// + // Static Fields + public static int NestFldPubStat; + private static int NestFldPrivStat; + internal static int NestFldAsmStat; //assembly + + ////////////////////////////////////// + // Instance fields for nested classes + public Cls2 Cls2PubInst; + private Cls2 Cls2PrivInst; + internal Cls2 Cls2AsmInst; + + ///////////////////////////////////// + // Static fields of nested classes + public static Cls ClsPubStat = new Cls(); + private static Cls ClsPrivStat = new Cls(); + + public static Cls getClsPrivStat() + { + return ClsPrivStat; + } + ////////////////////////////// + // Instance NestMethods + public int NestMethPubInst(){ + Console.WriteLine("A::NestMethPubInst()"); + return 100; + } + + private int NestMethPrivInst(){ + Console.WriteLine("A::NestMethPrivInst()"); + return 100; + } + + internal int NestMethAsmInst(){ + Console.WriteLine("A::NestMethAsmInst()"); + return 100; + } + + ////////////////////////////// + // Static NestMethods + public static int NestMethPubStat(){ + Console.WriteLine("A::NestMethPubStat()"); + return 100; + } + + private static int NestMethPrivStat(){ + Console.WriteLine("A::NestMethPrivStat()"); + return 100; + } + + internal static int NestMethAsmStat(){ + Console.WriteLine("A::NestMethAsmStat()"); + return 100; + } + + + + public struct Cls2{ + public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // ACCESS ENCLOSING FIELDS/MEMBERS + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + //@csharp - C# will not allow nested classes to access non-static members of their enclosing classes + + ///////////////////////////////// + // Test static field access + FldPubStat = 100; + if(FldPubStat != 100) + mi_RetCode = 0; + + FldAsmStat = 100; + if(FldAsmStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(MethPubStat() != 100) + mi_RetCode = 0; + + if(MethAsmStat() != 100) + mi_RetCode = 0; + + //////////////////////////////////////////// + // Test access from within the nested class + //@todo - Look at testing accessing one nested class from another, @bugug - NEED TO ADD SUCH TESTING, access the public nested class fields from here, etc... + + ///////////////////////////////// + // Test static field access + NestFldPubStat = 100; + if(NestFldPubStat != 100) + mi_RetCode = 0; + + NestFldAsmStat = 100; + if(NestFldAsmStat != 100) + mi_RetCode = 0; + + ///////////////////////////////// + // Test static method access + if(NestMethPubStat() != 100) + mi_RetCode = 0; + + if(NestMethAsmStat() != 100) + mi_RetCode = 0; + + // to get rid of compiler warning + // warning CS0414: The private field 'A.ClsPrivStat' is assigned but its value is never used + A.Cls.getClsPrivStat().ToString(); + + // to get rid of compiler warning + // warning CS0414: The private field 'A.ClsPrivStat' is assigned but its value is never used + A.getClsPrivStat().ToString(); + + return mi_RetCode; + } + + ////////////////////////////// + // Instance Fields + public int Nest2FldPubInst; + private int Nest2FldPrivInst; + internal int Nest2FldAsmInst; //Translates to "assembly" + + ////////////////////////////// + // Static Fields + public static int Nest2FldPubStat; + private static int Nest2FldPrivStat; + internal static int Nest2FldAsmStat; //assembly + + ////////////////////////////// + // Instance Nest2Methods + public int Nest2MethPubInst(){ + Console.WriteLine("A::Nest2MethPubInst()"); + return 100; + } + + private int Nest2MethPrivInst(){ + Console.WriteLine("A::Nest2MethPrivInst()"); + return 100; + } + + internal int Nest2MethAsmInst(){ + Console.WriteLine("A::Nest2MethAsmInst()"); + return 100; + } + + ////////////////////////////// + // Static Nest2Methods + public static int Nest2MethPubStat(){ + Console.WriteLine("A::Nest2MethPubStat()"); + return 100; + } + + private static int Nest2MethPrivStat(){ + Console.WriteLine("A::Nest2MethPrivStat()"); + return 100; + } + + internal static int Nest2MethAsmStat(){ + Console.WriteLine("A::Nest2MethAsmStat()"); + return 100; + } + + + } + } +} diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-6-3D.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-6-3D.csproj new file mode 100644 index 0000000000..06e227bdf3 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-6-3D.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-2-6-3D</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-2-6-3D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-9-1.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-9-1.cs new file mode 100644 index 0000000000..fd48a81c44 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-9-1.cs @@ -0,0 +1,62 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +////////////////////////////////////////////////////////// +// L-1-9-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 1-deep implementation in +// the same assembly and module +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +//@csharp C# doesn't allow much flexibility here in terms of negative testing on interfaces... +//THIS NEEDS MORE COVERAGE + +using System; + +class Test{ +public static int Main(){ + int mi_RetCode; + B b = new B(); + mi_RetCode = b.Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; +} +} + +interface A{ + + ////////////////////////////// + // Instance Methods +int MethPubInst(); +} + +struct B : A{ +public int MethPubInst(){ + Console.WriteLine("B::MethPubInst()"); + return 100; +} + +public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance method access + if(MethPubInst() != 100) + mi_RetCode = 0; + + return mi_RetCode; +} +} + + + + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-9-1.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-9-1.csproj new file mode 100644 index 0000000000..0197c91cd2 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-9-1.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-2-9-1</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-2-9-1.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-9-2.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-9-2.csproj new file mode 100644 index 0000000000..8411806fa1 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-9-2.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-2-9-2</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-2-9-2D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-9-2D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-9-2D.cs new file mode 100644 index 0000000000..745f8da6cf --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-9-2D.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +interface A{ + + ////////////////////////////// + // Instance Methods +int MethPubInst(); +} + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-9-3.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-9-3.cs new file mode 100644 index 0000000000..4dd25c082a --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-9-3.cs @@ -0,0 +1,55 @@ +// 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. + +////////////////////////////////////////////////////////// +// L-1-9-1.cs - Beta1 Layout Test - RDawson +// +// Tests layout of classes using 1-deep implementation in +// the same assembly and module +// +// See ReadMe.txt in the same project as this source for +// further details about these tests. +// + +//@csharp C# doesn't allow much flexibility here in terms of negative testing on interfaces... +//THIS NEEDS MORE COVERAGE + +using System; + +class Test{ +public static int Main(){ + int mi_RetCode; + B b = new B(); + mi_RetCode = b.Test(); + + if(mi_RetCode == 100) + Console.WriteLine("Pass"); + else + Console.WriteLine("FAIL"); + + return mi_RetCode; +} +} + +struct B : A{ +public int MethPubInst(){ + Console.WriteLine("B::MethPubInst()"); + return 100; +} + +public int Test(){ + int mi_RetCode = 100; + + ///////////////////////////////// + // Test instance method access + if(MethPubInst() != 100) + mi_RetCode = 0; + + return mi_RetCode; +} +} + + + + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-9-3.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-9-3.csproj new file mode 100644 index 0000000000..2c5ded36d4 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-9-3.csproj @@ -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>L-2-9-3</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Exe</OutputType> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-2-9-3.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <ProjectReference Include="L-2-9-3D.csproj" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-9-3D.cs b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-9-3D.cs new file mode 100644 index 0000000000..ef3e1c468a --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-9-3D.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +public interface A{ + + ////////////////////////////// + // Instance Methods +int MethPubInst(); +} + diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-9-3D.csproj b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-9-3D.csproj new file mode 100644 index 0000000000..193f8ca5ac --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/L-2-9-3D.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <AssemblyName>L-2-9-3D</AssemblyName> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <OutputType>Library</OutputType> + <CLRTestKind>BuildOnly</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + + <ItemGroup> + <Compile Include="L-2-9-3D.cs" /> + </ItemGroup> + + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/app.config b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/app.config new file mode 100644 index 0000000000..e5622f77ad --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/app.config @@ -0,0 +1,27 @@ +<?xml version = "1.0" encoding="utf-8"?> +<configuration> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration> diff --git a/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/project.json b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/project.json new file mode 100644 index 0000000000..a2e84dc340 --- /dev/null +++ b/tests/src/Loader/classloader/v1/Beta1/Layout/Matrix/cs/project.json @@ -0,0 +1,35 @@ +{ + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816", + "System.Collections": "4.0.10", + "System.Collections.NonGeneric": "4.0.1-rc2-23816", + "System.Collections.Specialized": "4.0.1-rc2-23816", + "System.ComponentModel": "4.0.1-rc2-23816", + "System.Console": "4.0.0-rc2-23816", + "System.Diagnostics.Process": "4.1.0-rc2-23816", + "System.Globalization": "4.0.10", + "System.Globalization.Calendars": "4.0.0", + "System.IO": "4.0.10", + "System.IO.FileSystem": "4.0.0", + "System.IO.FileSystem.Primitives": "4.0.0", + "System.Linq": "4.0.1-rc2-23816", + "System.Linq.Queryable": "4.0.1-rc2-23816", + "System.Reflection": "4.0.10", + "System.Reflection.Primitives": "4.0.0", + "System.Runtime": "4.1.0-rc2-23816", + "System.Runtime.Extensions": "4.0.10", + "System.Runtime.Handles": "4.0.0", + "System.Runtime.InteropServices": "4.1.0-rc2-23816", + "System.Runtime.Loader": "4.0.0-rc2-23816", + "System.Text.Encoding": "4.0.10", + "System.Threading": "4.0.10", + "System.Threading.Thread": "4.0.0-rc2-23816", + "System.Xml.ReaderWriter": "4.0.11-rc2-23816", + "System.Xml.XDocument": "4.0.11-rc2-23816", + "System.Xml.XmlDocument": "4.0.1-rc2-23816", + "System.Xml.XmlSerializer": "4.0.11-rc2-23816" + }, + "frameworks": { + "dnxcore50": {} + } +} |