Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ public Task CanCompileReferencesWithResourcesWithCsc()
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task CanCompileReferencesWithResourcesWithMcs()
{
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task CanCompileTestCaseWithCsc()
{
Expand All @@ -57,12 +51,6 @@ public Task CanCompileTestCaseWithDebugPdbs()
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task CanCompileTestCaseWithMcs()
{
return RunTest(allowMissingWarnings: true);
}

[Fact]
public Task CanSandboxDependenciesUsingType()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public enum TestRunCharacteristics
TargetingNetFramework = 1,
TargetingNetCore = 2,
SupportsDefaultInterfaceMethods = 8,
SupportsStaticInterfaceMethods = 16,
TestFrameworkSupportsMcs = 32
SupportsStaticInterfaceMethods = 16
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
<Content Include="TestFramework\Dependencies\CanCompileReferencesWithResources_Lib1.txt" />
<Content Include="TestFramework\Dependencies\CanCompileReferencesWithResources_Lib1.log" />
<Content Include="TestFramework\Dependencies\CanCompileTestCaseWithCsc.txt" />
<Content Include="TestFramework\Dependencies\CanCompileTestCaseWithMcs.txt" />
<Content Include="TestFramework\Dependencies\VerifyResourceInAssemblyAttributesBehavior.txt" />
</ItemGroup>
<ItemGroup>
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
Expand Down Expand Up @@ -388,72 +387,7 @@ protected virtual NPath CompileCSharpAssemblyWithRoslyn(CompilerOptions options)

protected virtual NPath CompileCSharpAssemblyWithCsc(CompilerOptions options)
{
#if NET
return CompileCSharpAssemblyWithRoslyn(options);
#else
return CompileCSharpAssemblyWithExternalCompiler(LocateCscExecutable(), options, "/shared ");
#endif
}

protected virtual NPath CompileCSharpAssemblyWithMcs(CompilerOptions options)
{
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
CompileCSharpAssemblyWithExternalCompiler(LocateMcsExecutable(), options, string.Empty);

return CompileCSharpAssemblyWithDefaultCompiler(options);
}

protected static NPath CompileCSharpAssemblyWithExternalCompiler(string executable, CompilerOptions options, string compilerSpecificArguments)
{
var capturedOutput = new List<string>();
var process = new Process();
process.StartInfo.FileName = executable;
process.StartInfo.Arguments = OptionsToCompilerCommandLineArguments(options, compilerSpecificArguments);
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.StartInfo.RedirectStandardOutput = true;
process.OutputDataReceived += (sender, args) => capturedOutput.Add(args.Data);
process.Start();
process.BeginOutputReadLine();
process.WaitForExit();

if (process.ExitCode != 0)
Assert.Fail($"Failed to compile assembly with csc: {options.OutputPath}\n{capturedOutput.Aggregate((buff, s) => buff + Environment.NewLine + s)}");

return options.OutputPath;
}

static string LocateMcsExecutable()
{
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
Assert.Ignore("We don't have a universal way of locating mcs on Windows");

return "mcs";
}

protected static string OptionsToCompilerCommandLineArguments(CompilerOptions options, string compilerSpecificArguments)
{
var builder = new StringBuilder();
if (!string.IsNullOrEmpty(compilerSpecificArguments))
builder.Append(compilerSpecificArguments);
builder.Append($"/out:{options.OutputPath}");
var target = options.OutputPath.ExtensionWithDot == ".exe" ? "exe" : "library";
builder.Append($" /target:{target}");
if (options.Defines != null && options.Defines.Length > 0)
builder.Append(options.Defines.Aggregate(string.Empty, (buff, arg) => $"{buff} /define:{arg}"));

builder.Append(options.References.Aggregate(string.Empty, (buff, arg) => $"{buff} /r:{arg}"));

if (options.Resources != null && options.Resources.Length > 0)
builder.Append(options.Resources.Aggregate(string.Empty, (buff, arg) => $"{buff} /res:{arg}"));

if (options.AdditionalArguments != null && options.AdditionalArguments.Length > 0)
builder.Append(options.AdditionalArguments.Aggregate(string.Empty, (buff, arg) => $"{buff} {arg}"));

builder.Append(options.SourceFiles.Aggregate(string.Empty, (buff, arg) => $"{buff} {arg}"));

return builder.ToString();
}

protected NPath CompileCSharpAssembly(CompilerOptions options)
Expand All @@ -464,9 +398,6 @@ protected NPath CompileCSharpAssembly(CompilerOptions options)
if (options.CompilerToUse == "csc")
return CompileCSharpAssemblyWithCsc(options);

if (options.CompilerToUse == "mcs")
return CompileCSharpAssemblyWithMcs(options);

throw new ArgumentException($"Invalid compiler value `{options.CompilerToUse}`");
}

Expand Down
Loading