Skip to content

Commit 5959d74

Browse files
eOkadasbradwilson
authored andcommitted
#1816 Error message doesn't respect -nocolor option (#1824)
setting a NoColoring bool in TransformFactory if the related CommandLine switch was used. this commit was amended to fix missing 'static' keyword
1 parent 975ff0c commit 5959d74

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/xunit.console/CommandLine.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ protected XunitProject Parse(Predicate<string> fileExists)
170170
{
171171
GuardNoOptionValue(option);
172172
NoColor = true;
173+
TransformFactory.NoErrorColoring = NoColor;
173174
}
174175
else if (optionName == "noappdomain") // Here for historical reasons
175176
{

src/xunit.console/Utility/TransformFactory.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ public class TransformFactory
1414

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

17+
public static bool NoErrorColoring = false;
18+
1719
protected TransformFactory()
1820
{
1921
availableTransforms.Add("xml", new Transform
@@ -65,9 +67,15 @@ static void Handler_DirectWrite(XElement xml, string outputFileName)
6567
static void Handler_XslTransform(string key, string resourceName, XElement xml, string outputFileName)
6668
{
6769
#if NETCOREAPP1_0
68-
ConsoleHelper.SetForegroundColor(ConsoleColor.Yellow);
70+
if(!NoErrorColoring)
71+
{
72+
ConsoleHelper.SetForegroundColor(ConsoleColor.Yellow);
73+
}
6974
Console.WriteLine($"Skipping -{key} because XSL-T is not supported on .NET Core 1.x");
70-
ConsoleHelper.ResetColor();
75+
if(!NoErrorColoring)
76+
{
77+
ConsoleHelper.ResetColor();
78+
}
7179
#else
7280
var xmlTransform = new System.Xml.Xsl.XslCompiledTransform();
7381

0 commit comments

Comments
 (0)