Repository navigation
[ResourceLock] Replace broad DoNotParallelize with narrow ResourceLock in CrashDumpTests - #11192
Merged
Amaury Levé (Evangelink) merged 2 commits intoSep 11, 2026
Conversation
…ests Microsoft.Testing.Extensions.UnitTests is parallelized with [assembly: Parallelize(Scope = ExecutionScope.MethodLevel, Workers = 0)]. OnTestHostProcessExitedAsync_ProcessKilledByHangDump_DeletesSequenceFileAndDoesNotPublishArtifacts carried a class-wide-effective [DoNotParallelize] even though it touches exactly one process-wide resource: the AppDomain.CurrentDomain data slot "ProcessKilledByHangDump" read by CrashDumpProcessLifetimeHandler and written by HangDumpProcessLifetimeHandler. No other test in the project reads or writes that slot, so a method-level [ResourceLock] on this one test is sufficient and lets it run concurrently with the rest of the class again. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unlocked tests indirectly read the shared AppDomain slot and can race with the modified test.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Refactors CrashDump unit-test synchronization from broad non-parallel execution to a named resource lock.
Changes:
- Adds a constant identifying the AppDomain data slot resource.
- Replaces
[DoNotParallelize]with a method-level[ResourceLock].
File summaries
| File | Description |
|---|---|
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/CrashDumpTests.cs |
Narrows synchronization for the process-killed-by-hang-dump test. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Amaury Levé (Evangelink)
marked this pull request as ready for review
September 11, 2026 08:05
Amaury Levé (Evangelink)
approved these changes
Sep 11, 2026
Amaury Levé (Evangelink)
enabled auto-merge (squash)
September 11, 2026 08:05
Cover indirect CrashDump handler readers with a shared read lock and upgrade the AppDomain-slot mutator to exclusive access. Require the refactoring workflow to trace production read sets and prove declaration coverage before removing DoNotParallelize. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This was referenced Sep 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the original ResourceLock refactoring so the process-wide
AppDomainslot is protected for both its writer and every indirect reader, and hardens the generating workflow against repeating this mistake.Test synchronization fix
Microsoft.Testing.Extensions.UnitTestsruns with method-level parallelization.CrashDumpTests.OnTestHostProcessExitedAsync_ProcessKilledByHangDump_DeletesSequenceFileAndDoesNotPublishArtifactstemporarily writes the process-wide"ProcessKilledByHangDump"AppDomain slot, while several other tests indirectly read it throughCrashDumpProcessLifetimeHandler.OnTestHostProcessExitedAsync.The class now declares:
and the mutating test retains the same key with the default
ReadWritemode. This lets read-only tests remain concurrent with each other while excluding them whenever the slot is being changed.Workflow hardening
The ResourceLock refactoring workflow now requires a resource coverage matrix before removing
[DoNotParallelize]:It explicitly rejects literal-key grep as sufficient evidence, requires a declaration-reconciliation self-review against the parallel-safety audit rubric, and fails closed by retaining
[DoNotParallelize]or producing no PR when any observer is unknown or uncovered.Validation
.\build.cmd -projects "$PWD\test\UnitTests\Microsoft.Testing.Extensions.UnitTests\Microsoft.Testing.Extensions.UnitTests.csproj" -test -bl— succeeded with 0 warnings and 0 errors; tests passed on net462, net472, net8.0, and net9.0.gh aw compile resource-lock-refactoring --strict --no-check-update— succeeded.python .github/scripts/check_action_pins.py— passed; 2,546 references checked.