diff options
author | Alex Ghiondea <ghiondea.alexandru@microsoft.com> | 2015-01-30 15:09:01 -0800 |
---|---|---|
committer | Alex Ghiondea <ghiondea.alexandru@microsoft.com> | 2015-01-30 15:09:01 -0800 |
commit | 3a0d638843472056c0cbb723beaed0b1152ca36d (patch) | |
tree | 9891a6a2cd3317d6d5f8d8f8c2c62d2a77048470 /tests/src/managed | |
parent | ef1e2ab328087c61a6878c1e84f4fc5d710aebce (diff) | |
download | coreclr-3a0d638843472056c0cbb723beaed0b1152ca36d.tar.gz coreclr-3a0d638843472056c0cbb723beaed0b1152ca36d.tar.bz2 coreclr-3a0d638843472056c0cbb723beaed0b1152ca36d.zip |
Add test for mscorlib.
The test will use Roslyn to compile a simple program.
[tfs-changeset: 1408001]
Diffstat (limited to 'tests/src/managed')
-rw-r--r-- | tests/src/managed/Compilation/Compilation.cs | 36 | ||||
-rw-r--r-- | tests/src/managed/Compilation/Compilation.csproj | 45 | ||||
-rw-r--r-- | tests/src/managed/Compilation/HelloWorld.cs | 13 | ||||
-rw-r--r-- | tests/src/managed/Compilation/packages.config | 29 |
4 files changed, 123 insertions, 0 deletions
diff --git a/tests/src/managed/Compilation/Compilation.cs b/tests/src/managed/Compilation/Compilation.cs new file mode 100644 index 0000000000..0a0037af29 --- /dev/null +++ b/tests/src/managed/Compilation/Compilation.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; + +class Program +{ + static int Main(string[] args) + { + Console.WriteLine("Starting the test"); + string codeFile = @"helloWorld.cs"; + + var sourceTree = new List<SyntaxTree>(){SyntaxFactory.ParseSyntaxTree(File.ReadAllText(codeFile))}; + + string mscorlibFile = Path.Combine(Environment.GetEnvironmentVariable("Core_root"), "mscorlib.dll"); + Console.WriteLine("Using reference to: {0}", mscorlibFile); + var reference = new List<MetadataReference>(){ MetadataReference.CreateFromFile(mscorlibFile)}; + + var compilation = CSharpCompilation.Create("helloworld", sourceTree, reference); + + Console.WriteLine("Test compiled"); + var result = compilation.Emit(new FileStream("helloworld.exe", FileMode.Create)); + if (!result.Success) + { + return -1; + } + + return 100; + } +} diff --git a/tests/src/managed/Compilation/Compilation.csproj b/tests/src/managed/Compilation/Compilation.csproj new file mode 100644 index 0000000000..5b274fb30a --- /dev/null +++ b/tests/src/managed/Compilation/Compilation.csproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>Compilation</AssemblyName> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{39DD9A75-2535-4EBD-94A4-C7DF7EF12CF5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <RestorePackages>true</RestorePackages> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <DefineConstants>$(DefineConstants);STATIC</DefineConstants> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <Compile Include="Compilation.cs" /> + </ItemGroup> + <ItemGroup> + <Content Include="HelloWorld.cs"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + </ItemGroup> + <ItemGroup> + <None Include="packages.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project>
\ No newline at end of file diff --git a/tests/src/managed/Compilation/HelloWorld.cs b/tests/src/managed/Compilation/HelloWorld.cs new file mode 100644 index 0000000000..13a423ba9d --- /dev/null +++ b/tests/src/managed/Compilation/HelloWorld.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System; +class C +{ + static int Main() + { + Console.WriteLine("Hello " + "world"); + return 100; + } +}
\ No newline at end of file diff --git a/tests/src/managed/Compilation/packages.config b/tests/src/managed/Compilation/packages.config new file mode 100644 index 0000000000..8566104ed2 --- /dev/null +++ b/tests/src/managed/Compilation/packages.config @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="System.Console" version="4.0.0-beta-22405" /> + <package id="System.Runtime" version="4.0.20-beta-22405" /> + <package id="System.Collections" version="4.0.10-beta-22512" /> + <package id="System.Collections.Concurrent" version="4.0.10-beta-22416" /> + <package id="System.IO" version="4.0.10-beta-22412" /> + <package id="System.IO.FileSystem" version="4.0.0-beta-22412" /> + <package id="System.IO.FileSystem.Primitives" version="4.0.0-beta-22412" /> + <package id="System.Text.Encoding" version="4.0.10-beta-22512" /> + <package id="System.Threading" version="4.0.0-beta-22412" /> + <package id="System.Threading.Tasks" version="4.0.10-beta-22412" /> + <package id="System.Runtime.Handles" version="4.0.0-beta-22412" /> + <package id="System.Threading.ThreadPool" version="4.0.10-beta-22416" /> + <package id="System.Threading.Overlapped" version="4.0.0-beta-22416" /> + <package id="System.Dynamic.Runtime" version="4.0.0-beta-22416" /> + <package id="System.Threading.Tasks.Parallel" version="4.0.0-beta-22416" /> + <package id="System.Runtime.Extensions" version="4.0.10-beta-22412" /> + + <package id="Microsoft.CodeAnalysis" version="1.0.0.0-beta2" targetFramework="net45" /> + <package id="Microsoft.CodeAnalysis.Common" version="1.0.0.0-beta2" targetFramework="net45" /> + <package id="Microsoft.CodeAnalysis.CSharp" version="1.0.0.0-beta2" targetFramework="net45" /> + <package id="Microsoft.CodeAnalysis.CSharp.Workspaces" version="1.0.0.0-beta2" targetFramework="net45" /> + <package id="Microsoft.CodeAnalysis.VisualBasic" version="1.0.0.0-beta2" targetFramework="net45" /> + <package id="Microsoft.CodeAnalysis.VisualBasic.Workspaces" version="1.0.0.0-beta2" targetFramework="net45" /> + <package id="Microsoft.CodeAnalysis.Workspaces.Common" version="1.0.0.0-beta2" targetFramework="net45" /> + <package id="System.Collections.Immutable" version="1.1.32-beta" targetFramework="net45" /> + <package id="System.Reflection.Metadata" version="1.0.17-beta" targetFramework="net45" /> +</packages> |