Skip to content

Update pattern to match current dotnet format output #491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
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: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ jobs:

strategy:
matrix:
node: [12, 14, 16]
node: [20]

steps:
- name: Check out repo
uses: actions/checkout@v4.0.0

- name: Install Node
uses: actions/setup-node@v3.8.1
uses: actions/setup-node@v4.0.2
with:
node-version: ${{ matrix.node }}

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.101
dotnet-version: 7.0.x
- uses: xt0rted/dotnet-format-problem-matcher@v1
- run: dotnet tool install -g dotnet-format
- run: dotnet-format --dry-run
- run: dotnet format --no-restore --verify-no-changes
```

![Example of inline annotations](docs/annotations.png)
Expand All @@ -36,3 +36,4 @@ Name | Allowed values | Description
## License

The scripts and documentation in this project are released under the [MIT License](LICENSE)

35 changes: 20 additions & 15 deletions __tests__/problemMatcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ describe("problemMatcher", () => {

describe("pattern", () => {
const reportOutput = [
" Formatting code files in workspace 'C:\\dev\\application\\application.sln'.",
" src\\ConsoleApp\\Program.cs(5,18): Fix whitespace formatting 1.",
" src\\ConsoleApp\\Program.cs(8,30): Fix whitespace formatting 2.",
" Formatted code file 'Program.cs'.",
" Format complete in 4451ms.",
"/path/file.cs(15,2): error WHITESPACE: Fix whitespace formatting. Insert '\t'. [/path/project.csproj]",
"/path/file.cs(15,3): error WHITESPACE: Fix whitespace formatting. Replace 4 characters with '\n\t\t\t'. [/path/project.csproj]",
"/path/file.cs(16,84): error WHITESPACE: Fix whitespace formatting. Replace 4 characters with '\n\t\t\t'. [/path/project.csproj]",
];

let pattern: ProblemPattern;
Expand All @@ -34,19 +32,26 @@ describe("problemMatcher", () => {
});

it("matches violations", () => {
expect(results.length).toEqual(2);
expect(results.length).toEqual(3);
});

it("matches violation details", () => {
expect(results[0][pattern.file]).toEqual("src\\ConsoleApp\\Program.cs");
expect(results[0][pattern.line]).toEqual("5");
expect(results[0][pattern.column]).toEqual("18");
expect(results[0][pattern.message]).toEqual("Fix whitespace formatting 1.");

expect(results[1][pattern.file]).toEqual("src\\ConsoleApp\\Program.cs");
expect(results[1][pattern.line]).toEqual("8");
expect(results[1][pattern.column]).toEqual("30");
expect(results[1][pattern.message]).toEqual("Fix whitespace formatting 2.");
expect(results[0][pattern.file]).toEqual("/path/file.cs");
expect(results[0][pattern.line]).toEqual("15");
expect(results[0][pattern.column]).toEqual("2");
expect(results[0][pattern.message]).toEqual("Fix whitespace formatting. Insert '\t'.");
expect(results[0][pattern.severity]).toEqual("error");
expect(results[0][pattern.code]).toEqual("WHITESPACE");

expect(results[1][pattern.file]).toEqual("/path/file.cs");
expect(results[1][pattern.line]).toEqual("15");
expect(results[1][pattern.column]).toEqual("3");
expect(results[1][pattern.message]).toEqual("Fix whitespace formatting. Replace 4 characters with '\n\t\t\t'.");

expect(results[2][pattern.file]).toEqual("/path/file.cs");
expect(results[2][pattern.line]).toEqual("16");
expect(results[2][pattern.column]).toEqual("84");
expect(results[2][pattern.message]).toEqual("Fix whitespace formatting. Replace 4 characters with '\n\t\t\t'.");
});
});
});
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ inputs:
default: add

runs:
using: "node12"
using: "node20"
main: "dist/index.js"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"build": "tsc",
"lint": "tsc --noEmit",
"package": "ncc build src/main.ts",
"package": "ncc build src/main.ts && cp src/*.json dist/",
"release": "npm run package && git add -f dist/",
"test": "jest"
},
Expand Down
7 changes: 5 additions & 2 deletions src/problem-matcher.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
"owner": "dotnet-format",
"pattern": [
{
"regexp": "^\\s+(.*)\\((\\d+),(\\d+)\\):\\s+(.*)$",
"regexp": "^\\s*(.*)\\((\\d+),(\\d+)\\): (\\w+) ([^:]+): ([^\\[]+) \\[(.*)\\]",
"file": 1,
"line": 2,
"column": 3,
"message": 4
"severity": 4,
"code": 5,
"message": 6,
"fromPath": 7
}
]
}
Expand Down