Skip to content

Fix dotCover parameter syntax - #4899

Open
flaviolazzarini wants to merge 21 commits into
cake-build:developfrom
flaviolazzarini:feature/fix-dot-cover-tool
Open

flaviolazzarini wants to merge 21 commits into
cake-build:developfrom
flaviolazzarini:feature/fix-dot-cover-tool

Conversation

@flaviolazzarini

Copy link
Copy Markdown

As of dotCover 2025.2 JetBrains made significant changes to the parameter syntax of dotCover. Some changes where already made in #4670. Unfortunately not all commands and parameters have been covered. This pull request adds compatibility for the following commands:

  • merge
  • report

analyse has not been covered, as it's not a supported command anymore.

For a complete list of the commands and their parameters see https://www.jetbrains.com/help/dotcover/dotCover__Console_Runner_Commands.html#help

This fixes #4096

@flaviolazzarini

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="exanicAG"

@devlead
devlead force-pushed the feature/fix-dot-cover-tool branch from 381c835 to 8182caa Compare June 24, 2026 17:31

@devlead devlead left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The direction looks sound and aligns with #4670, but I found one blocking regression and some medium/minor things that should be fixed before merge.

Blocking

DotCoverReport ignores outputFile in new syntax (the default path)

With UseLegacySyntax = false (default), the 3-arg API Report(sourceFile, outputFile, settings) never passes outputFile to the CLI. GenerateArguments only emits --snapshot-source and optional JsonReportOutput / XmlReportOutput from settings.

This breaks the common call pattern:

DotCoverReport(source, new FilePath("./result.xml"), new DotCoverReportSettings());

Previously, this produced /Output=...; now it runs with no output path. The new-syntax tests always set OutputFile = null, so there's no coverage for the default fixture path with a non-null output file.

Suggested fix: When !UseLegacySyntax && outputFile != null, map to the appropriate new flag (e.g., --xml-report-output for default ReportType.XML, --json-report-output for ReportType.JSON). I'd also add a test for that path.

Medium

  • Legacy filters are silently dropped on cover: Scope, Filters, AttributeFilters, ProcessFilters, and DisableDefaultFilters are ignored in the new syntax. Scripts using .WithFilter(...) without .WithLegacySyntax() will lose filters with no warning. I'd document this in the release notes and consider a runtime warning when legacy filter collections are populated, but UseLegacySyntax is false.
  • HTML / DetailedXML / NDependXML are legacy-only: New report syntax only supports --json-report-output and --xml-report-output. The new DotCoverReport alias example still shows ReportType = HTML, which won't work without legacy syntax.

Minor

  • DotCoverReportSettings: XmlReportOutput / XmlReportCoveringTestsScope XML comments say "JSON report" (looks like copy-paste).
  • DotCoverReporter.Report(source, settings) XML doc says "Cover" instead of "Report".
  • Test regions: typo "Paramter" → "Parameter".
  • No DotCoverMerge alias for optional output (tool-level overload exists).
  • analyse unchanged, fine with me if that's acknowledged and the command is deprecated in dotCover 2025.2+.

What looks good

  • merge / report new syntax (--snapshot-source, --snapshot-output, --temporary-directory, --log-file) looks correct to me.
  • Moving UseLegacySyntax to base DotCoverSettings makes sense.
  • Lowercase command names match the 2025.2 convention.
  • Good legacy vs new test split; build and unit tests pass locally on my machine.

Summary

Area My take
merge Good
report Please fix outputFile regression
cover OK, I'd document filter migration
Tests Missing main report output case

@devlead devlead left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for addressing the June review. The outputFile mapping, filter warnings, XML examples, comment typos, and merge-without-output overloads look good.

A few remaining items before merge:

Blocking

  • analyse + LogFile: GetArguments now emits --log-file unless UseLegacySyntax is true. DotCoverAnalyse still always uses legacy /Target* /Output flags, so the default path mixes syntax. The analyser test was updated to set UseLegacySyntax = true rather than keeping analyse on /LogFile.
  • Unsupported ReportType: HTML / DetailedXML / NDependXML silently map to --xml-report-output.
  • Settings mutation: mapping outputFile writes into the caller's XmlReportOutput / JsonReportOutput.

