Repository navigation
Description
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 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 inDispose()andDisposeAsync()) into a single private helper methodStopTimersAndCaptureActivityTask(out Task? activityIndicatorTask).
Improvements Made
-
Reduced Duplication
- Both
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.
- Both
-
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 asyncDisposeAsync()still calls.TimeoutAfterAsync(...); only the shared preamble was factored out.
- No functional changes: the sync
Changes Based On
Recent changes from:
- Cache generated acceptance test builds #10811 "Cache generated acceptance test builds" (repository-wide merge that included Refactor hang dump process lifetime handler #10836 "Refactor hang dump process lifetime handler", which introduced the duplicated code being simplified here)
Testing
- ✅
dotnet build src/Platform/Microsoft.Testing.Extensions.HangDump/Microsoft.Testing.Extensions.HangDump.csproj -c Debugsucceeds with 0 warnings/errors ⚠️ No dedicated unit test project exists forMicrosoft.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
- No unintended side effects from the refactor
- Naming (
StopTimersAndCaptureActivityTask) matches project conventions
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
southcentralus0.in.applicationinsights.azure.com
To allow these domains, add them to the network.allowed list in your workflow frontmatter:
network:
allowed:
- defaults
- "southcentralus0.in.applicationinsights.azure.com"See Network Configuration for more information.
🤖 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)
Activity
github-actions commentedon Aug 30, 2026
This issue was automatically closed because it expired on 2026-08-30T13:23:07.922Z.
Evangelink commentedon Aug 31, 2026
Completed by #10857.