Skip to content

Commit 05a9e89

Browse files
encXpdujtipiya
and
pdujtipiya
authored
Fix dotnet build parser to recognize path with space (#161)
Co-authored-by: pdujtipiya <[email protected]>
1 parent 118c078 commit 05a9e89

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Parser/DotnetBuildParser.spec.ts

+8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ describe('DotnetBuildParser tests', () => {
77
const cwdUnix = '/dir';
88

99
const logWithSource = `1:7>C:\\source\\Broken.cs(6,8): warning AG0030: Prevent use of dynamic [C:\\source\\Broken.csproj]`;
10+
const logWithSourceWithSpace = `1:7>C:\\source\\some dir\\Broken.cs(6,8): warning AG0030: Prevent use of dynamic [C:\\source\\some dir\\Broken.csproj]`;
1011
const logWithNoSource = `1:7>CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point [C:\\source\\Broken.csproj]`;
1112
const logWithUnrelatedSource = `9:8>/usr/share/dotnet/sdk/3.1.402/Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3277: some message [/dir/Tests/project.csproj]`;
1213
const contentWithNoPathAtTheEnd = `13:11>/dir/File.csproj : warning NU1701: This package may not be fully compatible with your project.`;
@@ -78,4 +79,11 @@ describe('DotnetBuildParser tests', () => {
7879
it('should ignore multiline-part messages', () => {
7980
expect(() => new DotnetBuildParser(cwdUnix).parse(multilinePart)).not.toThrowError();
8081
});
82+
83+
it('should handle path with space', () => {
84+
const items = new DotnetBuildParser(cwdWin).parse(logWithSourceWithSpace);
85+
const result = items[0];
86+
87+
expect(result.source).toBe('some dir/Broken.cs');
88+
});
8189
});

src/Parser/DotnetBuildParser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class DotnetBuildParser extends Parser {
1919

2020
private toLintItem(log: string): LintItem {
2121
const structureMatch = log.match(
22-
/(?:[\d:>]+)?([^ ()]+)(?:\((\d+),(\d+)\))? *: *(\w+) *(\w+) *: *([^\[]+)(?:\[(.+)])?$/,
22+
/(?:[\d:>]+)?([^>()]+)(?:\((\d+),(\d+)\))? *: *(\w+) *(\w+) *: *([^\[]+)(?:\[(.+)])?$/,
2323
);
2424
if (!structureMatch) {
2525
const message = "DotnetBuildParser Error: log structure doesn't match";

0 commit comments

Comments
 (0)