Remove DisplayDiagnostics() from RoslynScriptEngine.cs

This commit is contained in:
tawan0109 2016-07-21 20:53:12 +08:00
Родитель fc968fbb1e
Коммит c2766fd479
1 изменённых файлов: 2 добавлений и 24 удалений

Просмотреть файл

@ -100,13 +100,8 @@ namespace Microsoft.Spark.CSharp
if (hasErrors)
{
DisplayDiagnostics(diagnostics);
var message = new StringBuilder();
foreach (var diagnostic in diagnostics)
{
message.Append("[").Append(diagnostic.Severity).Append("] ").Append(": ").Append(diagnostic).Append("\r\n");
}
return new ScriptResult(compilationException: new Exception(message.ToString()));
var diagnosticMessages = diagnostics.Select(diagnostic => "[" + diagnostic.Severity + "] " + diagnostic).ToList();
return new ScriptResult(compilationException: new Exception(string.Join("\r\n", diagnosticMessages)));
}
var compilationDump = DumpCompilation(script.GetCompilation());
@ -146,23 +141,6 @@ namespace Microsoft.Spark.CSharp
}
}
internal void DisplayDiagnostics(IEnumerable<Diagnostic> diagnostics)
{
// refer to http://source.roslyn.io/#Microsoft.CodeAnalysis.Scripting/Hosting/CommandLine/CommandLineRunner.cs,268
try
{
foreach (var diagnostic in diagnostics)
{
Console.ForegroundColor = (diagnostic.Severity == DiagnosticSeverity.Error) ? ConsoleColor.Red : ConsoleColor.Yellow;
Console.WriteLine(diagnostic.ToString());
}
}
finally
{
Console.ResetColor();
}
}
/// <summary>
/// Check whether the given code is a complete submission
/// </summary>