/// <summary>
        /// Ctor
        /// </summary>
        /// <param name="parameters">Caller-specified command parameters. Will throw if the parameters
        /// are invalid.</param>
        internal LocationHelper(CommandParameters parameters)
        {
            if (!parameters.TryGetString(CommandConstStrings.OutputPath, out string outputPath))
            {
                outputPath = GetEnvironmentVariablePathValue() ?? GetFallbackPathValue();
            }

            if (string.IsNullOrWhiteSpace(outputPath))
            {
                throw new A11yAutomationException(DisplayStrings.ErrorOutputPathIsTrivial);
            }

            if (!parameters.TryGetString(CommandConstStrings.OutputFile, out string outputFile))
            {
                throw new A11yAutomationException(DisplayStrings.ErrorOutputFileIsNotSpecified);
            }

            if (string.IsNullOrWhiteSpace(outputFile))
            {
                throw new A11yAutomationException(DisplayStrings.ErrorOutputFileIsTrivial);
            }

            if (!Directory.Exists(outputPath))
            {
                Directory.CreateDirectory(outputPath);
            }

            string outputFileFormat = null;
            string extension        = Path.GetExtension(outputFile);

            // If extension is missing in the file name
            if (string.IsNullOrWhiteSpace(extension))
            {
                // If output file format is PRESENT check it is valid
                if (parameters.TryGetString(CommandConstStrings.OutputFileFormat, out outputFileFormat))
                {
                    if (string.IsNullOrWhiteSpace(outputFileFormat))
                    {
                        throw new A11yAutomationException(DisplayStrings.ErrorOutputFileFormatIsTrivial);
                    }
                    outputFileFormat = ValidateExtension(outputFileFormat);
                }
                else
                {
                    // If file format absent set default value
                    outputFileFormat = ValidateExtension(SarifExtension);
                }
            }
            else
            {
                // Validate the extension that was passed in the filename
                outputFileFormat = ValidateExtension(extension);
                outputFile       = Path.GetFileNameWithoutExtension(outputFile);
            }

            // If extension is present in the filename and a fileformat is also being passed in, we will honor the extension in the filename.
            this.OutputPath       = outputPath;
            this.OutputFileFormat = outputFileFormat;
            this.OutputFile       = outputFile;
        }
 /// <summary>
 /// Check to see if files should be retained even when no violations are found
 /// </summary>
 /// <param name="parameters">The CommandParameters object to check</param>
 /// <returns>true iff files are always retained, even if no errors exist.
 /// Retention is our default behavior unless we're explicitly told to discard</returns>
 internal static bool RetainIfNoViolations(this CommandParameters parameters)
 {
     return(!(parameters.TryGetString(CommandConstStrings.NoViolationPolicy, out string policy) &&
              policy.Equals(CommandConstStrings.Discard, StringComparison.OrdinalIgnoreCase)));
 }