Skip to content

Cancellation updates#1412

Merged
OsirisTerje merged 12 commits into
mainfrom
CancellationUpdates
Feb 24, 2026
Merged

Cancellation updates#1412
OsirisTerje merged 12 commits into
mainfrom
CancellationUpdates

Conversation

@OsirisTerje

@OsirisTerje OsirisTerje commented Feb 13, 2026

Copy link
Copy Markdown
Member

Fixes #1282
Fixes #1361


Note

Medium Risk
Touches cancellation paths and diagnostic file writing around engine execution; behavior changes could affect how/when runs stop and may introduce dump file corruption/perf issues due to read-modify-write appends.

Overview
Improves cancellation behavior/observability in the NUnit adapter by adding additional IsCancelled checks around execution, extra debug/dump logging immediately before/after the engine run, and skipping post-run output generation when cancelled.

Reworks the XML dump writer (DumpXml) to support structured XML elements (with escaping), append new content into an existing dump file, and create the initial execution dump file earlier so cancellation-related diagnostics can be recorded reliably.

Adds extensive cancellation guidance docs (HowToCancelWithNUnit.md, NUnitCancel.md) plus a cleanup/implementation plan (PlanCancel.md), bumps the prerelease package modifier to -alpha.49, and suppresses StyleCop SA1629 via .editorconfig.

Written by Cursor Bugbot for commit 296d06f. This will update automatically on new commits. Configure here.

Comment thread src/NUnitTestAdapter/Dump/DumpXml.cs
Comment thread src/NUnitTestAdapter/ExecutionProcesses/VsTestExecution.cs
txt.Append(text);
txt.Append("\n</NUnitTestEvent>\n");
}
public void AddTestEvent(string text) => AddXmlElement("NUnitTestEvent", $"\n{text}\n");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

XML content incorrectly escaped in dump output

Medium Severity

AddTestEvent now routes through AddXmlElement, which applies EscapeXmlContent to its content. The caller NUnitEventListener.OnTestEvent passes node.AsString() — which is already formatted XML from an XmlNode. This escaping turns tags like <test-case> into &lt;test-case&gt;, corrupting the dump file. The same issue affects DumpVSInputFilter, where filter.Text contains XML (e.g., <cat>, <not><cat>). Previously both methods inserted raw XML content as-is.

Additional Locations (1)

Fix in Cursor Fix in Web

Comment thread docs/NUnitCancel.md
}
```

This approach eliminates the exception by ensuring all tests are properly completed and then exiting cleanly with a success code, which satisfies MTP's session lifecycle requirements without needing complex session end message handling.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Massive debugging log committed as documentation

Medium Severity

NUnitCancel.md is a 4100-line file that reads like an iterative debugging session log rather than documentation. It contains specific error log timestamps (19:23:24.059), "Your Current Error" sections, trial-and-error reflection code, multiple contradictory "CRITICAL FIX" and "IMMEDIATE FIX" headings, and heavily duplicated code snippets trying different approaches. This appears to be AI-assisted debugging notes accidentally committed rather than polished project documentation.

Fix in Cursor Fix in Web

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

}

txt = new StringBuilder(); // Reset for next use
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Appending dump may corrupt closing tag

Medium Severity

AppendToFile removes </NUnitXml> using existingContent.Replace("</NUnitXml>", ""), which strips all occurrences, not just the final closing tag. If the dump ever contains multiple </NUnitXml> strings (e.g., concatenated dumps or embedded raw XML), the append can silently produce malformed XML or drop content.

Fix in Cursor Fix in Web

@OsirisTerje OsirisTerje reopened this Feb 24, 2026
@OsirisTerje OsirisTerje disabled auto-merge February 24, 2026 15:54
@OsirisTerje OsirisTerje merged commit a849e96 into main Feb 24, 2026
6 checks passed
@OsirisTerje OsirisTerje deleted the CancellationUpdates branch February 24, 2026 15:54
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.

dotnet test using MTP with NUnit3TestAdapter cannot be cancelled on CLI [MTP] Cannot stop running tests if parallel testing used

1 participant