Cancellation updates#1412
Conversation
…elling a session.
| txt.Append(text); | ||
| txt.Append("\n</NUnitTestEvent>\n"); | ||
| } | ||
| public void AddTestEvent(string text) => AddXmlElement("NUnitTestEvent", $"\n{text}\n"); |
There was a problem hiding this comment.
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 <test-case>, 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)
| } | ||
| ``` | ||
|
|
||
| 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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 | ||
| } |
There was a problem hiding this comment.
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.


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
IsCancelledchecks 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 StyleCopSA1629via.editorconfig.Written by Cursor Bugbot for commit 296d06f. This will update automatically on new commits. Configure here.