Add MSBuild Diagnostic Format Output Option - #689
Merged
Conversation
Adds an output format to using devskim in a csproj build task to populate the diagnostic window.
Contributor
There was a problem hiding this comment.
Pull Request Overview
Adds support for a new “vs” output format so DevSkim results can be emitted in MSBuild/Visual Studio diagnostic style.
- Introduces a
vscase in the writer factory with a default format string for MSBuild errors/warnings - Implements
%Vtoken inSimpleTextWriterand maps DevSkim severities to Visual Studio severities - Updates CLI options to advertise the new
vsfile-format
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| DevSkim-DotNet/Microsoft.DevSkim.CLI/Writers/WriterFactory.cs | Added case "vs" to return a SimpleTextWriter with VS layout |
| DevSkim-DotNet/Microsoft.DevSkim.CLI/Writers/SimpleTextWriter.cs | Added %V token docs, imported severity enum, and mapping method |
| DevSkim-DotNet/Microsoft.DevSkim.CLI/Options/BaseAnalyzeCommandOptions.cs | Extended file-format option help/default to include vs |
Comments suppressed due to low confidence (3)
DevSkim-DotNet/Microsoft.DevSkim.CLI/Writers/WriterFactory.cs:22
- The CLI help lists a "text" format but WriterFactory only handles "vs" and "json" (for SARIF). Either add a
case "text"that returns the sameSimpleTextWriteror update the help/options to only list the actual supported formats.
case "vs":
DevSkim-DotNet/Microsoft.DevSkim.CLI/Options/BaseAnalyzeCommandOptions.cs:36
- The help text refers to
[text|sarif|vs], but the factory usesjsonfor SARIF. Align this help text with the actual keywords (e.g.,[text|json|vs]) or adjust the factory to acceptsarifas an alias forjson.
[Option('f', "file-format", HelpText = "Format type for output. [text|sarif|vs]", Default = "sarif")]
DevSkim-DotNet/Microsoft.DevSkim.CLI/Writers/SimpleTextWriter.cs:74
- Consider adding unit tests for
DevSkimSevToVsSevto verify each severity maps to the expected Visual Studio severity string and to cover the default (_) case.
private string DevSkimSevToVsSev(Severity ruleSeverity)
Dan Fiedler (danfiedler-msft)
approved these changes
Jun 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an output format to use devskim in a csproj build task to populate the diagnostic window.
Intended as an alternative to the VS extension.
To use, one would add something like the following to your csproj (this specific example assuming having the devskim tool installed on your system path like with
dotnet tool install -g Microsoft.CST.DevSkim.CLI).