You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR simplifies the recently-added HangDumpProcessLifetimeHandler.Disposal.cs (added in #10836, merged in the last 24 hours) to remove duplicated logic between Dispose() and DisposeAsync() while preserving identical behavior.
Files Simplified
src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpProcessLifetimeHandler.Disposal.cs — Extracted the duplicated timer-stopping/gate-claiming logic (identical in Dispose() and DisposeAsync()) into a single private helper method StopTimersAndCaptureActivityTask(out Task? activityIndicatorTask).
Improvements Made
Reduced Duplication
Both Dispose() and DisposeAsync() contained an identical block: dispose the deadline/activity timers, then lock _dumpLock, set _dumpTaken = 1, and capture _activityIndicatorTask. This is now a single shared method called from both places.
Enhanced Clarity
The comment explaining why the timers are stopped and the gate is claimed now lives in one place (on the helper method) instead of being duplicated verbatim in two call sites, reducing the risk of the two copies drifting out of sync over time.
Preserved Behavior
No functional changes: the sync Dispose() still calls .Wait(...) and the async DisposeAsync() still calls .TimeoutAfterAsync(...); only the shared preamble was factored out.
✅ dotnet build src/Platform/Microsoft.Testing.Extensions.HangDump/Microsoft.Testing.Extensions.HangDump.csproj -c Debug succeeds with 0 warnings/errors
⚠️ No dedicated unit test project exists for Microsoft.Testing.Extensions.HangDump; verification is via successful build plus manual review confirming the extracted helper is byte-for-byte equivalent logic
✅ No functional changes - behavior is identical
Review Focus
Please verify:
The extracted helper preserves lock semantics and ordering exactly
🤖 Automated content by GitHub Copilot. Generated by the Code Simplifier workflow. · auto · 72.3 AIC · ⌖ 2.76 AIC · ⊞ 14.1K · [◷]( · ◷)
Add this agentic workflow to your repo
To install this agentic workflow, run
gh aw add githubnext/agentics/workflows/code-simplifier.md@main
expires on Aug 30, 2026, 1:23 PM UTC
Note
This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch code-simplifier/hangdump-disposal-dedup-21523d2872237188.
To fix the permissions issue, go to Settings → Actions → General and enable Allow GitHub Actions to create and approve pull requests. See also: gh-aw FAQ
Show patch preview (80 of 80 lines)
From ae69b8fd57572247457f7578d3d7324fdf61193c Mon Sep 17 00:00:00 2001
X-GH-AW-Base-Commit: 5d831a914a5ed1731123462b19b94d38dd820a21
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Sat, 29 Aug 2026 13:21:28 +0000
Subject: [PATCH] Simplify HangDumpProcessLifetimeHandler disposal by
extracting shared helper
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
...HangDumpProcessLifetimeHandler.Disposal.cs | 37 +++++++++----------
1 file changed, 17 insertions(+), 20 deletions(-)
diff --git a/src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpProcessLifetimeHandler.Disposal.cs b/src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpProcessLifetimeHandler.Disposal.cs
index 631c0ea..94b2bdf 100644
--- a/src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpProcessLifetimeHandler.Disposal.cs+++ b/src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpProcessLifetimeHandler.Disposal.cs@@ -15,17 +15,7 @@ public void Dispose()
// down the pipes. The happy path disposes them in OnTestHostProcessExitedAsync, but that runs
// only on a clean exit; Ctrl+C or an exception skips it, so dispose here too (Timer.Dispose is
// idempotent, so disposing twice is safe).
- _deadlineTimer?.Dispose();- _activityTimer?.Dispose();-- Task? activityIndicatorTask;- lock (_dumpLock)- {- // Claim the gate so no timer callback can start a new dump once we begin tearing down the- // pipes, and capture any dump already in flight so we wait for it below.- _dumpTaken = 1;- activityIndicatorTask = _activityIndicatorTask;- }+ StopTimersAndCaptureActivityTask(out Task? activityIndicatorTask);
if (activityIndicatorTask is not null)
{
@@ -51,24 +41,31 @@ public void Dispose()
_singleConnectionNamedPipeServer?.Dispose();
}
-#if NETCOREAPP- public async ValueTas
... (truncated)
Code Simplification - 2026-08-29
This PR simplifies the recently-added
HangDumpProcessLifetimeHandler.Disposal.cs(added in #10836, merged in the last 24 hours) to remove duplicated logic betweenDispose()andDisposeAsync()while preserving identical behavior.Files Simplified
src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpProcessLifetimeHandler.Disposal.cs— Extracted the duplicated timer-stopping/gate-claiming logic (identical inDispose()andDisposeAsync()) into a single private helper methodStopTimersAndCaptureActivityTask(out Task? activityIndicatorTask).Improvements Made
Reduced Duplication
Dispose()andDisposeAsync()contained an identical block: dispose the deadline/activity timers, then lock_dumpLock, set_dumpTaken = 1, and capture_activityIndicatorTask. This is now a single shared method called from both places.Enhanced Clarity
Preserved Behavior
Dispose()still calls.Wait(...)and the asyncDisposeAsync()still calls.TimeoutAfterAsync(...); only the shared preamble was factored out.Changes Based On
Recent changes from:
Testing
dotnet build src/Platform/Microsoft.Testing.Extensions.HangDump/Microsoft.Testing.Extensions.HangDump.csproj -c Debugsucceeds with 0 warnings/errorsMicrosoft.Testing.Extensions.HangDump; verification is via successful build plus manual review confirming the extracted helper is byte-for-byte equivalent logicReview Focus
Please verify:
StopTimersAndCaptureActivityTask) matches project conventionsWarning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
southcentralus0.in.applicationinsights.azure.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.
Add this agentic workflow to your repo
To install this agentic workflow, run
Note
This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch
code-simplifier/hangdump-disposal-dedup-21523d2872237188.Click here to create the pull request
To fix the permissions issue, go to Settings → Actions → General and enable Allow GitHub Actions to create and approve pull requests. See also: gh-aw FAQ
Show patch preview (80 of 80 lines)