Skip to content
Open
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
4 changes: 4 additions & 0 deletions Tests/UnitTests/ClassificationFormatTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ private static IEnumerable<Type> GetAllExportedFormats()

private String GetCorrectName(Type formatType)
{
if (formatType == typeof(BuildProjectHeaderFormatDefinition))
{
return "Output enhancer: Build project header";
}
if (formatType == typeof(BuildMessageErrorFormatDefinition))
{
return "Output enhancer: Build error message";
Expand Down
14 changes: 14 additions & 0 deletions Tests/UnitTests/Classifiers/BuildOutputClassifierTestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ namespace Balakin.VSOutputEnhancer.Tests.UnitTests.Classifiers
[ExcludeFromCodeCoverage]
public abstract class BuildOutputClassifierTestsBase : ClassifierTestsBase
{
[Fact]
public void BuildProjectHeader()
{
const String buildCompleteMessage = "1>------ Build started: Project: UnitTests, Configuration: Debug Any CPU ------\r\n";
var span = Utils.CreateSpan(buildCompleteMessage);

var expectedResult = new[]
{
new ClassificationSpan(span, new ClassificationTypeStub(ClassificationType.BuildProjectHeader))
};

Test(span, expectedResult);
}

[Fact]
public void BuildFailed()
{
Expand Down
48 changes: 48 additions & 0 deletions Tests/UnitTests/Parsers/BuildProjectHeaderParserTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System;
using System.Diagnostics.CodeAnalysis;
using Balakin.VSOutputEnhancer.Parsers;
using Balakin.VSOutputEnhancer.Parsers.BuildProjectHeader;
using FluentAssertions;
using Microsoft.VisualStudio.Text;
using Xunit;

namespace Balakin.VSOutputEnhancer.Tests.UnitTests.Parsers
{
[ExcludeFromCodeCoverage]
public class BuildProjectHeaderParserTests
{
[Theory]
[InlineData("Message\r\n")]
[InlineData("1>------ Publish: 10 succeeded, 3 failed, 122 skipped\r\n")]
[InlineData("------ Anything ------\r\n")]
[InlineData("Anything ------\r\n")]
public void NotParsed(String message)
{
var span = Utils.CreateSpan(message);
var parser = new BuildProjectHeaderParser();
BuildProjectHeaderData parsedData;
var parsed = parser.TryParse(span, out parsedData);

parsed.Should().BeFalse();
parsedData.Should().BeNull();
}

[Fact]
public void Build()
{
const String publishCompleteMessage = "1>------ Rebuild All started: Project: VSOutputEnhancer, Configuration: Debug Any CPU ------\r\n";
var expectedResult = new BuildProjectHeaderData(
new ParsedValue<Int32>(1, new Span(0, 1)),
new ParsedValue<String>("Rebuild All started: Project: VSOutputEnhancer, Configuration: Debug Any CPU", new Span(9, 76))
);

var span = Utils.CreateSpan(publishCompleteMessage);
BuildProjectHeaderData parsedData;
var parser = new BuildProjectHeaderParser();
var parsed = parser.TryParse(span, out parsedData);

parsed.Should().BeTrue();
parsedData.ShouldBeEquivalentTo(expectedResult);
}
}
}
2 changes: 2 additions & 0 deletions Tests/UnitTests/ParsersConfigurationServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Diagnostics.CodeAnalysis;
using Balakin.VSOutputEnhancer.Parsers.BowerMessage;
using Balakin.VSOutputEnhancer.Parsers.BuildFileRelatedMessage;
using Balakin.VSOutputEnhancer.Parsers.BuildProjectHeader;
using Balakin.VSOutputEnhancer.Parsers.BuildResult;
using Balakin.VSOutputEnhancer.Parsers.DebugException;
using Balakin.VSOutputEnhancer.Parsers.DebugTraceMessage;
Expand Down Expand Up @@ -33,6 +34,7 @@ private void TestBuildOutput(String contentType)
{
var expectedResult = new[]
{
new ParserConfiguration(typeof(BuildProjectHeaderParser), typeof(BuildProjectHeaderData), typeof(BuildProjectHeaderProcessor)),
new ParserConfiguration(typeof(BuildResultParser), typeof(BuildResultData), typeof(BuildResultDataProcessor)),
new ParserConfiguration(typeof(BuildFileRelatedMessageParser), typeof(BuildFileRelatedMessageData), typeof(BuildFileRelatedMessageDataProcessor)),
new ParserConfiguration(typeof(PublishResultParser), typeof(PublishResultData), typeof(PublishResultDataProcessor)),
Expand Down
5 changes: 5 additions & 0 deletions Tests/UnitTests/StyleManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ public void SimilarClassificationTypesHasSimilarColors(Theme theme)
{
ClassificationType.DebugTraceInformation
};
var info = new[]
{
ClassificationType.BuildProjectHeader
};

TestSimilarColors(error.Select(styleManager.GetStyleForClassificationType).ToList(), "error");
TestSimilarColors(warning.Select(styleManager.GetStyleForClassificationType).ToList(), "warning");
Expand All @@ -67,6 +71,7 @@ public void SimilarClassificationTypesHasSimilarColors(Theme theme)
.Except(warning)
.Except(success)
.Except(skip)
.Except(info)
.ToList();
notChecked.Should().BeEmpty("Classification types did not checked: " + String.Join(", ", notChecked));
}
Expand Down
1 change: 1 addition & 0 deletions Tests/UnitTests/UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
<Compile Include="Classifiers\BowerOutputClassifierTests.cs" />
<Compile Include="Classifiers\BuildOutputClassifierTestsBase.cs" />
<Compile Include="Parsers\BowerMessageParserTests.cs" />
<Compile Include="Parsers\BuildProjectHeaderParserTests.cs" />
<Compile Include="Parsers\NpmResultParserTests.cs" />
<Compile Include="Parsers\NpmMessageParserTests.cs" />
<Compile Include="Classifiers\BuildOrderOutputClassifierTests.cs" />
Expand Down
3 changes: 3 additions & 0 deletions VSOutputEnhancer/ClassificationType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ internal static class ClassificationType
{
BuildMessageError,
BuildMessageWarning,
BuildProjectHeader,
BuildResultFailed,
BuildResultSucceeded,
PublishResultFailed,
Expand All @@ -25,6 +26,8 @@ internal static class ClassificationType
BowerMessageError
};

public const String BuildProjectHeader = "BuildProjectHeader";

public const String BuildMessageError = "BuildMessageError";
public const String BuildMessageWarning = "BuildMessageWarning";

Expand Down
4 changes: 4 additions & 0 deletions VSOutputEnhancer/Exports/ClassificationTypeExports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ namespace Balakin.VSOutputEnhancer.Exports
{
internal static class ClassificationTypeExports
{
[Export(typeof(ClassificationTypeDefinition))]
[Name(ClassificationType.BuildProjectHeader)]
public static ClassificationTypeDefinition BuildProjectHeader;

[Export(typeof(ClassificationTypeDefinition))]
[Name(ClassificationType.BuildResultSucceeded)]
public static ClassificationTypeDefinition BuildResultSucceeded;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Text.Classification;
using Microsoft.VisualStudio.Utilities;

namespace Balakin.VSOutputEnhancer.Exports.Formats
{
[Export(typeof(EditorFormatDefinition))]
[ClassificationType(ClassificationTypeNames = ClassificationType.BuildProjectHeader)]
[Name(ClassificationType.BuildProjectHeader)]
[UserVisible(false)]
[Order(Before = Priority.Default)]
internal sealed class BuildProjectHeaderFormatDefinition : StyledClassificationFormatDefinition
{
[ImportingConstructor]
public BuildProjectHeaderFormatDefinition(IStyleManager styleManager) : base(styleManager)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;

namespace Balakin.VSOutputEnhancer.Parsers.BuildProjectHeader
{
// TODO: Review accessibility level
public class BuildProjectHeaderData : ParsedData
{
// TODO: Refactor ParsedData builder to get rid of this constructor
public BuildProjectHeaderData()
{
}

public BuildProjectHeaderData(
ParsedValue<Int32> buildTaskId,
ParsedValue<String> fullMessage)
{
BuildTaskId = buildTaskId;
FullMessage = fullMessage;
}

// This properties filled using reflection
// ReSharper disable UnusedAutoPropertyAccessor.Local
public ParsedValue<Int32> BuildTaskId { get; private set; }
public ParsedValue<String> FullMessage { get; private set; }
// ReSharper restore UnusedAutoPropertyAccessor.Local
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Text.RegularExpressions;
using Microsoft.VisualStudio.Text;

namespace Balakin.VSOutputEnhancer.Parsers.BuildProjectHeader
{
[UseForClassification(ContentType.BuildOutput)]
[UseForClassification(ContentType.BuildOrderOutput)]
internal class BuildProjectHeaderParser : IParser<BuildProjectHeaderData>
{
public Boolean TryParse(SnapshotSpan span, out BuildProjectHeaderData result)
{
var text = span.GetText();

result = null;
if (!text.EndsWith(" ------\r\n", StringComparison.Ordinal))
{
return false;
}

var regex = $"^(?:(?<BuildTaskId>\\d+)>)------ (?<FullMessage>.*) ------\r\n$";

var match = Regex.Match(text, regex, RegexOptions.Compiled);
if (!match.Success)
{
return false;
}

result = ParsedData.Create<BuildProjectHeaderData>(match, span.Span);
return true;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.Text;

namespace Balakin.VSOutputEnhancer.Parsers.BuildProjectHeader
{
internal class BuildProjectHeaderProcessor : IParsedDataProcessor<BuildProjectHeaderData>
{
public IEnumerable<ProcessedParsedData> ProcessData(SnapshotSpan span, BuildProjectHeaderData parsedData)
{
if (parsedData == null)
{
yield break;
}

yield return new ProcessedParsedData(span, ClassificationType.BuildProjectHeader);
}
}
}
9 changes: 9 additions & 0 deletions VSOutputEnhancer/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions VSOutputEnhancer/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@
<data name="FormatDisplayName_BuildResultFailed" xml:space="preserve">
<value>Output enhancer: Build failed</value>
</data>
<data name="FormatDisplayName_BuildProjectHeader" xml:space="preserve">
<value>Output enhancer: Build project header</value>
</data>
<data name="FormatDisplayName_BuildResultSucceeded" xml:space="preserve">
<value>Output enhancer: Build succeeded</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions VSOutputEnhancer/Resources/DarkTheme.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"BuildProjectHeader": {
"ForegroundColor": "#00FFFF"
},
"BuildMessageError": {
"ForegroundColor": "#D85050"
},
Expand Down
3 changes: 3 additions & 0 deletions VSOutputEnhancer/Resources/LightTheme.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"BuildProjectHeader": {
"ForegroundColor": "#00FFFF"
},
"BuildMessageError": {
"ForegroundColor": "#BF0606"
},
Expand Down
4 changes: 4 additions & 0 deletions VSOutputEnhancer/VSOutputEnhancer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
<Compile Include="Exports\Formats\BuildMessageErrorFormatDefinition.cs" />
<Compile Include="Exports\Formats\BuildMessageWarningFormatDefinition.cs" />
<Compile Include="Exports\Formats\BuildResultFailedFormatDefinition.cs" />
<Compile Include="Exports\Formats\BuildProjectHeaderFormatDefinition.cs" />
<Compile Include="Exports\Formats\BuildResultSucceededFormatDefinition.cs" />
<Compile Include="Exports\Formats\DebugExceptionFormatDefinition.cs" />
<Compile Include="Exports\Formats\DebugTraceErrorFormatDefinition.cs" />
Expand All @@ -105,6 +106,9 @@
<Compile Include="Parsers\BowerMessage\BowerMessageData.cs" />
<Compile Include="Parsers\BowerMessage\BowerMessageDataProcessor.cs" />
<Compile Include="Parsers\BowerMessage\BowerMessageParser.cs" />
<Compile Include="Parsers\BuildProjectHeader\BuildProjectHeaderData.cs" />
<Compile Include="Parsers\BuildProjectHeader\BuildProjectHeaderParser.cs" />
<Compile Include="Parsers\BuildProjectHeader\BuildProjectHeaderProcessor.cs" />
<Compile Include="Parsers\EnumValueAttribute.cs" />
<Compile Include="Parsers\NpmResult\NpmResultData.cs" />
<Compile Include="Parsers\NpmResult\NpmResultDataProcessor.cs" />
Expand Down