Skip to content

Commit

Permalink
#1816 Error message doesn't respect -nocolor option (#1824)
Browse files Browse the repository at this point in the history
setting a NoColoring bool in TransformFactory
if the related CommandLine switch was used.
this commit was amended to fix missing 'static' keyword
  • Loading branch information
eOkadas authored and bradwilson committed Oct 2, 2018
1 parent 975ff0c commit 5959d74
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/xunit.console/CommandLine.cs
Expand Up @@ -170,6 +170,7 @@ protected XunitProject Parse(Predicate<string> fileExists)
{
GuardNoOptionValue(option);
NoColor = true;
TransformFactory.NoErrorColoring = NoColor;
}
else if (optionName == "noappdomain") // Here for historical reasons
{
Expand Down
12 changes: 10 additions & 2 deletions src/xunit.console/Utility/TransformFactory.cs
Expand Up @@ -14,6 +14,8 @@ public class TransformFactory

readonly Dictionary<string, Transform> availableTransforms = new Dictionary<string, Transform>(StringComparer.OrdinalIgnoreCase);

public static bool NoErrorColoring = false;

protected TransformFactory()
{
availableTransforms.Add("xml", new Transform
Expand Down Expand Up @@ -65,9 +67,15 @@ static void Handler_DirectWrite(XElement xml, string outputFileName)
static void Handler_XslTransform(string key, string resourceName, XElement xml, string outputFileName)
{
#if NETCOREAPP1_0
ConsoleHelper.SetForegroundColor(ConsoleColor.Yellow);
if(!NoErrorColoring)
{
ConsoleHelper.SetForegroundColor(ConsoleColor.Yellow);
}
Console.WriteLine($"Skipping -{key} because XSL-T is not supported on .NET Core 1.x");
ConsoleHelper.ResetColor();
if(!NoErrorColoring)
{
ConsoleHelper.ResetColor();
}
#else
var xmlTransform = new System.Xml.Xsl.XslCompiledTransform();

Expand Down

0 comments on commit 5959d74

Please sign in to comment.