resharper-vs-code-bridge
v0.0.4
Published
Bridges the gap between the ReSharper CLI's code inspection tools and Visual Studio Code's Problem Matchers to allow ReSharper issues to be exposed in the Visual Studio Code IDE
Downloads
2
Readme
ReSharper -> VS Code Bridge
This is an extremely shabby attempt at getting ReSharper's inspections into Visual Studio Code now that JetBrains have expressed no interest in bringing ReSharper across officially.
Usage
- Install as a dev dependency:
npm i -D resharper-vs-code-bridge
- Download the ReSharper Command Line Tools from https://www.jetbrains.com/resharper/download/#section=resharper-clt
- Extract the tools to a known location and add that directory to your system's PATH variable. Note: This must be added to either the system's PATH or the PATH of the user that runs your VS Code tasks
- Add a task to your
.vscode\tasks.json
as follows:
{
"label": "inspect",
"command": "node",
"type": "process",
"args": [
"node_modules\\resharper-vs-code-bridge",
"MySolution.sln"
],
"problemMatcher": {
"owner": "resharper-vs-code-bridge",
"fileLocation": [
"relative",
"${workspaceFolder}"
],
"pattern": {
"regexp": "Code=\"(.+?)\" Severity=\"(.+?)\" File=\"(.+?)\" Line=\"(.+?)\" Message=\"(.+?)\"",
"code": 1,
"severity": 2,
"file": 3,
"line": 4,
"message": 5
}
}
}
- Run the
inspect
task from theTasks -> Run Task...
menu in VS Code
How it works
The task itself simply runs the resharper-vs-code-bridge NodeJS package, listens for output on STDOUT and then parses it with the provided regex pattern in order to extract code inspection issues and pass them to the IDE.
The package takes one required argument and another optional one. For example:
node node_modules\\resharper-vs-code-bridge MySolution.sln InspectCode.exe
Where:
MySolution.sln
is a required argument defining the path to the solution to inspect relative to the root of your workspaceInspectCode.exe
is an optional argument (default value isInspectCode.exe
) that defines where the package can find ReSharper's executable. This is not required if the PATH was set up as explained above.
The package then does the following:
- Runs
InspectCode.exe
for the solution you defined and outputs the report as a temporary XML file in the root of your workspace - Reads and parses this temporary report in order to collate metadata about each issue into a more suitable format for output to VS Code
- Removes the temporary report file
- Outputs the modified report onto STDOUT in the format specified in the task's pattern
- VS Code then reads this output, runs the regex against it and ends up with a list of inspection issues that it can display in the IDE
Known Limitations
- It's far too slow for any automated approach, because of this I've not put any effort into writing an extension to run the inspections automatically as you code
- Resulting inspection issues do not expose the exact columns of the errors, instead you'll see a squiggly across the whole line. More fine grained reporting is possible, but has not been implemented in this MVP
- No support for specifying the minimum severity ReSharper will report on, currently it will show Suggestions and upwards (i.e. hints are ignored)