summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/src/managed/Compilation/Compilation.cs36
-rw-r--r--tests/src/managed/Compilation/Compilation.csproj45
-rw-r--r--tests/src/managed/Compilation/HelloWorld.cs13
-rw-r--r--tests/src/managed/Compilation/packages.config29
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>