Skip to content

Conversation

gfs
Copy link
Contributor

@gfs gfs commented Jun 9, 2025

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).

  <Target Name="Run DevSkim" BeforeTargets="Build">
    <Exec Command="devskim analyze -I . -f vs" />
  </Target>

Adds an output format to using devskim in a csproj build task to populate the diagnostic window.
@gfs gfs requested a review from Copilot June 9, 2025 16:32
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 vs case in the writer factory with a default format string for MSBuild errors/warnings
  • Implements %V token in SimpleTextWriter and maps DevSkim severities to Visual Studio severities
  • Updates CLI options to advertise the new vs file-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 same SimpleTextWriter or 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 uses json for SARIF. Align this help text with the actual keywords (e.g., [text|json|vs]) or adjust the factory to accept sarif as an alias for json.
[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 DevSkimSevToVsSev to verify each severity maps to the expected Visual Studio severity string and to cover the default (_) case.
private string DevSkimSevToVsSev(Severity ruleSeverity)

@gfs gfs merged commit c6cbc9b into main Jun 10, 2025
16 checks passed
@gfs gfs deleted the gfs/AddVsOutputFormatToCli branch June 10, 2025 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants