From 9dba5c6c1f79121a1a6a9245544edde579f003b9 Mon Sep 17 00:00:00 2001 From: Gabe Stocco <98900+gfs@users.noreply.github.com> Date: Thu, 14 Mar 2024 18:23:47 +0000 Subject: [PATCH] Fix Default Option Settings When Deserializing Options Json (#610) * Fix Default Option Settings When Deserializing Options Json OutputTextFormat and OutputFileFormat were defaulting to string.Empty when deserialized because the default set for instantiating differed from the default value used for command parsing. * Update Changelog.md --- Changelog.md | 4 ++++ .../Options/BaseAnalyzeCommandOptions.cs | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index 781f1481..44e2430c 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.0.33] - 2024-3-13 +### Fix +Fixes properly setting the default value for the `OutputFileFormat` and `OutputTextFormat` fields when using the `options-json` argument to the analyze command. + ## [1.0.32] - 2024-3-04 ### Pipeline Improvement to pipeline to allow rerunning failed deploy jobs. diff --git a/DevSkim-DotNet/Microsoft.DevSkim.CLI/Options/BaseAnalyzeCommandOptions.cs b/DevSkim-DotNet/Microsoft.DevSkim.CLI/Options/BaseAnalyzeCommandOptions.cs index 12d04e00..826da8b4 100644 --- a/DevSkim-DotNet/Microsoft.DevSkim.CLI/Options/BaseAnalyzeCommandOptions.cs +++ b/DevSkim-DotNet/Microsoft.DevSkim.CLI/Options/BaseAnalyzeCommandOptions.cs @@ -31,10 +31,10 @@ public record BaseAnalyzeCommandOptions : LogOptions public string CommentsPath { get; set; } = string.Empty; [Option('o', "output-format", HelpText = "Format for output text.", Default = SimpleTextWriter.DefaultFormat)] - public string OutputTextFormat { get; set; } = string.Empty; + public string OutputTextFormat { get; set; } = SimpleTextWriter.DefaultFormat; [Option('f', "file-format", HelpText = "Format type for output. [text|sarif]", Default = "sarif")] - public string OutputFileFormat { get; set; } = string.Empty; + public string OutputFileFormat { get; set; } = "sarif"; [Option('s', "severity", HelpText = "Comma-separated Severities to match", Separator = ',', Default = new[] { Severity.Critical, Severity.Important, Severity.Moderate, Severity.BestPractice, Severity.ManualReview })] public IEnumerable Severities { get; set; } = new[] { Severity.Critical, Severity.Important, Severity.Moderate, Severity.BestPractice, Severity.ManualReview };