Medium

  • DotCoverMerge(sourceFiles, settings) is missing [CakeMethodAlias] (and the usual null checks), so Cake scripts will not see that overload.
  • The new 2-arg report example uses DotCoverReportType.Xml (invalid; enum is XML).
  • WithLegacySyntax() is still cover-only even though the flag now lives on DotCoverSettings.
  • The existing DotCoverCover example still uses .WithFilter(...) without .WithLegacySyntax() or --exclude-assemblies, so it documents the drop-and-warn path.

Process

  • CI on this PR is red (looks like the original June run). Please re-run after the follow-up.
  • Please call out in release notes: default 2025.2 syntax, filter → --exclude-*, report types XML/JSON only, optional merge output, analyse remaining legacy-only.

merge / report new flags look correct against current JetBrains docs.

Comment on lines +67 to +76
if (settings.UseLegacySyntax)
{
var logFilePath = settings.LogFile.MakeAbsolute(_environment);
builder.AppendSwitch("/LogFile", "=", logFilePath.FullPath.Quote());
}
else
{
var logFilePath = settings.LogFile.MakeAbsolute(_environment);
builder.AppendSwitch("--log-file", logFilePath.FullPath.Quote());
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

DotCoverAnalyse always emits legacy /TargetExecutable, /Output, etc., then calls this helper. With the default UseLegacySyntax = false, LogFile becomes --log-file mixed into an otherwise legacy command line.

Please keep analyse on /LogFile unconditionally (or treat analyse as always-legacy). Updating the analyser test to set UseLegacySyntax = true hides the mixed-syntax default rather than fixing it.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Removed.

// Given
var fixture = new DotCoverAnalyserFixture();
fixture.Settings.LogFile = "./logfile.log";
fixture.Settings.UseLegacySyntax = true;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This was added so the assertion still expects /LogFile=, but the real alias default never sets UseLegacySyntax. Prefer a test (and implementation) where analyse uses /LogFile without requiring this flag, plus a cover/merge/report test that --log-file is used on the new-syntax path.

Comment on lines +54 to +68
if (!settings.UseLegacySyntax && outputFile != null)
{
// map outputFile to new syntax parameters. Otherwise input is ignored
switch (settings.ReportType)
{
case DotCoverReportType.XML:
settings.XmlReportOutput = outputFile;
break;
case DotCoverReportType.JSON:
settings.JsonReportOutput = outputFile;
break;
default:
settings.XmlReportOutput = outputFile;
break;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Two issues here:

  1. This mutates the caller's settings (XmlReportOutput / JsonReportOutput), including overwriting values they already set. Map outputFile only when building arguments.
  2. HTML / DetailedXML / NDependXML fall through default to --xml-report-output with no warning. Those types are legacy-only in 2025.2. Please throw or warn and require UseLegacySyntax instead of silently emitting XML.

/// <code>
/// DotCoverReport(new FilePath("./result.dcvr"),
/// new DotCoverReportSettings {
/// ReportType = DotCoverReportType.Xml

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

DotCoverReportType.Xml does not exist (the enum member is XML). This example also still keys off ReportType, which the new-syntax 2-arg overload does not emit — prefer XmlReportOutput / JsonReportOutput here.

Comment on lines +317 to +326
public static void DotCoverMerge(
this ICakeContext context,
IEnumerable<FilePath> sourceFiles,
DotCoverMergeSettings settings)
{
var merger = new DotCoverMerger(
context.FileSystem, context.Environment,
context.ProcessRunner, context.Tools);
merger.Merge(sourceFiles, settings);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This overload is missing [CakeMethodAlias], [CakeAliasCategory("Merge")], and [CakeNamespaceImport(...)], so it will not be imported into Cake scripts. Please also null-check context / settings like the other merge aliases.

// Set the Temporary directory.
if (settings.TemporaryDirectory != null)
{
settings.TemporaryDirectory = settings.TemporaryDirectory.MakeAbsolute(_environment);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same mutation smell as report: this overwrites settings.TemporaryDirectory with the absolute path. Use a local MakeAbsolute result when appending the switch.

/// When false, uses new format like '--target-executable "/path"'.
/// Default is false (new format).
/// </summary>
public bool UseLegacySyntax { get; set; }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Moving this to the base class is the right call. WithLegacySyntax() is still only on DotCoverCoverSettings, so merge/report/analyse users have to set the property. A generic extension on DotCoverSettings would keep the fluent API consistent.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DotCover aliasses are using windows style cli arguments on unix-like systems

3 participants