PageRenderTime 5ms CodeModel.GetById 3ms app.highlight 32ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Compilers/Core/VBCSCompilerTests/CompilerServerTests.cs

https://github.com/EkardNT/Roslyn
C# | 1596 lines | 1393 code | 143 blank | 60 comment | 35 complexity | e4b11ffc9e7e8374c07687592990da4e MD5 | raw file
   1// Copyright (c) Microsoft Open Technologies, Inc.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.
   2
   3using System;
   4using System.Collections.Generic;
   5using System.Diagnostics;
   6using System.IO;
   7using System.Linq;
   8using System.Text;
   9using ProprietaryTestResources = Microsoft.CodeAnalysis.Test.Resources.Proprietary;
  10using Microsoft.CodeAnalysis.Test.Utilities;
  11using Microsoft.CodeAnalysis.Text;
  12
  13using Roslyn.Test.Utilities;
  14using Xunit;
  15using Microsoft.Win32;
  16using System.Runtime.InteropServices;
  17using System.Reflection;
  18
  19namespace Microsoft.CodeAnalysis.BuildTasks.UnitTests
  20{
  21    public class CompilerServerUnitTests : TestBase
  22    {
  23        #region Helpers
  24
  25        private TempDirectory tempDirectory = null;
  26
  27        public CompilerServerUnitTests()
  28        {
  29            tempDirectory = Temp.CreateDirectory();
  30        }
  31
  32        public override void Dispose()
  33        {
  34            KillCompilerServer();
  35
  36            base.Dispose();
  37        }
  38
  39        private Dictionary<string, string> AddForLoggingEnvironmentVars(Dictionary<string, string> vars)
  40        {
  41            var dict = vars == null ? new Dictionary<string, string>() : vars;
  42            if (!dict.ContainsKey("RoslynCommandLineLogFile"))
  43            {
  44                dict.Add("RoslynCommandLineLogFile", typeof(CompilerServerUnitTests).Assembly.Location + ".client-server.log");
  45            }
  46            return dict;
  47        }
  48
  49        private void KillProcess(string path)
  50        {
  51            var processes = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(path));
  52            foreach (Process p in processes)
  53            {
  54                int pathSize = path.Length * 2;
  55                var exeNameBuffer = new StringBuilder(pathSize);
  56                IntPtr handle = IntPtr.Zero;
  57
  58                try
  59                {
  60                    // If the process has exited in between asking for the list and getting the handle,
  61                    // this will throw an exception. We want to ignore it and keep on going with the
  62                    // next process
  63                    handle = p.Handle;
  64                }
  65                catch (InvalidOperationException)
  66                { }
  67
  68                if (handle != IntPtr.Zero &&
  69                    QueryFullProcessImageName(handle,
  70                                              0, // Win32 path format
  71                                              exeNameBuffer,
  72                                              ref pathSize) &&
  73                    string.Equals(exeNameBuffer.ToString(),
  74                                  path,
  75                                  StringComparison.OrdinalIgnoreCase))
  76                {
  77                    p.Kill();
  78                    p.WaitForExit();
  79                }
  80            }
  81        }
  82
  83        /// <summary>
  84        /// Get the file path of the executable that started this process.
  85        /// </summary>
  86        /// <param name="processHandle"></param>
  87        /// <param name="flags">Should always be 0: Win32 path format.</param>
  88        /// <param name="exeNameBuffer">Buffer for the name</param>
  89        /// <param name="bufferSize">
  90        /// Size of the buffer coming in, chars written coming out.
  91        /// </param>
  92        [DllImport("Kernel32.dll", EntryPoint = "QueryFullProcessImageNameW", CharSet = CharSet.Unicode)]
  93        private static extern bool QueryFullProcessImageName(
  94            IntPtr processHandle,
  95            int flags,
  96            StringBuilder exeNameBuffer,
  97            ref int bufferSize);
  98
  99        private static string WorkingDirectory
 100        {
 101            get
 102            {
 103                return Environment.CurrentDirectory;
 104            }
 105        }
 106
 107        private static string msbuildExecutable;
 108        private static string MSBuildExecutable
 109        {
 110            get
 111            {
 112                if (msbuildExecutable == null)
 113                {
 114                    msbuildExecutable = Path.Combine(MSBuildDirectory, "MSBuild.exe");
 115                }
 116                return msbuildExecutable;
 117            }
 118        }
 119
 120        private static string msbuildDirectory;
 121        private static string MSBuildDirectory
 122        {
 123            get
 124            {
 125                if (msbuildDirectory == null)
 126                {
 127                    var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0", false);
 128
 129                    if (key != null)
 130                    {
 131                        var toolsPath = key.GetValue("MSBuildToolsPath");
 132                        if (toolsPath != null)
 133                        {
 134                            msbuildDirectory = toolsPath.ToString();
 135                        }
 136                    }
 137                }
 138                return msbuildDirectory;
 139            }
 140        }
 141
 142        private static string CompilerServerExecutable = Path.Combine(WorkingDirectory, "VBCSCompiler.exe");
 143        private static string BuildTaskDll = Path.Combine(WorkingDirectory, "Roslyn.Compilers.BuildTasks.dll");
 144        private static string CSharpCompilerClientExecutable = Path.Combine(WorkingDirectory, "csc2.exe");
 145        private static string BasicCompilerClientExecutable = Path.Combine(WorkingDirectory, "vbc2.exe");
 146        private static string CSharpCompilerExecutable = Path.Combine(WorkingDirectory, "csc.exe");
 147        private static string BasicCompilerExecutable = Path.Combine(WorkingDirectory, "vbc.exe");
 148
 149        // In order that the compiler server doesn't stay around and prevent future builds, we explicitly
 150        // kill it after each test.
 151        private void KillCompilerServer()
 152        {
 153            KillProcess(CompilerServerExecutable);
 154        }
 155
 156        private ProcessResult RunCommandLineCompiler(string compilerPath, string arguments, string currentDirectory, Dictionary<string, string> additionalEnvironmentVars = null)
 157        {
 158            return ProcessLauncher.Run(compilerPath, arguments, currentDirectory, additionalEnvironmentVars: AddForLoggingEnvironmentVars(additionalEnvironmentVars));
 159        }
 160
 161        private ProcessResult RunCommandLineCompiler(string compilerPath, string arguments, TempDirectory currentDirectory, Dictionary<string, string> filesInDirectory, Dictionary<string, string> additionalEnvironmentVars = null)
 162        {
 163            foreach (var pair in filesInDirectory)
 164            {
 165                TempFile file = currentDirectory.CreateFile(pair.Key);
 166                file.WriteAllText(pair.Value);
 167            }
 168
 169            return RunCommandLineCompiler(compilerPath, arguments, currentDirectory.Path, additionalEnvironmentVars: AddForLoggingEnvironmentVars(additionalEnvironmentVars));
 170        }
 171
 172        private DisposableFile GetResultFile(TempDirectory directory, string resultFileName)
 173        {
 174            return new DisposableFile(Path.Combine(directory.Path, resultFileName));
 175        }
 176
 177        private ProcessResult RunCompilerOutput(TempFile file)
 178        {
 179            return ProcessLauncher.Run(file.Path, "", Path.GetDirectoryName(file.Path));
 180        }
 181
 182        private static void VerifyResult(ProcessResult result)
 183        {
 184            Assert.Equal("", result.Output);
 185            Assert.Equal("", result.Errors);
 186            Assert.Equal(0, result.ExitCode);
 187        }
 188
 189        private void VerifyResultAndOutput(ProcessResult result, TempDirectory path, string expectedOutput)
 190        {
 191            using (var resultFile = GetResultFile(path, "hello.exe"))
 192            {
 193                VerifyResult(result);
 194
 195                var runningResult = RunCompilerOutput(resultFile);
 196                Assert.Equal(expectedOutput, runningResult.Output);
 197            }
 198        }
 199
 200        #endregion
 201
 202        [Fact]
 203        [Trait(Traits.Environment, Traits.Environments.VSProductInstall)]
 204        public void HelloWorldCS()
 205        {
 206            Dictionary<string, string> files =
 207                                   new Dictionary<string, string> {
 208                                           { "hello.cs", 
 209@"using System;
 210using System.Diagnostics;
 211class Hello 
 212{
 213    static void Main()
 214    { 
 215        var obj = new Process();
 216        Console.WriteLine(""Hello, world.""); 
 217    }
 218}"}};
 219
 220            var result = RunCommandLineCompiler(CSharpCompilerClientExecutable, "/nologo hello.cs", tempDirectory, files);
 221            VerifyResultAndOutput(result, tempDirectory, "Hello, world.\r\n");
 222        }
 223
 224        [Fact]
 225        [WorkItem(946954)]
 226        public void CompilerBinariesAreAnyCPU()
 227        {
 228            Assert.Equal(ProcessorArchitecture.MSIL, AssemblyName.GetAssemblyName(CompilerServerExecutable).ProcessorArchitecture);
 229        }
 230
 231        /// <summary>
 232        /// This method tests that when a 64-bit compiler server loads a 
 233        /// 64-bit mscorlib with /platform:x86 enabled no warning about
 234        /// emitting a refence to a 64-bit assembly is produced.
 235        /// The test should pass on x86 or amd64, but can only fail on
 236        /// amd64.
 237        /// </summary>
 238        [Fact]
 239        [Trait(Traits.Environment, Traits.Environments.VSProductInstall)]
 240        public void Platformx86MscorlibCsc()
 241        {
 242            var files = new Dictionary<string, string> { { "c.cs", "class C {}" } };
 243            var result = RunCommandLineCompiler(CSharpCompilerClientExecutable,
 244                                                "/nologo /t:library /platform:x86 c.cs",
 245                                                tempDirectory,
 246                                                files);
 247            VerifyResult(result);
 248        }
 249
 250        [Fact]
 251        [Trait(Traits.Environment, Traits.Environments.VSProductInstall)]
 252        public void Platformx86MscorlibVbc()
 253        {
 254            var files = new Dictionary<string, string> { { "c.vb", "Class C\nEnd Class" } };
 255            var result = RunCommandLineCompiler(BasicCompilerClientExecutable,
 256                                                "/nologo /t:library /platform:x86 c.vb",
 257                                                tempDirectory,
 258                                                files);
 259            VerifyResult(result);
 260        }
 261
 262        [Fact]
 263        [Trait(Traits.Environment, Traits.Environments.VSProductInstall)]
 264        public void ExtraMSCorLibCS()
 265        {
 266            Dictionary<string, string> files =
 267                                   new Dictionary<string, string> {
 268                                           { "hello.cs", 
 269@"using System;
 270class Hello 
 271{
 272    static void Main()
 273    { Console.WriteLine(""Hello, world.""); }
 274}"}};
 275
 276            var result = RunCommandLineCompiler(CSharpCompilerClientExecutable, "/nologo /r:mscorlib.dll hello.cs", tempDirectory, files);
 277            VerifyResultAndOutput(result, tempDirectory, "Hello, world.\r\n");
 278        }
 279
 280        [Fact]
 281        [Trait(Traits.Environment, Traits.Environments.VSProductInstall)]
 282        public void HelloWorldVB()
 283        {
 284            Dictionary<string, string> files =
 285                                   new Dictionary<string, string> {
 286                                           { "hello.vb", 
 287@"Imports System.Diagnostics
 288
 289Module Module1
 290    Sub Main()
 291        Dim p As New Process()
 292        Console.WriteLine(""Hello from VB"")
 293    End Sub
 294End Module"}};
 295
 296            var result = RunCommandLineCompiler(BasicCompilerClientExecutable, "/nologo /r:Microsoft.VisualBasic.dll hello.vb", tempDirectory, files);
 297            VerifyResultAndOutput(result, tempDirectory, "Hello from VB\r\n");
 298        }
 299
 300        [Fact]
 301        [Trait(Traits.Environment, Traits.Environments.VSProductInstall)]
 302        public void ExtraMSCorLibVB()
 303        {
 304            Dictionary<string, string> files =
 305                                   new Dictionary<string, string> {
 306                                           { "hello.vb", 
 307@"Imports System
 308
 309Module Module1
 310    Sub Main()
 311        Console.WriteLine(""Hello from VB"")
 312    End Sub
 313End Module"}};
 314
 315            var result = RunCommandLineCompiler(BasicCompilerClientExecutable, "/nologo /r:mscorlib.dll /r:Microsoft.VisualBasic.dll hello.vb", tempDirectory, files);
 316            VerifyResultAndOutput(result, tempDirectory, "Hello from VB\r\n");
 317        }
 318
 319        [Fact]
 320        [Trait(Traits.Environment, Traits.Environments.VSProductInstall)]
 321        public void CompileErrorsCS()
 322        {
 323            Dictionary<string, string> files =
 324                                   new Dictionary<string, string> {
 325                                           { "hello.cs", 
 326@"using System;
 327class Hello 
 328{
 329    static void Main()
 330    { Console.WriteLine(""Hello, world."") }
 331}"}};
 332
 333            var result = RunCommandLineCompiler(CSharpCompilerClientExecutable, "hello.cs", tempDirectory, files);
 334
 335            // Should output errors, but not create output file.                  
 336            Assert.Contains("Copyright (C) Microsoft Corporation. All rights reserved.", result.Output);
 337            Assert.Contains("hello.cs(5,42): error CS1002: ; expected\r\n", result.Output);
 338            Assert.Equal("", result.Errors);
 339            Assert.Equal(1, result.ExitCode);
 340            Assert.False(File.Exists(Path.Combine(tempDirectory.Path, "hello.exe")));
 341        }
 342
 343        [Fact]
 344        [Trait(Traits.Environment, Traits.Environments.VSProductInstall)]
 345        public void CompileErrorsVB()
 346        {
 347            Dictionary<string, string> files =
 348                                   new Dictionary<string, string> {
 349                                           { "hellovb.vb", 
 350@"Imports System
 351
 352Module Module1
 353    Sub Main()
 354        Console.WriteLine(""Hello from VB"")
 355    End Sub
 356End Class"}};
 357
 358            var result = RunCommandLineCompiler(BasicCompilerClientExecutable, "/r:Microsoft.VisualBasic.dll hellovb.vb", tempDirectory, files);
 359
 360            // Should output errors, but not create output file.
 361            Assert.Contains("Copyright (C) Microsoft Corporation. All rights reserved.", result.Output);
 362            Assert.Contains("hellovb.vb(3) : error BC30625: 'Module' statement must end with a matching 'End Module'.\r\n", result.Output);
 363            Assert.Contains("hellovb.vb(7) : error BC30460: 'End Class' must be preceded by a matching 'Class'.\r\n", result.Output);
 364            Assert.Equal("", result.Errors);
 365            Assert.Equal(1, result.ExitCode);
 366            Assert.False(File.Exists(Path.Combine(tempDirectory.Path, "hello.exe")));
 367        }
 368
 369        [Fact]
 370        [Trait(Traits.Environment, Traits.Environments.VSProductInstall)]
 371        public void MissingFileErrorCS()
 372        {
 373            var result = RunCommandLineCompiler(CSharpCompilerClientExecutable, "missingfile.cs", tempDirectory, new Dictionary<string, string>());
 374
 375            // Should output errors, but not create output file.
 376            Assert.Equal("", result.Errors);
 377            Assert.Contains("Copyright (C) Microsoft Corporation. All rights reserved.", result.Output);
 378            Assert.Contains("error CS2001: Source file", result.Output);
 379            Assert.Equal(1, result.ExitCode);
 380            Assert.False(File.Exists(Path.Combine(tempDirectory.Path, "missingfile.exe")));
 381        }
 382
 383        [Fact]
 384        [Trait(Traits.Environment, Traits.Environments.VSProductInstall)]
 385        public void MissingReferenceErrorCS()
 386        {
 387            Dictionary<string, string> files =
 388                                   new Dictionary<string, string> {
 389                                           { "hello.cs", 
 390@"using System;
 391class Hello 
 392{
 393    static void Main()
 394    { 
 395        Console.WriteLine(""Hello, world.""); 
 396    }
 397}"}};
 398
 399            var result = RunCommandLineCompiler(CSharpCompilerClientExecutable, "/r:missing.dll hello.cs", tempDirectory, files);
 400
 401            // Should output errors, but not create output file.
 402            Assert.Equal("", result.Errors);
 403            Assert.Contains("Copyright (C) Microsoft Corporation. All rights reserved.", result.Output);
 404            Assert.Contains("error CS0006: Metadata file", result.Output);
 405            Assert.Equal(1, result.ExitCode);
 406            Assert.False(File.Exists(Path.Combine(tempDirectory.Path, "hello.exe")));
 407        }
 408
 409        [WorkItem(546067, "DevDiv")]
 410        [Fact]
 411        [Trait(Traits.Environment, Traits.Environments.VSProductInstall)]
 412        public void InvalidMetadataFileErrorCS()
 413        {
 414            Dictionary<string, string> files =
 415                                   new Dictionary<string, string> {
 416                                               { "Lib.cs", "public class C {}"},
 417                                               { "app.cs", "class Test { static void Main() {} }"},
 418                                           };
 419
 420            var result = RunCommandLineCompiler(CSharpCompilerClientExecutable, "/r:Lib.cs app.cs", tempDirectory, files);
 421
 422            // Should output errors, but not create output file.
 423            Assert.Equal("", result.Errors);
 424            Assert.Contains("Copyright (C) Microsoft Corporation. All rights reserved.", result.Output);
 425            Assert.Contains("error CS0009: Metadata file", result.Output);
 426            Assert.Equal(1, result.ExitCode);
 427            Assert.False(File.Exists(Path.Combine(tempDirectory.Path, "app.exe")));
 428        }
 429
 430        [Fact]
 431        [Trait(Traits.Environment, Traits.Environments.VSProductInstall)]
 432        public void MissingFileErrorVB()
 433        {
 434            var result = RunCommandLineCompiler(BasicCompilerClientExecutable, "missingfile.vb", tempDirectory, new Dictionary<string, string>());
 435
 436            // Should output errors, but not create output file.
 437            Assert.Equal("", result.Errors);
 438            Assert.Contains("Copyright (C) Microsoft Corporation. All rights reserved.", result.Output);
 439            Assert.Contains("error BC2001", result.Output);
 440            Assert.Equal(1, result.ExitCode);
 441            Assert.False(File.Exists(Path.Combine(tempDirectory.Path, "missingfile.exe")));
 442        }
 443
 444        [Fact(), WorkItem(761131, "DevDiv")]
 445        [Trait(Traits.Environment, Traits.Environments.VSProductInstall)]
 446        public void MissingReferenceErrorVB()
 447        {
 448            Dictionary<string, string> files =
 449                                   new Dictionary<string, string> {
 450                                           { "hellovb.vb", 
 451@"Imports System.Diagnostics
 452
 453Module Module1
 454    Sub Main()
 455        Dim p As New Process()
 456        Console.WriteLine(""Hello from VB"")
 457    End Sub
 458End Module"}};
 459
 460            var result = RunCommandLineCompiler(BasicCompilerClientExecutable, "/nologo /r:Microsoft.VisualBasic.dll /r:missing.dll hellovb.vb", tempDirectory, files);
 461
 462            // Should output errors, but not create output file.
 463            Assert.Equal("", result.Errors);
 464            Assert.Contains("error BC2017: could not find library", result.Output);
 465            Assert.Equal(1, result.ExitCode);
 466            Assert.False(File.Exists(Path.Combine(tempDirectory.Path, "hellovb.exe")));
 467        }
 468
 469        [WorkItem(546067, "DevDiv")]
 470        [Fact]
 471        [Trait(Traits.Environment, Traits.Environments.VSProductInstall)]
 472        public void InvalidMetadataFileErrorVB()
 473        {
 474            Dictionary<string, string> files =
 475                                   new Dictionary<string, string> {
 476                                            { "Lib.vb",
 477@"Class C
 478End Class" },
 479                                            { "app.vb",
 480@"Module M1
 481    Sub Main()
 482    End Sub
 483End Module"}};
 484
 485            var result = RunCommandLineCompiler(BasicCompilerClientExecutable, "/r:Lib.vb app.vb", tempDirectory, files);
 486
 487            // Should output errors, but not create output file.
 488            Assert.Equal("", result.Errors);
 489            Assert.Contains("error BC31519", result.Output);
 490            Assert.Equal(1, result.ExitCode);
 491            Assert.False(File.Exists(Path.Combine(tempDirectory.Path, "app.exe")));
 492        }
 493
 494        [Fact()]
 495        [WorkItem(723280, "DevDiv")]
 496        [Trait(Traits.Environment, Traits.Environments.VSProductInstall)]
 497        public void ReferenceCachingVB()
 498        {
 499            TempDirectory rootDirectory = tempDirectory.CreateDirectory("ReferenceCachingVB");
 500
 501            // Create DLL "lib.dll"
 502            Dictionary<string, string> files =
 503                                   new Dictionary<string, string> {
 504                                           { "src1.vb", 
 505@"Imports System
 506Public Class Library 
 507
 508    Public Shared Function GetString() As String
 509        Return ""library1""
 510    End Function
 511End Class
 512"}};
 513
 514            using (var tmpFile = GetResultFile(rootDirectory, "lib.dll"))
 515            {
 516                var result = RunCommandLineCompiler(BasicCompilerClientExecutable, "src1.vb /nologo /t:library /out:lib.dll", rootDirectory, files);
 517                Assert.Equal("", result.Output);
 518                Assert.Equal("", result.Errors);
 519                Assert.Equal(0, result.ExitCode);
 520
 521                using (var hello1_file = GetResultFile(rootDirectory, "hello1.exe"))
 522                {
 523                    // Create EXE "hello1.exe"
 524                    files = new Dictionary<string, string> {
 525                                           { "hello1.vb", 
 526@"Imports System
 527Module Module1 
 528    Public Sub Main()
 529        Console.WriteLine(""Hello1 from {0}"", Library.GetString())
 530    End Sub
 531End Module
 532"}};
 533                    result = RunCommandLineCompiler(BasicCompilerClientExecutable, "hello1.vb /nologo /r:Microsoft.VisualBasic.dll /r:lib.dll /out:hello1.exe", rootDirectory, files);
 534                    Assert.Equal("", result.Output);
 535                    Assert.Equal("", result.Errors);
 536                    Assert.Equal(0, result.ExitCode);
 537
 538                    // Run hello1.exe.
 539                    var runningResult = RunCompilerOutput(hello1_file);
 540                    Assert.Equal("Hello1 from library1\r\n", runningResult.Output);
 541
 542                    using (var hello2_file = GetResultFile(rootDirectory, "hello2.exe"))
 543                    {
 544                        // Create EXE "hello2.exe" referencing same DLL
 545                        files = new Dictionary<string, string> {
 546                                                { "hello2.vb", 
 547@"Imports System
 548Module Module1 
 549Public Sub Main()
 550    Console.WriteLine(""Hello2 from {0}"", Library.GetString())
 551End Sub
 552End Module
 553"}};
 554                        result = RunCommandLineCompiler(BasicCompilerClientExecutable, "hello2.vb /nologo /r:Microsoft.VisualBasic.dll /r:lib.dll /out:hello2.exe", rootDirectory, files);
 555                        Assert.Equal("", result.Output);
 556                        Assert.Equal("", result.Errors);
 557                        Assert.Equal(0, result.ExitCode);
 558
 559                        // Run hello2.exe.
 560                        runningResult = RunCompilerOutput(hello2_file);
 561                        Assert.Equal("Hello2 from library1\r\n", runningResult.Output);
 562
 563                        // Change DLL "lib.dll" to something new.
 564                        files =
 565                                               new Dictionary<string, string> {
 566                                           { "src2.vb", 
 567@"Imports System
 568Public Class Library 
 569    Public Shared Function GetString() As String
 570        Return ""library2""
 571    End Function
 572    Public Shared Function GetString2() As String
 573        Return ""library3""
 574    End Function
 575End Class
 576"}};
 577
 578                        result = RunCommandLineCompiler(BasicCompilerClientExecutable, "src2.vb /nologo /t:library /out:lib.dll", rootDirectory, files);
 579                        Assert.Equal("", result.Output);
 580                        Assert.Equal("", result.Errors);
 581                        Assert.Equal(0, result.ExitCode);
 582
 583                        using (var hello3_file = GetResultFile(rootDirectory, "hello3.exe"))
 584                        {
 585                            // Create EXE "hello3.exe" referencing new DLL
 586                            files = new Dictionary<string, string> {
 587                                           { "hello3.vb", 
 588@"Imports System
 589Module Module1 
 590    Public Sub Main()
 591        Console.WriteLine(""Hello3 from {0}"", Library.GetString2())
 592    End Sub
 593End Module
 594"}};
 595                            result = RunCommandLineCompiler(BasicCompilerClientExecutable, "hello3.vb /nologo /r:Microsoft.VisualBasic.dll /r:lib.dll /out:hello3.exe", rootDirectory, files);
 596                            Assert.Equal("", result.Output);
 597                            Assert.Equal("", result.Errors);
 598                            Assert.Equal(0, result.ExitCode);
 599
 600                            // Run hello3.exe. Should work.
 601                            runningResult = RunCompilerOutput(hello3_file);
 602                            Assert.Equal("Hello3 from library3\r\n", runningResult.Output);
 603
 604                            // Run hello2.exe one more time. Should have different output than before from updated library.
 605                            runningResult = RunCompilerOutput(hello2_file);
 606                            Assert.Equal("Hello2 from library2\r\n", runningResult.Output);
 607                        }
 608                    }
 609                }
 610            }
 611
 612            GC.KeepAlive(rootDirectory);
 613        }
 614
 615        [Fact()]
 616        [WorkItem(723280, "DevDiv")]
 617        [Trait(Traits.Environment, Traits.Environments.VSProductInstall)]
 618        public void ReferenceCachingCS()
 619        {
 620            TempDirectory rootDirectory = tempDirectory.CreateDirectory("ReferenceCachingCS");
 621
 622            using (var tmpFile = GetResultFile(rootDirectory, "lib.dll"))
 623            {
 624                // Create DLL "lib.dll"
 625                Dictionary<string, string> files =
 626                                       new Dictionary<string, string> {
 627                                           { "src1.cs", 
 628@"using System;
 629public class Library 
 630{
 631    public static string GetString()
 632    { return ""library1""; }
 633}"}};
 634
 635                var result = RunCommandLineCompiler(CSharpCompilerClientExecutable, "src1.cs /nologo /t:library /out:lib.dll", rootDirectory, files);
 636                Assert.Equal("", result.Output);
 637                Assert.Equal("", result.Errors);
 638                Assert.Equal(0, result.ExitCode);
 639
 640                using (var hello1_file = GetResultFile(rootDirectory, "hello1.exe"))
 641                {
 642                    // Create EXE "hello1.exe"
 643                    files = new Dictionary<string, string> {
 644                                           { "hello1.cs", 
 645@"using System;
 646class Hello 
 647{
 648    public static void Main()
 649    { Console.WriteLine(""Hello1 from {0}"", Library.GetString()); }
 650}"}};
 651                    result = RunCommandLineCompiler(CSharpCompilerClientExecutable, "hello1.cs /nologo /r:lib.dll /out:hello1.exe", rootDirectory, files);
 652                    Assert.Equal("", result.Output);
 653                    Assert.Equal("", result.Errors);
 654                    Assert.Equal(0, result.ExitCode);
 655
 656                    // Run hello1.exe.
 657                    var runningResult = RunCompilerOutput(hello1_file);
 658                    Assert.Equal("Hello1 from library1\r\n", runningResult.Output);
 659
 660                    using (var hello2_file = GetResultFile(rootDirectory, "hello2.exe"))
 661                    {
 662                        var hello2exe = Temp.AddFile(hello2_file);
 663
 664                        // Create EXE "hello2.exe" referencing same DLL
 665                        files = new Dictionary<string, string> {
 666                                               { "hello2.cs", 
 667@"using System;
 668class Hello 
 669{
 670    public static void Main()
 671    { Console.WriteLine(""Hello2 from {0}"", Library.GetString()); }
 672}"}};
 673                        result = RunCommandLineCompiler(CSharpCompilerClientExecutable, "hello2.cs /nologo /r:lib.dll /out:hello2.exe", rootDirectory, files);
 674                        Assert.Equal("", result.Output);
 675                        Assert.Equal("", result.Errors);
 676                        Assert.Equal(0, result.ExitCode);
 677
 678                        // Run hello2.exe.
 679                        runningResult = RunCompilerOutput(hello2exe);
 680                        Assert.Equal("Hello2 from library1\r\n", runningResult.Output);
 681
 682                        // Change DLL "lib.dll" to something new.
 683                        files =
 684                                               new Dictionary<string, string> {
 685                                           { "src2.cs", 
 686@"using System;
 687public class Library 
 688{
 689    public static string GetString()
 690    { return ""library2""; }
 691
 692    public static string GetString2()
 693    { return ""library3""; }
 694}"}};
 695
 696                        result = RunCommandLineCompiler(CSharpCompilerClientExecutable, "src2.cs /nologo /t:library /out:lib.dll", rootDirectory, files);
 697                        Assert.Equal("", result.Output);
 698                        Assert.Equal("", result.Errors);
 699                        Assert.Equal(0, result.ExitCode);
 700
 701                        using (var hello3_file = GetResultFile(rootDirectory, "hello3.exe"))
 702                        {
 703                            // Create EXE "hello3.exe" referencing new DLL
 704                            files = new Dictionary<string, string> {
 705                                           { "hello3.cs", 
 706@"using System;
 707class Hello 
 708{
 709    public static void Main()
 710    { Console.WriteLine(""Hello3 from {0}"", Library.GetString2()); }
 711}"}};
 712                            result = RunCommandLineCompiler(CSharpCompilerClientExecutable, "hello3.cs /nologo /r:lib.dll /out:hello3.exe", rootDirectory, files);
 713                            Assert.Equal("", result.Output);
 714                            Assert.Equal("", result.Errors);
 715                            Assert.Equal(0, result.ExitCode);
 716
 717                            // Run hello3.exe. Should work.
 718                            runningResult = RunCompilerOutput(hello3_file);
 719                            Assert.Equal("Hello3 from library3\r\n", runningResult.Output);
 720
 721                            // Run hello2.exe one more time. Should have different output than before from updated library.
 722                            runningResult = RunCompilerOutput(hello2_file);
 723                            Assert.Equal("Hello2 from library2\r\n", runningResult.Output);
 724                        }
 725                    }
 726                }
 727            }
 728
 729            GC.KeepAlive(rootDirectory);
 730        }
 731
 732        // Set up directory for multiple simultaneous compilers.
 733        private TempDirectory SetupDirectory(TempRoot root, int i)
 734        {
 735            TempDirectory dir = root.CreateDirectory();
 736            var helloFileCs = dir.CreateFile(string.Format("hello{0}.cs", i));
 737            helloFileCs.WriteAllText(string.Format(
 738@"using System;
 739class Hello 
 740{{
 741    public static void Main()
 742    {{ Console.WriteLine(""CS Hello number {0}""); }}
 743}}", i));
 744
 745            var helloFileVb = dir.CreateFile(string.Format("hello{0}.vb", i));
 746            helloFileVb.WriteAllText(string.Format(
 747@"Imports System
 748Module Hello 
 749    Sub Main()
 750       Console.WriteLine(""VB Hello number {0}"") 
 751    End Sub
 752End Module", i));
 753
 754            return dir;
 755        }
 756
 757        // Run compiler in directory set up by SetupDirectory
 758        private Process RunCompilerCS(TempDirectory dir, int i)
 759        {
 760            return ProcessLauncher.StartProcess(CSharpCompilerClientExecutable, string.Format("/nologo hello{0}.cs /out:hellocs{0}.exe", i), dir.Path);
 761        }
 762
 763        // Run compiler in directory set up by SetupDirectory
 764        private Process RunCompilerVB(TempDirectory dir, int i)
 765        {
 766            return ProcessLauncher.StartProcess(BasicCompilerClientExecutable, string.Format("/nologo hello{0}.vb /r:Microsoft.VisualBasic.dll /out:hellovb{0}.exe", i), dir.Path);
 767        }
 768
 769        // Run output in directory set up by SetupDirectory
 770        private void RunOutput(TempRoot root, TempDirectory dir, int i)
 771        {
 772            var exeFile = root.AddFile(GetResultFile(dir, string.Format("hellocs{0}.exe", i)));
 773            var runningResult = RunCompilerOutput(exeFile);
 774            Assert.Equal(string.Format("CS Hello number {0}\r\n", i), runningResult.Output);
 775
 776            exeFile = root.AddFile(GetResultFile(dir, string.Format("hellovb{0}.exe", i)));
 777            runningResult = RunCompilerOutput(exeFile);
 778            Assert.Equal(string.Format("VB Hello number {0}\r\n", i), runningResult.Output);
 779        }
 780
 781        [Fact(), WorkItem(761326, "DevDiv")]
 782        [Trait(Traits.Environment, Traits.Environments.VSProductInstall)]
 783        public void MultipleSimultaneousCompiles()
 784        {
 785            // Run this many compiles simultaneously in different directories.
 786            const int numberOfCompiles = 10;
 787            TempDirectory[] directories = new TempDirectory[numberOfCompiles];
 788            Process[] processesVB = new Process[numberOfCompiles];
 789            Process[] processesCS = new Process[numberOfCompiles];
 790
 791            for (int i = 0; i < numberOfCompiles; ++i)
 792            {
 793                directories[i] = SetupDirectory(Temp, i);
 794            }
 795
 796            for (int i = 0; i < numberOfCompiles; ++i)
 797            {
 798                processesCS[i] = RunCompilerCS(directories[i], i);
 799            }
 800
 801            for (int i = 0; i < numberOfCompiles; ++i)
 802            {
 803                processesVB[i] = RunCompilerVB(directories[i], i);
 804            }
 805
 806            for (int i = 0; i < numberOfCompiles; ++i)
 807            {
 808                AssertNoOutputOrErrors(processesCS[i]);
 809                processesCS[i].WaitForExit();
 810                processesCS[i].Close();
 811                AssertNoOutputOrErrors(processesVB[i]);
 812                processesVB[i].WaitForExit();
 813                processesVB[i].Close();
 814            }
 815
 816            for (int i = 0; i < numberOfCompiles; ++i)
 817            {
 818                RunOutput(Temp, directories[i], i);
 819            }
 820        }
 821
 822        private void AssertNoOutputOrErrors(Process process)
 823        {
 824            Assert.Equal(string.Empty, process.StandardOutput.ReadToEnd());
 825            Assert.Equal(string.Empty, process.StandardError.ReadToEnd());
 826        }
 827
 828        private Dictionary<string, string> GetSimpleMSBuildFiles()
 829        {
 830            // Return a dictionary with name and contents of all the files we want to create for the SimpleMSBuild test.
 831
 832            return new Dictionary<string, string> {
 833{ "HelloSolution.sln", 
 834@"
 835Microsoft Visual Studio Solution File, Format Version 11.00
 836# Visual Studio 2010
 837Project(""{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"") = ""HelloProj"", ""HelloProj.csproj"", ""{7F4CCBA2-1184-468A-BF3D-30792E4E8003}""
 838EndProject
 839Project(""{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"") = ""HelloLib"", ""HelloLib.csproj"", ""{C1170A4A-80CF-4B4F-AA58-2FAEA9158D31}""
 840EndProject
 841Project(""{F184B08F-C81C-45F6-A57F-5ABD9991F28F}"") = ""VBLib"", ""VBLib.vbproj"", ""{F21C894B-28E5-4212-8AF7-C8E0E5455737}""
 842EndProject
 843Global
 844	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 845		Debug|Any CPU = Debug|Any CPU
 846		Debug|Mixed Platforms = Debug|Mixed Platforms
 847		Debug|x86 = Debug|x86
 848		Release|Any CPU = Release|Any CPU
 849		Release|Mixed Platforms = Release|Mixed Platforms
 850		Release|x86 = Release|x86
 851	EndGlobalSection
 852	GlobalSection(ProjectConfigurationPlatforms) = postSolution
 853		{7F4CCBA2-1184-468A-BF3D-30792E4E8003}.Debug|Any CPU.ActiveCfg = Debug|x86
 854		{7F4CCBA2-1184-468A-BF3D-30792E4E8003}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
 855		{7F4CCBA2-1184-468A-BF3D-30792E4E8003}.Debug|Mixed Platforms.Build.0 = Debug|x86
 856		{7F4CCBA2-1184-468A-BF3D-30792E4E8003}.Debug|x86.ActiveCfg = Debug|x86
 857		{7F4CCBA2-1184-468A-BF3D-30792E4E8003}.Debug|x86.Build.0 = Debug|x86
 858		{7F4CCBA2-1184-468A-BF3D-30792E4E8003}.Release|Any CPU.ActiveCfg = Release|x86
 859		{7F4CCBA2-1184-468A-BF3D-30792E4E8003}.Release|Mixed Platforms.ActiveCfg = Release|x86
 860		{7F4CCBA2-1184-468A-BF3D-30792E4E8003}.Release|Mixed Platforms.Build.0 = Release|x86
 861		{7F4CCBA2-1184-468A-BF3D-30792E4E8003}.Release|x86.ActiveCfg = Release|x86
 862		{7F4CCBA2-1184-468A-BF3D-30792E4E8003}.Release|x86.Build.0 = Release|x86
 863		{C1170A4A-80CF-4B4F-AA58-2FAEA9158D31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 864		{C1170A4A-80CF-4B4F-AA58-2FAEA9158D31}.Debug|Any CPU.Build.0 = Debug|Any CPU
 865		{C1170A4A-80CF-4B4F-AA58-2FAEA9158D31}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
 866		{C1170A4A-80CF-4B4F-AA58-2FAEA9158D31}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
 867		{C1170A4A-80CF-4B4F-AA58-2FAEA9158D31}.Debug|x86.ActiveCfg = Debug|Any CPU
 868		{C1170A4A-80CF-4B4F-AA58-2FAEA9158D31}.Release|Any CPU.ActiveCfg = Release|Any CPU
 869		{C1170A4A-80CF-4B4F-AA58-2FAEA9158D31}.Release|Any CPU.Build.0 = Release|Any CPU
 870		{C1170A4A-80CF-4B4F-AA58-2FAEA9158D31}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
 871		{C1170A4A-80CF-4B4F-AA58-2FAEA9158D31}.Release|Mixed Platforms.Build.0 = Release|Any CPU
 872		{C1170A4A-80CF-4B4F-AA58-2FAEA9158D31}.Release|x86.ActiveCfg = Release|Any CPU
 873		{F21C894B-28E5-4212-8AF7-C8E0E5455737}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 874		{F21C894B-28E5-4212-8AF7-C8E0E5455737}.Debug|Any CPU.Build.0 = Debug|Any CPU
 875		{F21C894B-28E5-4212-8AF7-C8E0E5455737}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
 876		{F21C894B-28E5-4212-8AF7-C8E0E5455737}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
 877		{F21C894B-28E5-4212-8AF7-C8E0E5455737}.Debug|x86.ActiveCfg = Debug|Any CPU
 878		{F21C894B-28E5-4212-8AF7-C8E0E5455737}.Release|Any CPU.ActiveCfg = Release|Any CPU
 879		{F21C894B-28E5-4212-8AF7-C8E0E5455737}.Release|Any CPU.Build.0 = Release|Any CPU
 880		{F21C894B-28E5-4212-8AF7-C8E0E5455737}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
 881		{F21C894B-28E5-4212-8AF7-C8E0E5455737}.Release|Mixed Platforms.Build.0 = Release|Any CPU
 882		{F21C894B-28E5-4212-8AF7-C8E0E5455737}.Release|x86.ActiveCfg = Release|Any CPU	EndGlobalSection
 883	GlobalSection(SolutionProperties) = preSolution
 884		HideSolutionNode = FALSE
 885	EndGlobalSection
 886EndGlobal
 887"},
 888
 889{ "HelloProj.csproj",
 890@"<?xml version=""1.0"" encoding=""utf-8""?>
 891<Project ToolsVersion=""4.0"" DefaultTargets=""Build"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
 892  <UsingTask TaskName=""Microsoft.CodeAnalysis.BuildTasks.Csc"" AssemblyFile=""" + BuildTaskDll + @""" />
 893  <PropertyGroup>
 894    <Configuration Condition="" '$(Configuration)' == '' "">Debug</Configuration>
 895    <Platform Condition="" '$(Platform)' == '' "">x86</Platform>
 896    <ProductVersion>8.0.30703</ProductVersion>
 897    <SchemaVersion>2.0</SchemaVersion>
 898    <ProjectGuid>{7F4CCBA2-1184-468A-BF3D-30792E4E8003}</ProjectGuid>
 899    <OutputType>Exe</OutputType>
 900    <AppDesignerFolder>Properties</AppDesignerFolder>
 901    <RootNamespace>HelloProj</RootNamespace>
 902    <AssemblyName>HelloProj</AssemblyName>
 903    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
 904    <TargetFrameworkProfile>Client</TargetFrameworkProfile>
 905    <FileAlignment>512</FileAlignment>
 906  </PropertyGroup>
 907  <PropertyGroup Condition="" '$(Configuration)|$(Platform)' == 'Debug|x86' "">
 908    <PlatformTarget>x86</PlatformTarget>
 909    <DebugSymbols>true</DebugSymbols>
 910    <DebugType>full</DebugType>
 911    <Optimize>false</Optimize>
 912    <OutputPath>bin\Debug\</OutputPath>
 913    <DefineConstants>DEBUG;TRACE</DefineConstants>
 914    <ErrorReport>prompt</ErrorReport>
 915    <WarningLevel>4</WarningLevel>
 916  </PropertyGroup>
 917  <PropertyGroup Condition="" '$(Configuration)|$(Platform)' == 'Release|x86' "">
 918    <PlatformTarget>x86</PlatformTarget>
 919    <DebugType>pdbonly</DebugType>
 920    <Optimize>true</Optimize>
 921    <OutputPath>bin\Release\</OutputPath>
 922    <DefineConstants>TRACE</DefineConstants>
 923    <ErrorReport>prompt</ErrorReport>
 924    <WarningLevel>4</WarningLevel>
 925  </PropertyGroup>
 926  <ItemGroup>
 927    <Reference Include=""System"" />
 928    <Reference Include=""System.Core"" />
 929    <Reference Include=""System.Xml.Linq"" />
 930    <Reference Include=""System.Xml"" />
 931  </ItemGroup>
 932  <ItemGroup>
 933    <Compile Include=""Program.cs"" />
 934  </ItemGroup>
 935  <ItemGroup>
 936    <ProjectReference Include=""HelloLib.csproj"">
 937      <Project>{C1170A4A-80CF-4B4F-AA58-2FAEA9158D31}</Project>
 938      <Name>HelloLib</Name>
 939    </ProjectReference>
 940    <ProjectReference Include=""VBLib.vbproj"">
 941      <Project>{F21C894B-28E5-4212-8AF7-C8E0E5455737}</Project>
 942      <Name>VBLib</Name>
 943    </ProjectReference>
 944  </ItemGroup>
 945  <ItemGroup>
 946    <Folder Include=""Properties\"" />
 947  </ItemGroup>
 948  <Import Project=""$(MSBuildToolsPath)\Microsoft.CSharp.targets"" />
 949</Project>"}, 
 950
 951{ "Program.cs",
 952@"using System;
 953using System.Collections.Generic;
 954using System.Linq;
 955using System.Text;
 956using HelloLib;
 957using VBLib;
 958
 959namespace HelloProj
 960{
 961    class Program
 962    {
 963        static void Main(string[] args)
 964        {
 965            HelloLibClass.SayHello();
 966            VBLibClass.SayThere();
 967            Console.WriteLine(""World"");
 968        }
 969    }
 970}
 971"},
 972
 973{ "HelloLib.csproj",
 974@"<?xml version=""1.0"" encoding=""utf-8""?>
 975<Project ToolsVersion=""4.0"" DefaultTargets=""Build"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
 976  <UsingTask TaskName=""Microsoft.CodeAnalysis.BuildTasks.Csc"" AssemblyFile=""" + BuildTaskDll + @""" />
 977  <PropertyGroup>
 978    <Configuration Condition="" '$(Configuration)' == '' "">Debug</Configuration>
 979    <Platform Condition="" '$(Platform)' == '' "">AnyCPU</Platform>
 980    <ProductVersion>8.0.30703</ProductVersion>
 981    <SchemaVersion>2.0</SchemaVersion>
 982    <ProjectGuid>{C1170A4A-80CF-4B4F-AA58-2FAEA9158D31}</ProjectGuid>
 983    <OutputType>Library</OutputType>
 984    <AppDesignerFolder>Properties</AppDesignerFolder>
 985    <RootNamespace>HelloLib</RootNamespace>
 986    <AssemblyName>HelloLib</AssemblyName>
 987    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
 988    <FileAlignment>512</FileAlignment>
 989  </PropertyGroup>
 990  <PropertyGroup Condition="" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "">
 991    <DebugSymbols>true</DebugSymbols>
 992    <DebugType>full</DebugType>
 993    <Optimize>false</Optimize>
 994    <OutputPath>bin\Debug\</OutputPath>
 995    <DefineConstants>DEBUG;TRACE</DefineConstants>
 996    <ErrorReport>prompt</ErrorReport>
 997    <WarningLevel>4</WarningLevel>
 998  </PropertyGroup>
 999  <PropertyGroup Condition="" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "">
1000    <DebugType>pdbonly</DebugType>
1001    <Optimize>true</Optimize>
1002    <OutputPath>bin\Release\</OutputPath>
1003    <DefineConstants>TRACE</DefineConstants>
1004    <ErrorReport>prompt</ErrorReport>
1005    <WarningLevel>4</WarningLevel>
1006  </PropertyGroup>
1007  <ItemGroup>
1008    <Reference Include=""System"" />
1009    <Reference Include=""System.Core"" />
1010    <Reference Include=""System.Xml.Linq"" />
1011    <Reference Include=""System.Xml"" />
1012  </ItemGroup>
1013  <ItemGroup>
1014    <Compile Include=""HelloLib.cs"" />
1015  </ItemGroup>
1016  <ItemGroup>
1017    <Folder Include=""Properties\"" />
1018  </ItemGroup>
1019  <Import Project=""$(MSBuildToolsPath)\Microsoft.CSharp.targets"" />
1020</Project>"},
1021
1022{ "HelloLib.cs",
1023@"using System;
1024using System.Collections.Generic;
1025using System.Linq;
1026using System.Text;
1027
1028namespace HelloLib
1029{
1030    public class HelloLibClass
1031    {
1032        public static void SayHello()
1033        {
1034            Console.WriteLine(""Hello"");
1035        }
1036    }
1037}
1038"},
1039
1040 { "VBLib.vbproj",
1041@"<?xml version=""1.0"" encoding=""utf-8""?>
1042<Project ToolsVersion=""4.0"" DefaultTargets=""Build"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
1043  <UsingTask TaskName=""Microsoft.CodeAnalysis.BuildTasks.Vbc"" AssemblyFile=""" + BuildTaskDll + @""" />
1044  <PropertyGroup>
1045    <Configuration Condition="" '$(Configuration)' == '' "">Debug</Configuration>
1046    <Platform Condition="" '$(Platform)' == '' "">AnyCPU</Platform>
1047    <ProductVersion>
1048    </ProductVersion>
1049    <SchemaVersion>
1050    </SchemaVersion>
1051    <ProjectGuid>{F21C894B-28E5-4212-8AF7-C8E0E5455737}</ProjectGuid>
1052    <OutputType>Library</OutputType>
1053    <RootNamespace>VBLib</RootNamespace>
1054    <AssemblyName>VBLib</AssemblyName>
1055    <FileAlignment>512</FileAlignment>
1056    <MyType>Windows</MyType>
1057    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
1058  </PropertyGroup>
1059  <PropertyGroup Condition="" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "">
1060    <DebugSymbols>true</DebugSymbols>
1061    <DebugType>full</DebugType>
1062    <DefineDebug>true</DefineDebug>
1063    <DefineTrace>true</DefineTrace>
1064    <OutputPath>bin\Debug\</OutputPath>
1065    <DocumentationFile>VBLib.xml</DocumentationFile>
1066    <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
1067  </PropertyGroup>
1068  <PropertyGroup Condition="" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "">
1069    <DebugType>pdbonly</DebugType>
1070    <DefineDebug>false</DefineDebug>
1071    <DefineTrace>true</DefineTrace>
1072    <Optimize>true</Optimize>
1073    <OutputPath>bin\Release\</OutputPath>
1074    <DocumentationFile>VBLib.xml</DocumentationFile>
1075    <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
1076  </PropertyGroup>
1077  <PropertyGroup>
1078    <OptionExplicit>On</OptionExplicit>
1079  </PropertyGroup>
1080  <PropertyGroup>
1081    <OptionCompare>Binary</OptionCompare>
1082  </PropertyGroup>
1083  <PropertyGroup>
1084    <OptionStrict>Off</OptionStrict>
1085  </PropertyGroup>
1086  <PropertyGroup>
1087    <OptionInfer>On</OptionInfer>
1088  </PropertyGroup>
1089  <ItemGroup>
1090    <Reference Include=""System"" />
1091  </ItemGroup>
1092  <ItemGroup>
1093    <Import Include=""Microsoft.VisualBasic"" />
1094    <Import Include=""System"" />
1095    <Import Include=""System.Collections.Generic"" />
1096  </ItemGroup>
1097  <ItemGroup>
1098    <Compile Include=""VBLib.vb"" />
1099  </ItemGroup>
1100  <Import Project=""$(MSBuildToolsPath)\Microsoft.VisualBasic.targets"" />
1101  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
1102       Other similar extension points exist, see Microsoft.Common.targets.
1103  -->
1104</Project>"},
1105
1106 { "VBLib.vb",
1107@"
1108Public Class VBLibClass
1109    Public Shared Sub SayThere()
1110        Console.WriteLine(""there"")
1111    End Sub
1112End Class
1113"}
1114            };
1115        }
1116
1117        [Fact()]
1118        public void SimpleMSBuild()
1119        {
1120            string arguments = string.Format(@"/m /nr:false /t:Rebuild /p:UseRoslyn=1 HelloSolution.sln");
1121            var result = RunCommandLineCompiler(MSBuildExecutable, arguments, tempDirectory, GetSimpleMSBuildFiles());
1122
1123            using (var resultFile = GetResultFile(tempDirectory, @"bin\debug\helloproj.exe"))
1124            {
1125                // once we stop issuing BC40998 (NYI), we can start making stronger assertions
1126                // about our ouptut in the general case
1127                if (result.ExitCode != 0)
1128                {
1129                    Assert.Equal("", result.Output);
1130                    Assert.Equal("", result.Errors);
1131                }
1132                Assert.Equal(0, result.ExitCode);
1133                var runningResult = RunCompilerOutput(resultFile);
1134                Assert.Equal("Hello\r\nthere\r\nWorld\r\n", runningResult.Output);
1135            }
1136        }
1137
1138        private Dictionary<string, string> GetMultiFileMSBuildFiles()
1139        {
1140            // Return a dictionary with name and contents of all the files we want to create for the SimpleMSBuild test.
1141
1142            return new Dictionary<string, string> {
1143{"ConsoleApplication1.sln", 
1144@"
1145Microsoft Visual Studio Solution File, Format Version 12.00
1146# Visual Studio 2012
1147Project(""{F184B08F-C81C-45F6-A57F-5ABD9991F28F}"") = ""Mod1"", ""Mod1.vbproj"", ""{DEF6D929-FA03-4076-8A05-7BFA33DCC829}""
1148EndProject
1149Project(""{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"") = ""assem1"", ""assem1.csproj"", ""{1245560C-55E4-49D7-904C-18281B369763}""
1150EndProject
1151Project(""{F184B08F-C81C-45F6-A57F-5ABD9991F28F}"") = ""ConsoleApplication1"", ""ConsoleApplication1.vbproj"", ""{52F3466B-DD3F-435C-ADA6-CD023CC82E91}""
1152EndProject
1153Global
1154	GlobalSection(SolutionConfigurationPlatforms) = preSolution
1155		Debug|Any CPU = Debug|Any CPU
1156		Release|Any CPU = Release|Any CPU
1157	EndGlobalSection
1158	GlobalSection(ProjectConfigurationPlatforms) = postSolution
1159		{1245560C-55E4-49D7-904C-18281B369763}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1160		{1245560C-55E4-49D7-904C-18281B369763}.Debug|Any CPU.Build.0 = Debug|Any CPU
1161		{1245560C-55E4-49D7-904C-18281B369763}.Release|Any CPU.ActiveCfg = Release|Any CPU
1162		{1245560C-55E4-49D7-904C-18281B369763}.Release|Any CPU.Build.0 = Release|Any CPU
1163		{52F3466B-DD3F-435C-ADA6-CD023CC82E91}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1164		{52F3466B-DD3F-435C-ADA6-CD023CC82E91}.Debug|Any CPU.Build.0 = Debug|Any CPU
1165		{52F3466B-DD3F-435C-ADA6-CD023CC82E91}.Release|Any CPU.ActiveCfg = Release|Any CPU
1166		{52F3466B-DD3F-435C-ADA6-CD023CC82E91}.Release|Any CPU.Build.0 = Release|Any CPU
1167		{DEF6D929-FA03-4076-8A05-7BFA33DCC829}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1168		{DEF6D929-FA03-4076-8A05-7BFA33DCC829}.Debug|Any CPU.Build.0 = Debug|Any CPU
1169		{DEF6D929-FA03-4076-8A05-7BFA33DCC829}.Release|Any CPU.ActiveCfg = Release|Any CPU
1170		{DEF6D929-FA03-4076-8A05-7BFA33DCC829}.Release|Any CPU.Build.0 = Release|Any CPU
1171	EndGlobalSection
1172	GlobalSection(SolutionProperties) = preSolution
1173		HideSolutionNode = FALSE
1174	EndGlobalSection
1175EndGlobal
1176"},
1177{"ConsoleApplication1.vbproj", 
1178@"<?xml version=""1.0"" encoding=""utf-8""?>
1179<Project ToolsVersion=""4.0"" DefaultTargets=""Build"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
1180  <Import Project=""$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"" Condition=""Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"" />
1181  <PropertyGroup>
1182    <Configuration Condition="" '$(Configuration)' == '' "">Debug</Configuration>
1183    <Platform Condition="" '$(Platform)' == '' "">AnyCPU</Platform>
1184    <ProjectGuid>{52F3466B-DD3F-435C-ADA6-CD023CC82E91}</ProjectGuid>
1185    <OutputType>Exe</OutputType>
1186    <StartupObject>ConsoleApplication1.ConsoleApp</StartupObject>
1187    <RootNamespace>ConsoleApplication1</RootNamespace>
1188    <AssemblyName>ConsoleApplication1</AssemblyName>
1189    <FileAlignment>512</FileAlignment>
1190    <MyType>Console</MyType>
1191    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
1192  </PropertyGroup>
1193  <PropertyGroup Condition="" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "">
1194    <PlatformTarget>AnyCPU</PlatformTarget>
1195    <DebugSymbols>true</DebugSymbols>
1196    <DebugType>full</DebugType>
1197    <DefineDebug>true</DefineDebug>
1198    <DefineTrace>true</DefineTrace>
1199    <OutputPath>bin\Debug</OutputPath>
1200    <DocumentationFile>ConsoleApplication1.xml</DocumentationFile>
1201    <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
1202  </PropertyGroup>
1203  <PropertyGroup>
1204    <OptionExplicit>On</OptionExplicit>
1205  </PropertyGroup>
1206  <PropertyGroup>
1207    <OptionCompare>Binary</OptionCompare>
1208  </PropertyGroup>
1209  <PropertyGroup>
1210    <OptionStrict>Off</OptionStrict>
1211  </PropertyGroup>
1212  <PropertyGroup>
1213    <OptionInfer>On</OptionInfer>
1214  </PropertyGroup>
1215  <ItemGroup>
1216    <Import Include=""Microsoft.VisualBasic"" />
1217    <Import Include=""System"" />
1218  </ItemGroup>
1219  <ItemGroup>
1220    <Compile Include=""ConsoleApp.vb"" />
1221  </ItemGroup>
1222  <ItemGroup>
1223    <Reference Include=""obj\debug\assem1.dll"">
1224    </Reference>
1225  </ItemGroup>
1226  <Import Project=""$(MSBuildToolsPath)\Microsoft.VisualBasic.targets"" />
1227  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
1228       Other similar extension points exist, see Microsoft.Common.targets.
1229  <Target Name=""BeforeBuild"">
1230  </Target>
1231  <Target Name=""AfterBuild"">
1232  </Target>
1233  -->
1234</Project>
1235"},
1236{"ConsoleApp.vb", 
1237@"
1238Module ConsoleApp
1239    Sub Main()
1240        Console.WriteLine(""Hello"")
1241        Console.WriteLine(AssemClass.GetNames())
1242        Console.WriteLine(ModClass2.Name)
1243    End Sub
1244End Module
1245"},
1246{"assem1.csproj", 
1247@"<?xml version=""1.0"" encoding=""utf-8""?>
1248<Project ToolsVersion=""4.0"" DefaultTargets=""Build"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
1249  <Import Project=""$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"" Condition=""Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"" />
1250  <PropertyGroup>
1251    <Configuration Condition="" '$(Configuration)' == '' "">Debug</Configuration>
1252    <Platform Condition="" '$(Platform)' == '' "">AnyCPU</Platform>
1253    <ProjectGuid>{1245560C-55E4-49D7-904C-18281B369763}</ProjectGuid>
1254    <OutputType>Library</OutputType>
1255    <AppDesignerFolder>Properties</AppDesignerFolder>
1256    <RootNamespace>assem1</RootNamespace>
1257    <AssemblyName>assem1</AssemblyName>
1258    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
1259    <FileAlignment>512</FileAlignment>
1260  </PropertyGroup>
1261  <PropertyGroup Condition="" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "">
1262    <DebugSymbols>true</DebugSymbols>
1263    <DebugType>full</DebugType>
1264    <Optimize>false</Optimize>
1265    <OutputPath>bin\Debug\</OutputPath>
1266    <DefineConstants>DEBUG;TRACE</DefineConstants>
1267    <ErrorReport>prompt</ErrorReport>
1268    <WarningLevel>4</WarningLevel>
1269  </PropertyGroup>
1270  <ItemGroup>
1271    <Compile Include=""Assem1.cs"" />
1272  </ItemGroup>
1273  <ItemGroup>
1274    <AddModules Include=""obj\Debug\Mod1.netmodule"">
1275    </AddModules>
1276  </ItemGroup>
1277  <ItemGroup>
1278    <Folder Include=""Properties\"" />
1279  </ItemGroup>
1280  <Import Project=""$(MSBuildToolsPath)\Microsoft.CSharp.targets"" />
1281  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
1282       Other similar extension points exist, see Microsoft.Common.targets.
1283  <Target Name=""BeforeBuild"">
1284  </Target>
1285  <Target Name=""AfterBuild"">
1286  </Target>
1287  -->
1288</Project>
1289"},
1290{"Assem1.cs", 
1291@"
1292using System;
1293using System.Collections.Generic;
1294using System.Linq;
1295using System.Text;
1296using System.Threading.Tasks;
1297
1298public class AssemClass
1299{
1300    public static string Name = ""AssemClass"";
1301
1302    public static string GetNames()
1303    {
1304        return Name + "" "" + ModClass.Name;
1305    }
1306}
1307"},
1308{"Mod1.vbproj", 
1309@"<?xml version=""1.0"" encoding=""utf-8""?>
1310<Project ToolsVersion=""4.0"" DefaultTargets=""Build"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
1311  <Import Project=""$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"" Condition=""Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"" />
1312  <PropertyGroup>
1313    <Configuration Condition="" '$(Configuration)' == '' "">Debug</Configuration>
1314    <Platform Condition="" '$(Platform)' == '' "">AnyCPU</Platform>
1315    <ProjectGuid>{DEF6D929-FA03-4076-8A05-7BFA33DCC829}</ProjectGuid>
1316    <OutputType>Module</OutputType>
1317    <RootNamespace>
1318    </RootNamespace>
1319    <AssemblyName>Mod1</AssemblyName>
1320    <FileAlignment>512</FileAlignment>
1321    <MyType>Windows</MyType>
1322    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
1323  </PropertyGroup>
1324  <PropertyGroup Condition="" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "">
1325    <DebugSymbols>true</DebugSymbols>
1326    <DebugType>full</DebugType>
1327    <DefineDebug>true</DefineDebug>
1328    <DefineTrace>true</DefineTrace>
1329    <OutputPath>bin\Debug\</OutputPath>
1330    <DocumentationFile>Mod1.xml</DocumentationFile>
1331    <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
1332  </PropertyGroup>
1333  <PropertyGroup>
1334    <OptionExplicit>On</OptionExplicit>
1335  </PropertyGroup>
1336  <PropertyGroup>
1337    <OptionCompare>Binary</OptionCompare>
1338  </PropertyGroup>
1339  <PropertyGroup>
1340    <OptionStrict>Off</OptionStrict>
1341  </PropertyGroup>
1342  <PropertyGroup>
1343    <OptionInfer>On</OptionInfer>
1344  </PropertyGroup>
1345  <ItemGroup>
1346    <Import Include=""Microsoft.VisualBasic"" />
1347    <Import Include=""System"" />
1348  </ItemGroup>
1349  <ItemGroup>
1350    <Compile Include=""Mod1.vb"" />
1351  </ItemGroup>
1352  <Import Project=""$(MSBuildToolsPath)\Microsoft.VisualBasic.targets"" />
1353  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
1354       Other similar extension points exist, see Microsoft.Common.targets.
1355  <Target Name=""BeforeBuild"">
1356  </Target>
1357  <Target Name=""AfterBuild"">
1358  </Target>
1359  -->
1360</Project>
1361"},
1362{"Mod1.vb", 
1363@"
1364Friend Class ModClass
1365    Public Shared Name As String = ""ModClass""
1366End Class
1367
1368Public Class ModClass2
1369    Public Shared Name As String = ""ModClass2""
1370End Class
1371"}
1372            };
1373        }
1374
1375        [Fact]
1376        [Trait(Traits.Environment, Traits.Environments.VSProductInstall)]
1377        public void UseLibVariableCS()
1378        {
1379            var libDirectory = tempDirectory.CreateDirectory("LibraryDir");
1380
1381            // Create DLL "lib.dll"
1382            Dictionary<string, string> files =
1383                                   new Dictionary<string, string> {
1384                                           { "src1.cs", 
1385@"
1386public class Library 
1387{
1388    public static string GetString()
1389    { return ""library1""; }
1390}"}};
1391
1392            var result = RunCommandLineCompiler(CSharpCompilerClientExecutable,
1393                                                "src1.cs /nologo /t:library /out:" + libDirectory.Path + "\\lib.dll",
1394                                                tempDirectory, files);
1395
1396            Assert.Equal("", result.Output);
1397            Assert.Equal("", result.Errors);
1398            Assert.Equal(0, result.ExitCode);
1399
1400            Temp.AddFile(GetResultFile(libDirectory, "lib.dll"));
1401
1402            // Create EXE "hello1.exe"
1403            files = new Dictionary<string, string> {
1404                                           { "hello1.cs", 
1405@"using System;
1406class Hello 
1407{
1408    public static void Main()
1409    { Console.WriteLine(""Hello1 from {0}"", Library.GetString()); }
1410}"}};
1411            result = RunCommandLineCompiler(CSharpCompilerClientExecutable, "hello1.cs /nologo /r:lib.dll /out:hello1.exe", tempDirectory, files,
1412                                            additionalEnvironmentVars: new Dictionary<string, string>() { { "LIB", libDirectory.Path } });
1413
1414            Assert.Equal("", result.Output);
1415            Assert.Equal("", result.Errors);
1416            Assert.Equal(0, result.ExitCode);
1417
1418            var resultFile = Temp.AddFile(GetResultFile(tempDirectory, "hello1.exe"));
1419        }
1420
1421        [Fact]
1422        [Trait(Traits.Environment, Traits.Environments.VSProductInstall)]
1423        public void UseLibVariableVB()
1424        {
1425            var libDirectory = tempDirectory.CreateDirectory("LibraryDir");
1426
1427            // Create DLL "lib.dll"
1428            Dictionary<string, string> files =
1429                                   new Dictionary<string, string> {
1430                                           { "src1.vb", 
1431@"Imports System
1432Public Class Library 
1433
1434    Public Shared Function GetString() As String
1435        Return ""library1""
1436    End Function
1437End Class
1438"}};
1439
1440            var result = RunCommandLineCompiler(BasicCompilerClientExecutable,
1441                                                "src1.vb /nologo /t:library /out:" + libDirectory.Path + "\\lib.dll",
1442                                                tempDirectory, files);
1443
1444            Assert.Equal("", result.Output);
1445            Assert.Equal("", result.Errors);
1446            Assert.Equal(0, result.ExitCode);
1447
1448            Temp.AddFile(GetResultFile(libDirectory, "lib.dll"));
1449
1450            // Create EXE "hello1.exe"
1451            files = new Dictionary<string, string> {
1452                                           { "hello1.vb", 
1453@"Imports System
1454Module Module1 
1455    Public Sub Main()
1456        Console.WriteLine(""Hello1 from {0}"", Library.GetString())
1457    End Sub
1458End Module
1459"}};
1460            result = RunCommandLineCompiler(BasicCompilerClientExecutable, "hello1.vb /nologo /r:Microsoft.VisualBasic.dll /r:lib.dll /out:hello1.exe", tempDirectory, files,
1461                                            additionalEnvironmentVars: new Dictionary<string, string>() { { "LIB", libDirectory.Path } });
1462
1463            Assert.Equal("", result.Output);
1464            Assert.Equal("", result.Errors);
1465            Assert.Equal(0, result.ExitCode);
1466
1467            var resultFile = Temp.AddFile(GetResultFile(tempDirectory, "hello1.exe"));
1468        }
1469
1470        [WorkItem(545446, "DevDiv")]
1471        [Fact()]
1472        [Trait(Traits.Environment, Traits.Environments.VSProductInstall)]
1473        public void Utf8Output_WithRedirecting_Off_csc2()
1474        {
1475            var srcFile = tempDirectory.CreateFile("test.cs").WriteAllText("♕").Path;
1476            var tempOut = tempDirectory.CreateFile("output.txt");
1477
1478            var result = ProcessLauncher.Run("cmd", string.Format("/C csc2.exe /nologo /t:library {0} > {1}", srcFile, tempOut.Path));
1479
1480            Assert.Equal("", result.Output.Trim());
1481            Assert.Equal("SRC.CS(1,1): error CS1056: Unexpected character '?'".Trim(),
1482                tempOut.ReadAllText().Trim().Replace(srcFile, "SRC.CS"));
1483            Assert.Equal(1, result.ExitCode);
1484        }
1485
1486        [WorkItem(545446, "DevDiv")]
1487        [Fact()]
1488        [Trait(Traits.Environment, Traits.Environments.VSProductInstall)]
1489        public void Utf8Output_WithRedirecting_Off_vbc2()
1490        {
1491            var srcFile = tempDirectory.CreateFile("test.vb").WriteAllText(@"♕").Path;
1492            var tempOut = tempDirectory.CreateFile("output.txt");
1493
1494            var result = ProcessLauncher.Run("cmd", string.Format("/C vbc2.exe /nologo /t:library {0} > {1}", srcFile, tempOut.Path));
1495
1496            Assert.Equal("", result.Output.Trim());
1497            Assert.Equal(@"SRC.VB(1) : error BC30037: Character is not valid.
1498
1499?
1500~
1501".Trim(),
1502                        tempOut.ReadAllText().Trim().Replace(srcFile, "SRC.VB"));
1503            Assert.Equal(1, result.ExitCode);
1504        }
1505
1506        [WorkItem(545446, "DevDiv")]
1507        [Fact()]
1508        [Trait(Traits.Environment, Traits.Environments.VSProductInstall)]
1509        public void Utf8Output_WithRedirecting_On_csc2()
1510        {
1511            var srcFile = tempDirectory.CreateFile("test.cs").WriteAllText("♕").Path;
1512            var tempOut = tempDirectory.CreateFile("output.txt");
1513
1514            var result = ProcessLauncher.Run("cmd", string.Format("/C csc2.exe /utf8output /nologo /t:library {0} > {1}", srcFile, tempOut.Path));
1515
1516            Assert.Equal("", result.Output.Trim());
1517            Assert.Equal("SRC.CS(1,1): error CS1056: Unexpected character '♕'".Trim(),
1518                tempOut.ReadAllText().Trim().Replace(srcFile, "SRC.CS"));
1519            Assert.Equal(1, result.ExitCode);
1520        }
1521
1522        [WorkItem(545446, "DevDiv")]
1523        [Fact()]
1524        [Trait(Traits.Environment, Traits.Environments.VSProductInstall)]
1525        public void Utf8Output_WithRedirecting_On_vbc2()
1526        {
1527            var srcFile = tempDirectory.CreateFile("test.vb").WriteAllText(@"♕").Path;
1528            var tempOut = tempDirectory.CreateFile("output.txt");
1529
1530            var result = ProcessLauncher.Run("cmd", string.Format("/C vbc2.exe /utf8output /nologo /t:library {0} > {1}", srcFile, tempOut.Path));
1531
1532            Assert.Equal("", result.Output.Trim());
1533            Assert.Equal(@"SRC.VB(1) : error BC30037: Character is not valid.
1534
15351536~
1537".Trim(),
1538                        tempOut.ReadAllText().Trim().Replace(srcFile, "SRC.VB"));
1539            Assert.Equal(1, result.ExitCode);
1540        }
1541
1542        [WorkItem(871477, "DevDiv")]
1543        [Fact]
1544        [Trait(Traits.Environment, Traits.Environments.VSProductInstall)]
1545        public void AssemblyIdentityComparer1()
1546        {
1547            tempDirectory.CreateFile("mscorlib20.dll").WriteAllBytes(ProprietaryTestResources.NetFX.v2_0_50727.mscorlib);
1548            tempDirectory.CreateFile("mscorlib40.dll").WriteAllBytes(ProprietaryTestResources.NetFX.v4_0_21006.mscorlib);
1549
1550            // Create DLL "lib.dll"
1551            Dictionary<string, string> files =
1552                                   new Dictionary<string, string> {
1553                                           { "ref_mscorlib2.cs",
1554@"public class C
1555{
1556    public System.Exception GetException()
1557    {
1558        return null;
1559    }
1560}
1561"}};
1562
1563            var result = RunCommandLineCompiler(CSharpCompilerClientExecutable,
1564                                                "ref_mscorlib2.cs /nologo /nostdlib /noconfig /t:library /r:mscorlib20.dll",
1565                                                tempDirectory, files);
1566
1567            Assert.Equal("", result.Output);
1568            Assert.Equal("", result.Errors);
1569            Assert.Equal(0, result.ExitCode);
1570
1571            Temp.AddFile(GetResultFile(tempDirectory, "ref_mscorlib2.dll"));
1572
1573            // Create EXE "main.exe"
1574            files = new Dictionary<string, string> {
1575                                           { "main.cs",
1576@"using System;
1577
1578class Program
1579{
1580    static void Main(string[] args)
1581    {
1582        var e = new C().GetException();
1583        Console.WriteLine(e);
1584    }
1585}
1586"}};
1587            result = RunCommandLineCompiler(CSharpCompilerClientExecutable,
1588                                            "main.cs /nologo /nostdlib /noconfig /r:mscorlib40.dll /r:ref_mscorlib2.dll",
1589                                            tempDirectory, files);
1590
1591            Assert.Equal("", result.Output);
1592            Assert.Equal("", result.Errors);
1593            Assert.Equal(0, result.ExitCode);
1594        }
1595    }
1596}