Add --crash-report-if-supported and --hangdump-type-if-supported options - #8666

Merged
Amaury Levé (Evangelink) merged 5 commits into
mainfrom
dev/amauryleve/crash-report-if-supported
May 31, 2026
Merged

Add --crash-report-if-supported and --hangdump-type-if-supported options#8666
Amaury Levé (Evangelink) merged 5 commits into
mainfrom
dev/amauryleve/crash-report-if-supported

Conversation

@Evangelink

@EvangelinkAmaury Levé (Evangelink) commented May 28, 2026

Copy link
Copy Markdown
Member

Closes#7126 (companion options for --crash-report and --hangdump-type).

Problem

@bart-vmware pointed out that --crash-report errors out on Windows because the .NET runtime ignores DOTNET_EnableCrashReportOnly there. The same kind of friction exists for --hangdump-type Triage on .NET Framework (Triage is a netcoreapp-only dump type). The current behaviour forces consumers to maintain different CLI commands per OS / TFM in their CI scripts.

Solution

Introduce two new -if-supported companion options that behave identically to the strict variants when the underlying mechanism is supported, and silently no-op (with a single info line on the console) when it is not.

StrictNew companion
--crash-report (errors on Windows)--crash-report-if-supported (no-op on Windows / .NET Framework)
--hangdump-type <Mini|Heap|Full|Triage|None> (Triage rejected on netfx)--hangdump-type-if-supported <…> (Triage on netfx maps to Mini)

This lets users keep a single CI invocation across all build legs.

Naming rationale

We considered short forms (--crash-report?, --crash-report-best-effort, etc.) and decided on the explicit long -if-supported suffix:

  • The semantics are obvious from the name.
  • A short form would still need aliasing in the parser; the saving is small.
  • Future -if-supported variants can follow the same pattern.

Behaviour matrix

--crash-report-if-supported

RuntimeOSBehaviour
.NET FrameworkWindows / Linux / macOSNo-op (info message)
.NET (Core)WindowsNo-op (info message)
.NET (Core)Linux / macOSSame as --crash-report

Mutually exclusive with --crash-report.

--hangdump-type-if-supported <type>

TFMRequested typeResult
.NET (Core)any of Mini, Heap, Full, Triage, NoneHonored unchanged
.NET FrameworkMini / Heap / Full / NoneHonored unchanged
.NET FrameworkTriageMapped to Mini (info message), as Mini is the closest equivalent

Mutually exclusive with --hangdump-type.

Implementation notes

The lifetime handler's IsEnabledAsync returns true for the no-op case (so it can emit the info message), but the env-var provider's IsEnabledAsync and the lifecycle methods are gated on IsCrashReportEffective / IsHangDumpTypeSupportedOnCurrentRuntime to avoid:

  • Hard-erroring on .NET Framework via ValidateTestHostEnvironmentVariablesAsync.
  • Setting DbgEnableMiniDump=1 on Windows when the mechanism is known to be ignored.
  • Tripping ApplicationStateGuard.Ensure checks on a dump file name pattern that was never set up.

Tests

  • Unit tests for IsCrashReportEffective and MapToSupportedDumpType (added to CrashDumpTests / HangDumpTests).
  • Validation tests: mutual-exclusion error, accepted alongside --crashdump, never rejected on any platform, satisfies the -main-option-missing rule, both variants registered as arity-0.
  • Updated HelpInfoAllExtensionsTests expectations for both human-readable and structured --info output.

Local validation: 85/89 tests pass on net8.0 (4 Windows-skipped pre-existing CrashReport tests), 84/88 on net472 (same 4 skipped). Production projects (Microsoft.Testing.Extensions.CrashDump, Microsoft.Testing.Extensions.HangDump) and the unit-test project all build clean (0 warnings, 0 errors).

Acceptance tests for end-to-end behaviour aren't included here yet; happy to follow up if reviewers want them.

Why not an environment variable?

@bart-vmware also suggested keeping the hard error but letting users opt into a "downgrade to info" via an environment variable. We discarded that route in favour of an explicit CLI option for the following reasons:

  • Discoverability. A new CLI option shows up in --help / --info and is grep-able in CI scripts. An environment variable only surfaces when the user already hit the error and read the message, which is exactly the friction we are trying to remove.
  • Self-documenting CI scripts.--crash-report-if-supported clearly conveys the user's intent ("I want a crash report when I can get one"). A script that sets MTP_ALLOW_UNSUPPORTED_CRASH_REPORT=1 (or similar) and then calls --crash-report hides that intent in the environment.
  • Scope. An env-var-suppression mechanism would need to be replicated per option family (--crash-report, --hangdump-type Triage, plus every future option in the same situation), inflating the env-var surface. The -if-supported suffix is a uniform naming convention we can reuse going forward.
  • Local debugging. When investigating a build leg, an explicit CLI flag is much easier to reason about than "is there an environment variable set somewhere up the call stack?". Env vars also leak between commands in a CI step.
  • Composability. Users who genuinely want to fail fast on unsupported runtimes can keep using the strict --crash-report / --hangdump-type — the two variants coexist, are mutually exclusive at validation time, and a single CI matrix can mix the two if it really wants to.

The strict --crash-report / --hangdump-type are unchanged, so callers that prefer the fail-fast contract keep their current behaviour.

Companion options that silently no-op when the underlying mechanism is
unsupported on the current OS/TFM, so a single CLI line works on every
build leg (issue #7126).
- --crash-report-if-supported (arity 0): mirrors --crash-report but is
ignored on Windows (DOTNET_EnableCrashReportOnly is not honored there)
and on .NET Framework (no createdump runtime).
- --hangdump-type-if-supported <Mini|Heap|Full|Triage|None> (arity 1):
mirrors --hangdump-type but maps requested types unsupported on the
current TFM (today: Triage on .NET Framework) to the closest
equivalent (Mini).
Each variant emits a single informational line when it no-ops so users
can see the substitution happened.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings May 28, 2026 16:47

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds “best-effort” companion CLI options in Microsoft.Testing.Platform diagnostics extensions to reduce CI matrix friction by silently no-op’ing (with a single console message) when the underlying crash-report or dump-type mechanism isn’t supported on the current runtime/OS.

Changes:

  • Add --crash-report-if-supported (CrashDump) and --hangdump-type-if-supported (HangDump) options with mutual-exclusion validation against their strict counterparts.
  • Implement runtime/OS gating and fallback behavior (CrashReport ignored on Windows/.NET Framework; HangDump type mapping when requested type isn’t supported).
  • Add/extend unit tests, update help/info acceptance expectations, and update localized resources.
Show a summary per file
FileDescription
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/HangDumpTests.csAdds unit coverage for --hangdump-type-if-supported validation, mutual exclusion, and mapping helpers.
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/CrashDumpTests.csAdds unit coverage for --crash-report-if-supported, mutual exclusion, arity, and “effective” gating helper.
test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoAllExtensionsTests.csUpdates --help / --info expectations to include the new options and their descriptions.
src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpCommandLineProvider.csRegisters --hangdump-type-if-supported, validates values across TFMs, enforces mutual exclusion, and adds mapping helpers.
src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpProcessLifetimeHandler.csApplies best-effort dump-type mapping and emits a single message when a fallback occurs.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/ExtensionResources.resxAdds new HangDump option description + mutual-exclusion/fallback messages.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.cs.xlfLocalization update for new HangDump strings (Czech).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.de.xlfLocalization update for new HangDump strings (German).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.es.xlfLocalization update for new HangDump strings (Spanish).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.fr.xlfLocalization update for new HangDump strings (French).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.it.xlfLocalization update for new HangDump strings (Italian).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ja.xlfLocalization update for new HangDump strings (Japanese).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ko.xlfLocalization update for new HangDump strings (Korean).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.pl.xlfLocalization update for new HangDump strings (Polish).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.pt-BR.xlfLocalization update for new HangDump strings (Portuguese - Brazil).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ru.xlfLocalization update for new HangDump strings (Russian).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.tr.xlfLocalization update for new HangDump strings (Turkish).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.zh-Hans.xlfLocalization update for new HangDump strings (Chinese Simplified).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.zh-Hant.xlfLocalization update for new HangDump strings (Chinese Traditional).
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpCommandLineOptions.csDefines the new crash-report-if-supported option name constant.
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpCommandLineProvider.csRegisters --crash-report-if-supported, enforces mutual exclusion, and treats it as a main option.
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpEnvironmentVariableProvider.csGates env-var application via IsCrashReportEffective so Windows/.NET Framework no-op cases don’t error.
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpProcessLifetimeHandler.csEnables handler for --crash-report-if-supported to emit the informational line and avoids artifact scanning when ineffective.
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/CrashDumpResources.resxAdds CrashDump option description + mutual-exclusion and “ignored” info messages; updates Windows unsupported message.
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.cs.xlfLocalization update for new CrashDump strings (Czech).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.de.xlfLocalization update for new CrashDump strings (German).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.es.xlfLocalization update for new CrashDump strings (Spanish).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.fr.xlfLocalization update for new CrashDump strings (French).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.it.xlfLocalization update for new CrashDump strings (Italian).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.ja.xlfLocalization update for new CrashDump strings (Japanese).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.ko.xlfLocalization update for new CrashDump strings (Korean).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.pl.xlfLocalization update for new CrashDump strings (Polish).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.pt-BR.xlfLocalization update for new CrashDump strings (Portuguese - Brazil).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.ru.xlfLocalization update for new CrashDump strings (Russian).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.tr.xlfLocalization update for new CrashDump strings (Turkish).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.zh-Hans.xlfLocalization update for new CrashDump strings (Chinese Simplified).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.zh-Hant.xlfLocalization update for new CrashDump strings (Chinese Traditional).

Copilot's findings

  • Files reviewed: 37/37 changed files
  • Comments generated: 3

Aligns three locations that still described --hangdump-type-if-supported
as falling back to the default 'Full' (the original design) instead of
the actual closest-supported-type mapping (Triage -> Mini on netfx):
- HangDumpCommandLineProvider.cs: AllHangDumpTypeOptions comment.
- HelpInfoAllExtensionsTests.cs: --help and --info expectations.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Review of PR #8666--crash-report-if-supported / --hangdump-type-if-supported

Summary

The overall design is sound and well-structured: the new -if-supported companions are wired in at every layer (CLI validation, env-var provider, lifecycle callbacks), the mutual-exclusion checks are correct, the IsCrashReportEffective predicate cleanly avoids double-activation, and the MapToSupportedDumpType / IsHangDumpTypeSupportedOnCurrentRuntime pair is a solid runtime-dispatch pattern.

21-dimension verdict

#DimensionVerdictNotes
1Algorithmic CorrectnessIsCrashReportEffective, MapToSupportedDumpType, and the IsCrashHandlingEffective guard all trace correctly for every branch (netfx/net·win/net·unix). ApplicationStateGuard.Ensure guards are preserved.
2Threading & Concurrency⚠️_ifSupportedIgnoredMessageEmitted is a non-volatilebool read/written across potential thread switches; see inline comment.
3SecurityNo new file operations or untrusted input.
4Public API / Binary CompatAll new constants and helpers are internal. No PublicAPI.Unshipped.txt changes needed.
5PerformanceCold path only; no hot-path impact.
6Cross-TFM Compatibility#if !NETCOREAPP / #if NET guards are correct and consistent.
7Resource / IDisposableNo new disposables.
8Defensive CodingExisting ApplicationStateGuard.Ensure guards preserved; new guards added only for the effective paths.
9LocalizationAll strings in .resx. XLF files carry target state="new" markers (build-generated, not hand-edited).
10Test IsolationNo shared static mutable state added.
11Assertion QualityUnit tests use MSTest assertions as required for MTP test projects.
12FlakinessNo time-dependent assertions.
13CLI / Option Consistency⚠️--hangdump-type-if-supported is classified as a "sub-option" (requires --hangdump), consistent with --hangdump-type — but the option name implies it could stand alone. The PR description says this is intentional; worth a note in the --help description or error message so users aren't confused.
14Output / UX⚠️WarningMessageOutputDeviceData (yellow) used for graceful no-op paths. When the user chose -if-supportedbecause they expect the platform not to support it, a yellow warning is noise. See inline comments on CrashDumpProcessLifetimeHandler.cs:102 and HangDumpProcessLifetimeHandler.cs:121.
15Test CoverageUnit tests cover IsCrashReportEffective, MapToSupportedDumpType, mutual exclusion, and argument validation.
16Naming & ConventionsNaming is clear and consistent with the existing --crashdump / --hangdump family.
17Comment QualityInline comments are detailed and reference the upstream runtime issue (dotnet/runtime#80191).
18Error MessagesMutual-exclusion messages guide the user toward the correct option.
19Scope DisciplinePR is tightly focused on the two new companion options.
20Help/Info Test UpdatesHelpInfoAllExtensionsTests expectations updated.
21XLF / Localization PipelineXLF files correctly updated with target state="new" by the build tool.

Actionable items

  1. _ifSupportedIgnoredMessageEmitted — add volatile (CrashDumpProcessLifetimeHandler.cs:44): the "emit once" guard can be bypassed under concurrent test-host restarts without a memory barrier.
  2. WarningMessageOutputDeviceData → informational format (CrashDumpProcessLifetimeHandler.cs:102/110, HangDumpProcessLifetimeHandler.cs:121): the -if-supported variants are explicitly opt-in best-effort; a yellow warning contradicts the intent and adds noise to CI logs.

Generated by Expert Code Review (on open) for issue #8666 · sonnet46 3.6M

- Use FormattedTextOutputDeviceData instead of WarningMessageOutputDeviceData
for the '-if-supported' no-op / fallback messages. These are expected,
graceful paths; rendering them as yellow warnings would mislead CI users.
(CrashDumpProcessLifetimeHandler.cs x2, HangDumpProcessLifetimeHandler.cs x1)
- Replace the plain bool one-shot guard in CrashDumpProcessLifetimeHandler
with Interlocked.Exchange on an int field, so that concurrent invocations
(e.g. test-host controller retries) cannot race past the guard. Also
restructure to early-return when the option will not emit anything on the
current runtime/OS, so the guard is only claimed when we actually emit.
- Collapse the nested 'if' in HangDumpCommandLineProvider.ValidateOptionArgumentsAsync
for --hangdump-type-if-supported into a single conditional return (also
satisfies IDE0046).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings May 28, 2026 17:12

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

Comments suppressed due to low confidence (1)

test/UnitTests/Microsoft.Testing.Extensions.UnitTests/CrashDumpTests.cs:359

  • The placeholder-to-regex conversion test no longer covers several common createdump placeholders/pattern shapes (e.g. %e, %h, %t, literal-only patterns). Those DataRow cases previously validated that placeholders are expanded to wildcards across multiple tokens and adjacent placeholders; dropping them reduces coverage for BuildDumpFileNameRegexPattern and makes regressions easier to miss.
  • Files reviewed: 37/37 changed files
  • Comments generated: 1

…ents
The earlier comment in CrashDumpEnvironmentVariableProvider above the
'crashReportEnabled' assignment said 'IsEnabledAsync gates this method,
so at least one of --crashdump / --crash-report / --crash-report-if-supported
is set here.' That wording suggested '--crash-report-if-supported' alone
is sufficient to reach UpdateAsync / ValidateTestHostEnvironmentVariablesAsync
even on Windows / .NET Framework, where the option is intentionally a
no-op (IsCrashReportEffective returns false and IsEnabledAsync is false
unless '--crashdump' is also set).
Reword both occurrences to refer to an *effective* crash-report request
so future readers do not misinterpret the precondition.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings May 29, 2026 16:45

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 37/37 changed files
  • Comments generated: 0 new

@Evangelink
Amaury Levé (Evangelink) merged commit 35f4f1e into mainMay 31, 2026
25 of 26 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/crash-report-if-supported branch May 31, 2026 06:41
Amaury Levé (Evangelink) added a commit that referenced this pull request May 31, 2026
…om PR #8666 (#8716)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for freeto 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.

Add option to collect gcdump (MTPv2)

2 participants

@Evangelink
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Add --crash-report-if-supported and --hangdump-type-if-supported options - #8666

Merged
Amaury Levé (Evangelink) merged 5 commits into
mainfrom
dev/amauryleve/crash-report-if-supported
May 31, 2026
Merged

Add --crash-report-if-supported and --hangdump-type-if-supported options#8666
Amaury Levé (Evangelink) merged 5 commits into
mainfrom
dev/amauryleve/crash-report-if-supported

Conversation

@Evangelink

@EvangelinkAmaury Levé (Evangelink) commented May 28, 2026

Copy link
Copy Markdown
Member

Closes#7126 (companion options for --crash-report and --hangdump-type).

Problem

@bart-vmware pointed out that --crash-report errors out on Windows because the .NET runtime ignores DOTNET_EnableCrashReportOnly there. The same kind of friction exists for --hangdump-type Triage on .NET Framework (Triage is a netcoreapp-only dump type). The current behaviour forces consumers to maintain different CLI commands per OS / TFM in their CI scripts.

Solution

Introduce two new -if-supported companion options that behave identically to the strict variants when the underlying mechanism is supported, and silently no-op (with a single info line on the console) when it is not.

StrictNew companion
--crash-report (errors on Windows)--crash-report-if-supported (no-op on Windows / .NET Framework)
--hangdump-type <Mini|Heap|Full|Triage|None> (Triage rejected on netfx)--hangdump-type-if-supported <…> (Triage on netfx maps to Mini)

This lets users keep a single CI invocation across all build legs.

Naming rationale

We considered short forms (--crash-report?, --crash-report-best-effort, etc.) and decided on the explicit long -if-supported suffix:

  • The semantics are obvious from the name.
  • A short form would still need aliasing in the parser; the saving is small.
  • Future -if-supported variants can follow the same pattern.

Behaviour matrix

--crash-report-if-supported

RuntimeOSBehaviour
.NET FrameworkWindows / Linux / macOSNo-op (info message)
.NET (Core)WindowsNo-op (info message)
.NET (Core)Linux / macOSSame as --crash-report

Mutually exclusive with --crash-report.

--hangdump-type-if-supported <type>

TFMRequested typeResult
.NET (Core)any of Mini, Heap, Full, Triage, NoneHonored unchanged
.NET FrameworkMini / Heap / Full / NoneHonored unchanged
.NET FrameworkTriageMapped to Mini (info message), as Mini is the closest equivalent

Mutually exclusive with --hangdump-type.

Implementation notes

The lifetime handler's IsEnabledAsync returns true for the no-op case (so it can emit the info message), but the env-var provider's IsEnabledAsync and the lifecycle methods are gated on IsCrashReportEffective / IsHangDumpTypeSupportedOnCurrentRuntime to avoid:

  • Hard-erroring on .NET Framework via ValidateTestHostEnvironmentVariablesAsync.
  • Setting DbgEnableMiniDump=1 on Windows when the mechanism is known to be ignored.
  • Tripping ApplicationStateGuard.Ensure checks on a dump file name pattern that was never set up.

Tests

  • Unit tests for IsCrashReportEffective and MapToSupportedDumpType (added to CrashDumpTests / HangDumpTests).
  • Validation tests: mutual-exclusion error, accepted alongside --crashdump, never rejected on any platform, satisfies the -main-option-missing rule, both variants registered as arity-0.
  • Updated HelpInfoAllExtensionsTests expectations for both human-readable and structured --info output.

Local validation: 85/89 tests pass on net8.0 (4 Windows-skipped pre-existing CrashReport tests), 84/88 on net472 (same 4 skipped). Production projects (Microsoft.Testing.Extensions.CrashDump, Microsoft.Testing.Extensions.HangDump) and the unit-test project all build clean (0 warnings, 0 errors).

Acceptance tests for end-to-end behaviour aren't included here yet; happy to follow up if reviewers want them.

Why not an environment variable?

@bart-vmware also suggested keeping the hard error but letting users opt into a "downgrade to info" via an environment variable. We discarded that route in favour of an explicit CLI option for the following reasons:

  • Discoverability. A new CLI option shows up in --help / --info and is grep-able in CI scripts. An environment variable only surfaces when the user already hit the error and read the message, which is exactly the friction we are trying to remove.
  • Self-documenting CI scripts.--crash-report-if-supported clearly conveys the user's intent ("I want a crash report when I can get one"). A script that sets MTP_ALLOW_UNSUPPORTED_CRASH_REPORT=1 (or similar) and then calls --crash-report hides that intent in the environment.
  • Scope. An env-var-suppression mechanism would need to be replicated per option family (--crash-report, --hangdump-type Triage, plus every future option in the same situation), inflating the env-var surface. The -if-supported suffix is a uniform naming convention we can reuse going forward.
  • Local debugging. When investigating a build leg, an explicit CLI flag is much easier to reason about than "is there an environment variable set somewhere up the call stack?". Env vars also leak between commands in a CI step.
  • Composability. Users who genuinely want to fail fast on unsupported runtimes can keep using the strict --crash-report / --hangdump-type — the two variants coexist, are mutually exclusive at validation time, and a single CI matrix can mix the two if it really wants to.

The strict --crash-report / --hangdump-type are unchanged, so callers that prefer the fail-fast contract keep their current behaviour.

Companion options that silently no-op when the underlying mechanism is
unsupported on the current OS/TFM, so a single CLI line works on every
build leg (issue #7126).
- --crash-report-if-supported (arity 0): mirrors --crash-report but is
ignored on Windows (DOTNET_EnableCrashReportOnly is not honored there)
and on .NET Framework (no createdump runtime).
- --hangdump-type-if-supported <Mini|Heap|Full|Triage|None> (arity 1):
mirrors --hangdump-type but maps requested types unsupported on the
current TFM (today: Triage on .NET Framework) to the closest
equivalent (Mini).
Each variant emits a single informational line when it no-ops so users
can see the substitution happened.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings May 28, 2026 16:47

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds “best-effort” companion CLI options in Microsoft.Testing.Platform diagnostics extensions to reduce CI matrix friction by silently no-op’ing (with a single console message) when the underlying crash-report or dump-type mechanism isn’t supported on the current runtime/OS.

Changes:

  • Add --crash-report-if-supported (CrashDump) and --hangdump-type-if-supported (HangDump) options with mutual-exclusion validation against their strict counterparts.
  • Implement runtime/OS gating and fallback behavior (CrashReport ignored on Windows/.NET Framework; HangDump type mapping when requested type isn’t supported).
  • Add/extend unit tests, update help/info acceptance expectations, and update localized resources.
Show a summary per file
FileDescription
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/HangDumpTests.csAdds unit coverage for --hangdump-type-if-supported validation, mutual exclusion, and mapping helpers.
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/CrashDumpTests.csAdds unit coverage for --crash-report-if-supported, mutual exclusion, arity, and “effective” gating helper.
test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoAllExtensionsTests.csUpdates --help / --info expectations to include the new options and their descriptions.
src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpCommandLineProvider.csRegisters --hangdump-type-if-supported, validates values across TFMs, enforces mutual exclusion, and adds mapping helpers.
src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpProcessLifetimeHandler.csApplies best-effort dump-type mapping and emits a single message when a fallback occurs.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/ExtensionResources.resxAdds new HangDump option description + mutual-exclusion/fallback messages.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.cs.xlfLocalization update for new HangDump strings (Czech).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.de.xlfLocalization update for new HangDump strings (German).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.es.xlfLocalization update for new HangDump strings (Spanish).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.fr.xlfLocalization update for new HangDump strings (French).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.it.xlfLocalization update for new HangDump strings (Italian).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ja.xlfLocalization update for new HangDump strings (Japanese).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ko.xlfLocalization update for new HangDump strings (Korean).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.pl.xlfLocalization update for new HangDump strings (Polish).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.pt-BR.xlfLocalization update for new HangDump strings (Portuguese - Brazil).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ru.xlfLocalization update for new HangDump strings (Russian).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.tr.xlfLocalization update for new HangDump strings (Turkish).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.zh-Hans.xlfLocalization update for new HangDump strings (Chinese Simplified).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.zh-Hant.xlfLocalization update for new HangDump strings (Chinese Traditional).
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpCommandLineOptions.csDefines the new crash-report-if-supported option name constant.
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpCommandLineProvider.csRegisters --crash-report-if-supported, enforces mutual exclusion, and treats it as a main option.
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpEnvironmentVariableProvider.csGates env-var application via IsCrashReportEffective so Windows/.NET Framework no-op cases don’t error.
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpProcessLifetimeHandler.csEnables handler for --crash-report-if-supported to emit the informational line and avoids artifact scanning when ineffective.
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/CrashDumpResources.resxAdds CrashDump option description + mutual-exclusion and “ignored” info messages; updates Windows unsupported message.
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.cs.xlfLocalization update for new CrashDump strings (Czech).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.de.xlfLocalization update for new CrashDump strings (German).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.es.xlfLocalization update for new CrashDump strings (Spanish).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.fr.xlfLocalization update for new CrashDump strings (French).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.it.xlfLocalization update for new CrashDump strings (Italian).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.ja.xlfLocalization update for new CrashDump strings (Japanese).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.ko.xlfLocalization update for new CrashDump strings (Korean).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.pl.xlfLocalization update for new CrashDump strings (Polish).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.pt-BR.xlfLocalization update for new CrashDump strings (Portuguese - Brazil).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.ru.xlfLocalization update for new CrashDump strings (Russian).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.tr.xlfLocalization update for new CrashDump strings (Turkish).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.zh-Hans.xlfLocalization update for new CrashDump strings (Chinese Simplified).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.zh-Hant.xlfLocalization update for new CrashDump strings (Chinese Traditional).

Copilot's findings

  • Files reviewed: 37/37 changed files
  • Comments generated: 3

Aligns three locations that still described --hangdump-type-if-supported
as falling back to the default 'Full' (the original design) instead of
the actual closest-supported-type mapping (Triage -> Mini on netfx):
- HangDumpCommandLineProvider.cs: AllHangDumpTypeOptions comment.
- HelpInfoAllExtensionsTests.cs: --help and --info expectations.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Review of PR #8666--crash-report-if-supported / --hangdump-type-if-supported

Summary

The overall design is sound and well-structured: the new -if-supported companions are wired in at every layer (CLI validation, env-var provider, lifecycle callbacks), the mutual-exclusion checks are correct, the IsCrashReportEffective predicate cleanly avoids double-activation, and the MapToSupportedDumpType / IsHangDumpTypeSupportedOnCurrentRuntime pair is a solid runtime-dispatch pattern.

21-dimension verdict

#DimensionVerdictNotes
1Algorithmic CorrectnessIsCrashReportEffective, MapToSupportedDumpType, and the IsCrashHandlingEffective guard all trace correctly for every branch (netfx/net·win/net·unix). ApplicationStateGuard.Ensure guards are preserved.
2Threading & Concurrency⚠️_ifSupportedIgnoredMessageEmitted is a non-volatilebool read/written across potential thread switches; see inline comment.
3SecurityNo new file operations or untrusted input.
4Public API / Binary CompatAll new constants and helpers are internal. No PublicAPI.Unshipped.txt changes needed.
5PerformanceCold path only; no hot-path impact.
6Cross-TFM Compatibility#if !NETCOREAPP / #if NET guards are correct and consistent.
7Resource / IDisposableNo new disposables.
8Defensive CodingExisting ApplicationStateGuard.Ensure guards preserved; new guards added only for the effective paths.
9LocalizationAll strings in .resx. XLF files carry target state="new" markers (build-generated, not hand-edited).
10Test IsolationNo shared static mutable state added.
11Assertion QualityUnit tests use MSTest assertions as required for MTP test projects.
12FlakinessNo time-dependent assertions.
13CLI / Option Consistency⚠️--hangdump-type-if-supported is classified as a "sub-option" (requires --hangdump), consistent with --hangdump-type — but the option name implies it could stand alone. The PR description says this is intentional; worth a note in the --help description or error message so users aren't confused.
14Output / UX⚠️WarningMessageOutputDeviceData (yellow) used for graceful no-op paths. When the user chose -if-supportedbecause they expect the platform not to support it, a yellow warning is noise. See inline comments on CrashDumpProcessLifetimeHandler.cs:102 and HangDumpProcessLifetimeHandler.cs:121.
15Test CoverageUnit tests cover IsCrashReportEffective, MapToSupportedDumpType, mutual exclusion, and argument validation.
16Naming & ConventionsNaming is clear and consistent with the existing --crashdump / --hangdump family.
17Comment QualityInline comments are detailed and reference the upstream runtime issue (dotnet/runtime#80191).
18Error MessagesMutual-exclusion messages guide the user toward the correct option.
19Scope DisciplinePR is tightly focused on the two new companion options.
20Help/Info Test UpdatesHelpInfoAllExtensionsTests expectations updated.
21XLF / Localization PipelineXLF files correctly updated with target state="new" by the build tool.

Actionable items

  1. _ifSupportedIgnoredMessageEmitted — add volatile (CrashDumpProcessLifetimeHandler.cs:44): the "emit once" guard can be bypassed under concurrent test-host restarts without a memory barrier.
  2. WarningMessageOutputDeviceData → informational format (CrashDumpProcessLifetimeHandler.cs:102/110, HangDumpProcessLifetimeHandler.cs:121): the -if-supported variants are explicitly opt-in best-effort; a yellow warning contradicts the intent and adds noise to CI logs.

Generated by Expert Code Review (on open) for issue #8666 · sonnet46 3.6M

- Use FormattedTextOutputDeviceData instead of WarningMessageOutputDeviceData
for the '-if-supported' no-op / fallback messages. These are expected,
graceful paths; rendering them as yellow warnings would mislead CI users.
(CrashDumpProcessLifetimeHandler.cs x2, HangDumpProcessLifetimeHandler.cs x1)
- Replace the plain bool one-shot guard in CrashDumpProcessLifetimeHandler
with Interlocked.Exchange on an int field, so that concurrent invocations
(e.g. test-host controller retries) cannot race past the guard. Also
restructure to early-return when the option will not emit anything on the
current runtime/OS, so the guard is only claimed when we actually emit.
- Collapse the nested 'if' in HangDumpCommandLineProvider.ValidateOptionArgumentsAsync
for --hangdump-type-if-supported into a single conditional return (also
satisfies IDE0046).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings May 28, 2026 17:12

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

Comments suppressed due to low confidence (1)

test/UnitTests/Microsoft.Testing.Extensions.UnitTests/CrashDumpTests.cs:359

  • The placeholder-to-regex conversion test no longer covers several common createdump placeholders/pattern shapes (e.g. %e, %h, %t, literal-only patterns). Those DataRow cases previously validated that placeholders are expanded to wildcards across multiple tokens and adjacent placeholders; dropping them reduces coverage for BuildDumpFileNameRegexPattern and makes regressions easier to miss.
  • Files reviewed: 37/37 changed files
  • Comments generated: 1

…ents
The earlier comment in CrashDumpEnvironmentVariableProvider above the
'crashReportEnabled' assignment said 'IsEnabledAsync gates this method,
so at least one of --crashdump / --crash-report / --crash-report-if-supported
is set here.' That wording suggested '--crash-report-if-supported' alone
is sufficient to reach UpdateAsync / ValidateTestHostEnvironmentVariablesAsync
even on Windows / .NET Framework, where the option is intentionally a
no-op (IsCrashReportEffective returns false and IsEnabledAsync is false
unless '--crashdump' is also set).
Reword both occurrences to refer to an *effective* crash-report request
so future readers do not misinterpret the precondition.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings May 29, 2026 16:45

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 37/37 changed files
  • Comments generated: 0 new

@Evangelink
Amaury Levé (Evangelink) merged commit 35f4f1e into mainMay 31, 2026
25 of 26 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/crash-report-if-supported branch May 31, 2026 06:41
Amaury Levé (Evangelink) added a commit that referenced this pull request May 31, 2026
…om PR #8666 (#8716)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for freeto 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.

Add option to collect gcdump (MTPv2)

2 participants

@Evangelink
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Add --crash-report-if-supported and --hangdump-type-if-supported options - #8666

Merged
Amaury Levé (Evangelink) merged 5 commits into
mainfrom
dev/amauryleve/crash-report-if-supported
May 31, 2026
Merged

Add --crash-report-if-supported and --hangdump-type-if-supported options#8666
Amaury Levé (Evangelink) merged 5 commits into
mainfrom
dev/amauryleve/crash-report-if-supported

Conversation

@Evangelink

@EvangelinkAmaury Levé (Evangelink) commented May 28, 2026

Copy link
Copy Markdown
Member

Closes#7126 (companion options for --crash-report and --hangdump-type).

Problem

@bart-vmware pointed out that --crash-report errors out on Windows because the .NET runtime ignores DOTNET_EnableCrashReportOnly there. The same kind of friction exists for --hangdump-type Triage on .NET Framework (Triage is a netcoreapp-only dump type). The current behaviour forces consumers to maintain different CLI commands per OS / TFM in their CI scripts.

Solution

Introduce two new -if-supported companion options that behave identically to the strict variants when the underlying mechanism is supported, and silently no-op (with a single info line on the console) when it is not.

StrictNew companion
--crash-report (errors on Windows)--crash-report-if-supported (no-op on Windows / .NET Framework)
--hangdump-type <Mini|Heap|Full|Triage|None> (Triage rejected on netfx)--hangdump-type-if-supported <…> (Triage on netfx maps to Mini)

This lets users keep a single CI invocation across all build legs.

Naming rationale

We considered short forms (--crash-report?, --crash-report-best-effort, etc.) and decided on the explicit long -if-supported suffix:

  • The semantics are obvious from the name.
  • A short form would still need aliasing in the parser; the saving is small.
  • Future -if-supported variants can follow the same pattern.

Behaviour matrix

--crash-report-if-supported

RuntimeOSBehaviour
.NET FrameworkWindows / Linux / macOSNo-op (info message)
.NET (Core)WindowsNo-op (info message)
.NET (Core)Linux / macOSSame as --crash-report

Mutually exclusive with --crash-report.

--hangdump-type-if-supported <type>

TFMRequested typeResult
.NET (Core)any of Mini, Heap, Full, Triage, NoneHonored unchanged
.NET FrameworkMini / Heap / Full / NoneHonored unchanged
.NET FrameworkTriageMapped to Mini (info message), as Mini is the closest equivalent

Mutually exclusive with --hangdump-type.

Implementation notes

The lifetime handler's IsEnabledAsync returns true for the no-op case (so it can emit the info message), but the env-var provider's IsEnabledAsync and the lifecycle methods are gated on IsCrashReportEffective / IsHangDumpTypeSupportedOnCurrentRuntime to avoid:

  • Hard-erroring on .NET Framework via ValidateTestHostEnvironmentVariablesAsync.
  • Setting DbgEnableMiniDump=1 on Windows when the mechanism is known to be ignored.
  • Tripping ApplicationStateGuard.Ensure checks on a dump file name pattern that was never set up.

Tests

  • Unit tests for IsCrashReportEffective and MapToSupportedDumpType (added to CrashDumpTests / HangDumpTests).
  • Validation tests: mutual-exclusion error, accepted alongside --crashdump, never rejected on any platform, satisfies the -main-option-missing rule, both variants registered as arity-0.
  • Updated HelpInfoAllExtensionsTests expectations for both human-readable and structured --info output.

Local validation: 85/89 tests pass on net8.0 (4 Windows-skipped pre-existing CrashReport tests), 84/88 on net472 (same 4 skipped). Production projects (Microsoft.Testing.Extensions.CrashDump, Microsoft.Testing.Extensions.HangDump) and the unit-test project all build clean (0 warnings, 0 errors).

Acceptance tests for end-to-end behaviour aren't included here yet; happy to follow up if reviewers want them.

Why not an environment variable?

@bart-vmware also suggested keeping the hard error but letting users opt into a "downgrade to info" via an environment variable. We discarded that route in favour of an explicit CLI option for the following reasons:

  • Discoverability. A new CLI option shows up in --help / --info and is grep-able in CI scripts. An environment variable only surfaces when the user already hit the error and read the message, which is exactly the friction we are trying to remove.
  • Self-documenting CI scripts.--crash-report-if-supported clearly conveys the user's intent ("I want a crash report when I can get one"). A script that sets MTP_ALLOW_UNSUPPORTED_CRASH_REPORT=1 (or similar) and then calls --crash-report hides that intent in the environment.
  • Scope. An env-var-suppression mechanism would need to be replicated per option family (--crash-report, --hangdump-type Triage, plus every future option in the same situation), inflating the env-var surface. The -if-supported suffix is a uniform naming convention we can reuse going forward.
  • Local debugging. When investigating a build leg, an explicit CLI flag is much easier to reason about than "is there an environment variable set somewhere up the call stack?". Env vars also leak between commands in a CI step.
  • Composability. Users who genuinely want to fail fast on unsupported runtimes can keep using the strict --crash-report / --hangdump-type — the two variants coexist, are mutually exclusive at validation time, and a single CI matrix can mix the two if it really wants to.

The strict --crash-report / --hangdump-type are unchanged, so callers that prefer the fail-fast contract keep their current behaviour.

Companion options that silently no-op when the underlying mechanism is
unsupported on the current OS/TFM, so a single CLI line works on every
build leg (issue #7126).
- --crash-report-if-supported (arity 0): mirrors --crash-report but is
ignored on Windows (DOTNET_EnableCrashReportOnly is not honored there)
and on .NET Framework (no createdump runtime).
- --hangdump-type-if-supported <Mini|Heap|Full|Triage|None> (arity 1):
mirrors --hangdump-type but maps requested types unsupported on the
current TFM (today: Triage on .NET Framework) to the closest
equivalent (Mini).
Each variant emits a single informational line when it no-ops so users
can see the substitution happened.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings May 28, 2026 16:47

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds “best-effort” companion CLI options in Microsoft.Testing.Platform diagnostics extensions to reduce CI matrix friction by silently no-op’ing (with a single console message) when the underlying crash-report or dump-type mechanism isn’t supported on the current runtime/OS.

Changes:

  • Add --crash-report-if-supported (CrashDump) and --hangdump-type-if-supported (HangDump) options with mutual-exclusion validation against their strict counterparts.
  • Implement runtime/OS gating and fallback behavior (CrashReport ignored on Windows/.NET Framework; HangDump type mapping when requested type isn’t supported).
  • Add/extend unit tests, update help/info acceptance expectations, and update localized resources.
Show a summary per file
FileDescription
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/HangDumpTests.csAdds unit coverage for --hangdump-type-if-supported validation, mutual exclusion, and mapping helpers.
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/CrashDumpTests.csAdds unit coverage for --crash-report-if-supported, mutual exclusion, arity, and “effective” gating helper.
test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoAllExtensionsTests.csUpdates --help / --info expectations to include the new options and their descriptions.
src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpCommandLineProvider.csRegisters --hangdump-type-if-supported, validates values across TFMs, enforces mutual exclusion, and adds mapping helpers.
src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpProcessLifetimeHandler.csApplies best-effort dump-type mapping and emits a single message when a fallback occurs.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/ExtensionResources.resxAdds new HangDump option description + mutual-exclusion/fallback messages.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.cs.xlfLocalization update for new HangDump strings (Czech).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.de.xlfLocalization update for new HangDump strings (German).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.es.xlfLocalization update for new HangDump strings (Spanish).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.fr.xlfLocalization update for new HangDump strings (French).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.it.xlfLocalization update for new HangDump strings (Italian).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ja.xlfLocalization update for new HangDump strings (Japanese).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ko.xlfLocalization update for new HangDump strings (Korean).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.pl.xlfLocalization update for new HangDump strings (Polish).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.pt-BR.xlfLocalization update for new HangDump strings (Portuguese - Brazil).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ru.xlfLocalization update for new HangDump strings (Russian).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.tr.xlfLocalization update for new HangDump strings (Turkish).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.zh-Hans.xlfLocalization update for new HangDump strings (Chinese Simplified).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.zh-Hant.xlfLocalization update for new HangDump strings (Chinese Traditional).
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpCommandLineOptions.csDefines the new crash-report-if-supported option name constant.
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpCommandLineProvider.csRegisters --crash-report-if-supported, enforces mutual exclusion, and treats it as a main option.
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpEnvironmentVariableProvider.csGates env-var application via IsCrashReportEffective so Windows/.NET Framework no-op cases don’t error.
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpProcessLifetimeHandler.csEnables handler for --crash-report-if-supported to emit the informational line and avoids artifact scanning when ineffective.
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/CrashDumpResources.resxAdds CrashDump option description + mutual-exclusion and “ignored” info messages; updates Windows unsupported message.
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.cs.xlfLocalization update for new CrashDump strings (Czech).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.de.xlfLocalization update for new CrashDump strings (German).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.es.xlfLocalization update for new CrashDump strings (Spanish).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.fr.xlfLocalization update for new CrashDump strings (French).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.it.xlfLocalization update for new CrashDump strings (Italian).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.ja.xlfLocalization update for new CrashDump strings (Japanese).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.ko.xlfLocalization update for new CrashDump strings (Korean).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.pl.xlfLocalization update for new CrashDump strings (Polish).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.pt-BR.xlfLocalization update for new CrashDump strings (Portuguese - Brazil).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.ru.xlfLocalization update for new CrashDump strings (Russian).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.tr.xlfLocalization update for new CrashDump strings (Turkish).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.zh-Hans.xlfLocalization update for new CrashDump strings (Chinese Simplified).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.zh-Hant.xlfLocalization update for new CrashDump strings (Chinese Traditional).

Copilot's findings

  • Files reviewed: 37/37 changed files
  • Comments generated: 3

Aligns three locations that still described --hangdump-type-if-supported
as falling back to the default 'Full' (the original design) instead of
the actual closest-supported-type mapping (Triage -> Mini on netfx):
- HangDumpCommandLineProvider.cs: AllHangDumpTypeOptions comment.
- HelpInfoAllExtensionsTests.cs: --help and --info expectations.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Review of PR #8666--crash-report-if-supported / --hangdump-type-if-supported

Summary

The overall design is sound and well-structured: the new -if-supported companions are wired in at every layer (CLI validation, env-var provider, lifecycle callbacks), the mutual-exclusion checks are correct, the IsCrashReportEffective predicate cleanly avoids double-activation, and the MapToSupportedDumpType / IsHangDumpTypeSupportedOnCurrentRuntime pair is a solid runtime-dispatch pattern.

21-dimension verdict

#DimensionVerdictNotes
1Algorithmic CorrectnessIsCrashReportEffective, MapToSupportedDumpType, and the IsCrashHandlingEffective guard all trace correctly for every branch (netfx/net·win/net·unix). ApplicationStateGuard.Ensure guards are preserved.
2Threading & Concurrency⚠️_ifSupportedIgnoredMessageEmitted is a non-volatilebool read/written across potential thread switches; see inline comment.
3SecurityNo new file operations or untrusted input.
4Public API / Binary CompatAll new constants and helpers are internal. No PublicAPI.Unshipped.txt changes needed.
5PerformanceCold path only; no hot-path impact.
6Cross-TFM Compatibility#if !NETCOREAPP / #if NET guards are correct and consistent.
7Resource / IDisposableNo new disposables.
8Defensive CodingExisting ApplicationStateGuard.Ensure guards preserved; new guards added only for the effective paths.
9LocalizationAll strings in .resx. XLF files carry target state="new" markers (build-generated, not hand-edited).
10Test IsolationNo shared static mutable state added.
11Assertion QualityUnit tests use MSTest assertions as required for MTP test projects.
12FlakinessNo time-dependent assertions.
13CLI / Option Consistency⚠️--hangdump-type-if-supported is classified as a "sub-option" (requires --hangdump), consistent with --hangdump-type — but the option name implies it could stand alone. The PR description says this is intentional; worth a note in the --help description or error message so users aren't confused.
14Output / UX⚠️WarningMessageOutputDeviceData (yellow) used for graceful no-op paths. When the user chose -if-supportedbecause they expect the platform not to support it, a yellow warning is noise. See inline comments on CrashDumpProcessLifetimeHandler.cs:102 and HangDumpProcessLifetimeHandler.cs:121.
15Test CoverageUnit tests cover IsCrashReportEffective, MapToSupportedDumpType, mutual exclusion, and argument validation.
16Naming & ConventionsNaming is clear and consistent with the existing --crashdump / --hangdump family.
17Comment QualityInline comments are detailed and reference the upstream runtime issue (dotnet/runtime#80191).
18Error MessagesMutual-exclusion messages guide the user toward the correct option.
19Scope DisciplinePR is tightly focused on the two new companion options.
20Help/Info Test UpdatesHelpInfoAllExtensionsTests expectations updated.
21XLF / Localization PipelineXLF files correctly updated with target state="new" by the build tool.

Actionable items

  1. _ifSupportedIgnoredMessageEmitted — add volatile (CrashDumpProcessLifetimeHandler.cs:44): the "emit once" guard can be bypassed under concurrent test-host restarts without a memory barrier.
  2. WarningMessageOutputDeviceData → informational format (CrashDumpProcessLifetimeHandler.cs:102/110, HangDumpProcessLifetimeHandler.cs:121): the -if-supported variants are explicitly opt-in best-effort; a yellow warning contradicts the intent and adds noise to CI logs.

Generated by Expert Code Review (on open) for issue #8666 · sonnet46 3.6M

- Use FormattedTextOutputDeviceData instead of WarningMessageOutputDeviceData
for the '-if-supported' no-op / fallback messages. These are expected,
graceful paths; rendering them as yellow warnings would mislead CI users.
(CrashDumpProcessLifetimeHandler.cs x2, HangDumpProcessLifetimeHandler.cs x1)
- Replace the plain bool one-shot guard in CrashDumpProcessLifetimeHandler
with Interlocked.Exchange on an int field, so that concurrent invocations
(e.g. test-host controller retries) cannot race past the guard. Also
restructure to early-return when the option will not emit anything on the
current runtime/OS, so the guard is only claimed when we actually emit.
- Collapse the nested 'if' in HangDumpCommandLineProvider.ValidateOptionArgumentsAsync
for --hangdump-type-if-supported into a single conditional return (also
satisfies IDE0046).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings May 28, 2026 17:12

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

Comments suppressed due to low confidence (1)

test/UnitTests/Microsoft.Testing.Extensions.UnitTests/CrashDumpTests.cs:359

  • The placeholder-to-regex conversion test no longer covers several common createdump placeholders/pattern shapes (e.g. %e, %h, %t, literal-only patterns). Those DataRow cases previously validated that placeholders are expanded to wildcards across multiple tokens and adjacent placeholders; dropping them reduces coverage for BuildDumpFileNameRegexPattern and makes regressions easier to miss.
  • Files reviewed: 37/37 changed files
  • Comments generated: 1

…ents
The earlier comment in CrashDumpEnvironmentVariableProvider above the
'crashReportEnabled' assignment said 'IsEnabledAsync gates this method,
so at least one of --crashdump / --crash-report / --crash-report-if-supported
is set here.' That wording suggested '--crash-report-if-supported' alone
is sufficient to reach UpdateAsync / ValidateTestHostEnvironmentVariablesAsync
even on Windows / .NET Framework, where the option is intentionally a
no-op (IsCrashReportEffective returns false and IsEnabledAsync is false
unless '--crashdump' is also set).
Reword both occurrences to refer to an *effective* crash-report request
so future readers do not misinterpret the precondition.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings May 29, 2026 16:45

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 37/37 changed files
  • Comments generated: 0 new

@Evangelink
Amaury Levé (Evangelink) merged commit 35f4f1e into mainMay 31, 2026
25 of 26 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/crash-report-if-supported branch May 31, 2026 06:41
Amaury Levé (Evangelink) added a commit that referenced this pull request May 31, 2026
…om PR #8666 (#8716)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for freeto 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.

Add option to collect gcdump (MTPv2)

2 participants

@Evangelink
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Add --crash-report-if-supported and --hangdump-type-if-supported options - #8666

Merged
Amaury Levé (Evangelink) merged 5 commits into
mainfrom
dev/amauryleve/crash-report-if-supported
May 31, 2026
Merged

Add --crash-report-if-supported and --hangdump-type-if-supported options#8666
Amaury Levé (Evangelink) merged 5 commits into
mainfrom
dev/amauryleve/crash-report-if-supported

Conversation

@Evangelink

@EvangelinkAmaury Levé (Evangelink) commented May 28, 2026

Copy link
Copy Markdown
Member

Closes#7126 (companion options for --crash-report and --hangdump-type).

Problem

@bart-vmware pointed out that --crash-report errors out on Windows because the .NET runtime ignores DOTNET_EnableCrashReportOnly there. The same kind of friction exists for --hangdump-type Triage on .NET Framework (Triage is a netcoreapp-only dump type). The current behaviour forces consumers to maintain different CLI commands per OS / TFM in their CI scripts.

Solution

Introduce two new -if-supported companion options that behave identically to the strict variants when the underlying mechanism is supported, and silently no-op (with a single info line on the console) when it is not.

StrictNew companion
--crash-report (errors on Windows)--crash-report-if-supported (no-op on Windows / .NET Framework)
--hangdump-type <Mini|Heap|Full|Triage|None> (Triage rejected on netfx)--hangdump-type-if-supported <…> (Triage on netfx maps to Mini)

This lets users keep a single CI invocation across all build legs.

Naming rationale

We considered short forms (--crash-report?, --crash-report-best-effort, etc.) and decided on the explicit long -if-supported suffix:

  • The semantics are obvious from the name.
  • A short form would still need aliasing in the parser; the saving is small.
  • Future -if-supported variants can follow the same pattern.

Behaviour matrix

--crash-report-if-supported

RuntimeOSBehaviour
.NET FrameworkWindows / Linux / macOSNo-op (info message)
.NET (Core)WindowsNo-op (info message)
.NET (Core)Linux / macOSSame as --crash-report

Mutually exclusive with --crash-report.

--hangdump-type-if-supported <type>

TFMRequested typeResult
.NET (Core)any of Mini, Heap, Full, Triage, NoneHonored unchanged
.NET FrameworkMini / Heap / Full / NoneHonored unchanged
.NET FrameworkTriageMapped to Mini (info message), as Mini is the closest equivalent

Mutually exclusive with --hangdump-type.

Implementation notes

The lifetime handler's IsEnabledAsync returns true for the no-op case (so it can emit the info message), but the env-var provider's IsEnabledAsync and the lifecycle methods are gated on IsCrashReportEffective / IsHangDumpTypeSupportedOnCurrentRuntime to avoid:

  • Hard-erroring on .NET Framework via ValidateTestHostEnvironmentVariablesAsync.
  • Setting DbgEnableMiniDump=1 on Windows when the mechanism is known to be ignored.
  • Tripping ApplicationStateGuard.Ensure checks on a dump file name pattern that was never set up.

Tests

  • Unit tests for IsCrashReportEffective and MapToSupportedDumpType (added to CrashDumpTests / HangDumpTests).
  • Validation tests: mutual-exclusion error, accepted alongside --crashdump, never rejected on any platform, satisfies the -main-option-missing rule, both variants registered as arity-0.
  • Updated HelpInfoAllExtensionsTests expectations for both human-readable and structured --info output.

Local validation: 85/89 tests pass on net8.0 (4 Windows-skipped pre-existing CrashReport tests), 84/88 on net472 (same 4 skipped). Production projects (Microsoft.Testing.Extensions.CrashDump, Microsoft.Testing.Extensions.HangDump) and the unit-test project all build clean (0 warnings, 0 errors).

Acceptance tests for end-to-end behaviour aren't included here yet; happy to follow up if reviewers want them.

Why not an environment variable?

@bart-vmware also suggested keeping the hard error but letting users opt into a "downgrade to info" via an environment variable. We discarded that route in favour of an explicit CLI option for the following reasons:

  • Discoverability. A new CLI option shows up in --help / --info and is grep-able in CI scripts. An environment variable only surfaces when the user already hit the error and read the message, which is exactly the friction we are trying to remove.
  • Self-documenting CI scripts.--crash-report-if-supported clearly conveys the user's intent ("I want a crash report when I can get one"). A script that sets MTP_ALLOW_UNSUPPORTED_CRASH_REPORT=1 (or similar) and then calls --crash-report hides that intent in the environment.
  • Scope. An env-var-suppression mechanism would need to be replicated per option family (--crash-report, --hangdump-type Triage, plus every future option in the same situation), inflating the env-var surface. The -if-supported suffix is a uniform naming convention we can reuse going forward.
  • Local debugging. When investigating a build leg, an explicit CLI flag is much easier to reason about than "is there an environment variable set somewhere up the call stack?". Env vars also leak between commands in a CI step.
  • Composability. Users who genuinely want to fail fast on unsupported runtimes can keep using the strict --crash-report / --hangdump-type — the two variants coexist, are mutually exclusive at validation time, and a single CI matrix can mix the two if it really wants to.

The strict --crash-report / --hangdump-type are unchanged, so callers that prefer the fail-fast contract keep their current behaviour.

Companion options that silently no-op when the underlying mechanism is
unsupported on the current OS/TFM, so a single CLI line works on every
build leg (issue #7126).
- --crash-report-if-supported (arity 0): mirrors --crash-report but is
ignored on Windows (DOTNET_EnableCrashReportOnly is not honored there)
and on .NET Framework (no createdump runtime).
- --hangdump-type-if-supported <Mini|Heap|Full|Triage|None> (arity 1):
mirrors --hangdump-type but maps requested types unsupported on the
current TFM (today: Triage on .NET Framework) to the closest
equivalent (Mini).
Each variant emits a single informational line when it no-ops so users
can see the substitution happened.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings May 28, 2026 16:47

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds “best-effort” companion CLI options in Microsoft.Testing.Platform diagnostics extensions to reduce CI matrix friction by silently no-op’ing (with a single console message) when the underlying crash-report or dump-type mechanism isn’t supported on the current runtime/OS.

Changes:

  • Add --crash-report-if-supported (CrashDump) and --hangdump-type-if-supported (HangDump) options with mutual-exclusion validation against their strict counterparts.
  • Implement runtime/OS gating and fallback behavior (CrashReport ignored on Windows/.NET Framework; HangDump type mapping when requested type isn’t supported).
  • Add/extend unit tests, update help/info acceptance expectations, and update localized resources.
Show a summary per file
FileDescription
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/HangDumpTests.csAdds unit coverage for --hangdump-type-if-supported validation, mutual exclusion, and mapping helpers.
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/CrashDumpTests.csAdds unit coverage for --crash-report-if-supported, mutual exclusion, arity, and “effective” gating helper.
test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoAllExtensionsTests.csUpdates --help / --info expectations to include the new options and their descriptions.
src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpCommandLineProvider.csRegisters --hangdump-type-if-supported, validates values across TFMs, enforces mutual exclusion, and adds mapping helpers.
src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpProcessLifetimeHandler.csApplies best-effort dump-type mapping and emits a single message when a fallback occurs.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/ExtensionResources.resxAdds new HangDump option description + mutual-exclusion/fallback messages.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.cs.xlfLocalization update for new HangDump strings (Czech).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.de.xlfLocalization update for new HangDump strings (German).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.es.xlfLocalization update for new HangDump strings (Spanish).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.fr.xlfLocalization update for new HangDump strings (French).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.it.xlfLocalization update for new HangDump strings (Italian).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ja.xlfLocalization update for new HangDump strings (Japanese).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ko.xlfLocalization update for new HangDump strings (Korean).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.pl.xlfLocalization update for new HangDump strings (Polish).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.pt-BR.xlfLocalization update for new HangDump strings (Portuguese - Brazil).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ru.xlfLocalization update for new HangDump strings (Russian).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.tr.xlfLocalization update for new HangDump strings (Turkish).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.zh-Hans.xlfLocalization update for new HangDump strings (Chinese Simplified).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.zh-Hant.xlfLocalization update for new HangDump strings (Chinese Traditional).
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpCommandLineOptions.csDefines the new crash-report-if-supported option name constant.
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpCommandLineProvider.csRegisters --crash-report-if-supported, enforces mutual exclusion, and treats it as a main option.
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpEnvironmentVariableProvider.csGates env-var application via IsCrashReportEffective so Windows/.NET Framework no-op cases don’t error.
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpProcessLifetimeHandler.csEnables handler for --crash-report-if-supported to emit the informational line and avoids artifact scanning when ineffective.
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/CrashDumpResources.resxAdds CrashDump option description + mutual-exclusion and “ignored” info messages; updates Windows unsupported message.
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.cs.xlfLocalization update for new CrashDump strings (Czech).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.de.xlfLocalization update for new CrashDump strings (German).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.es.xlfLocalization update for new CrashDump strings (Spanish).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.fr.xlfLocalization update for new CrashDump strings (French).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.it.xlfLocalization update for new CrashDump strings (Italian).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.ja.xlfLocalization update for new CrashDump strings (Japanese).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.ko.xlfLocalization update for new CrashDump strings (Korean).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.pl.xlfLocalization update for new CrashDump strings (Polish).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.pt-BR.xlfLocalization update for new CrashDump strings (Portuguese - Brazil).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.ru.xlfLocalization update for new CrashDump strings (Russian).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.tr.xlfLocalization update for new CrashDump strings (Turkish).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.zh-Hans.xlfLocalization update for new CrashDump strings (Chinese Simplified).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.zh-Hant.xlfLocalization update for new CrashDump strings (Chinese Traditional).

Copilot's findings

  • Files reviewed: 37/37 changed files
  • Comments generated: 3

Aligns three locations that still described --hangdump-type-if-supported
as falling back to the default 'Full' (the original design) instead of
the actual closest-supported-type mapping (Triage -> Mini on netfx):
- HangDumpCommandLineProvider.cs: AllHangDumpTypeOptions comment.
- HelpInfoAllExtensionsTests.cs: --help and --info expectations.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Review of PR #8666--crash-report-if-supported / --hangdump-type-if-supported

Summary

The overall design is sound and well-structured: the new -if-supported companions are wired in at every layer (CLI validation, env-var provider, lifecycle callbacks), the mutual-exclusion checks are correct, the IsCrashReportEffective predicate cleanly avoids double-activation, and the MapToSupportedDumpType / IsHangDumpTypeSupportedOnCurrentRuntime pair is a solid runtime-dispatch pattern.

21-dimension verdict

#DimensionVerdictNotes
1Algorithmic CorrectnessIsCrashReportEffective, MapToSupportedDumpType, and the IsCrashHandlingEffective guard all trace correctly for every branch (netfx/net·win/net·unix). ApplicationStateGuard.Ensure guards are preserved.
2Threading & Concurrency⚠️_ifSupportedIgnoredMessageEmitted is a non-volatilebool read/written across potential thread switches; see inline comment.
3SecurityNo new file operations or untrusted input.
4Public API / Binary CompatAll new constants and helpers are internal. No PublicAPI.Unshipped.txt changes needed.
5PerformanceCold path only; no hot-path impact.
6Cross-TFM Compatibility#if !NETCOREAPP / #if NET guards are correct and consistent.
7Resource / IDisposableNo new disposables.
8Defensive CodingExisting ApplicationStateGuard.Ensure guards preserved; new guards added only for the effective paths.
9LocalizationAll strings in .resx. XLF files carry target state="new" markers (build-generated, not hand-edited).
10Test IsolationNo shared static mutable state added.
11Assertion QualityUnit tests use MSTest assertions as required for MTP test projects.
12FlakinessNo time-dependent assertions.
13CLI / Option Consistency⚠️--hangdump-type-if-supported is classified as a "sub-option" (requires --hangdump), consistent with --hangdump-type — but the option name implies it could stand alone. The PR description says this is intentional; worth a note in the --help description or error message so users aren't confused.
14Output / UX⚠️WarningMessageOutputDeviceData (yellow) used for graceful no-op paths. When the user chose -if-supportedbecause they expect the platform not to support it, a yellow warning is noise. See inline comments on CrashDumpProcessLifetimeHandler.cs:102 and HangDumpProcessLifetimeHandler.cs:121.
15Test CoverageUnit tests cover IsCrashReportEffective, MapToSupportedDumpType, mutual exclusion, and argument validation.
16Naming & ConventionsNaming is clear and consistent with the existing --crashdump / --hangdump family.
17Comment QualityInline comments are detailed and reference the upstream runtime issue (dotnet/runtime#80191).
18Error MessagesMutual-exclusion messages guide the user toward the correct option.
19Scope DisciplinePR is tightly focused on the two new companion options.
20Help/Info Test UpdatesHelpInfoAllExtensionsTests expectations updated.
21XLF / Localization PipelineXLF files correctly updated with target state="new" by the build tool.

Actionable items

  1. _ifSupportedIgnoredMessageEmitted — add volatile (CrashDumpProcessLifetimeHandler.cs:44): the "emit once" guard can be bypassed under concurrent test-host restarts without a memory barrier.
  2. WarningMessageOutputDeviceData → informational format (CrashDumpProcessLifetimeHandler.cs:102/110, HangDumpProcessLifetimeHandler.cs:121): the -if-supported variants are explicitly opt-in best-effort; a yellow warning contradicts the intent and adds noise to CI logs.

Generated by Expert Code Review (on open) for issue #8666 · sonnet46 3.6M

- Use FormattedTextOutputDeviceData instead of WarningMessageOutputDeviceData
for the '-if-supported' no-op / fallback messages. These are expected,
graceful paths; rendering them as yellow warnings would mislead CI users.
(CrashDumpProcessLifetimeHandler.cs x2, HangDumpProcessLifetimeHandler.cs x1)
- Replace the plain bool one-shot guard in CrashDumpProcessLifetimeHandler
with Interlocked.Exchange on an int field, so that concurrent invocations
(e.g. test-host controller retries) cannot race past the guard. Also
restructure to early-return when the option will not emit anything on the
current runtime/OS, so the guard is only claimed when we actually emit.
- Collapse the nested 'if' in HangDumpCommandLineProvider.ValidateOptionArgumentsAsync
for --hangdump-type-if-supported into a single conditional return (also
satisfies IDE0046).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings May 28, 2026 17:12

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

Comments suppressed due to low confidence (1)

test/UnitTests/Microsoft.Testing.Extensions.UnitTests/CrashDumpTests.cs:359

  • The placeholder-to-regex conversion test no longer covers several common createdump placeholders/pattern shapes (e.g. %e, %h, %t, literal-only patterns). Those DataRow cases previously validated that placeholders are expanded to wildcards across multiple tokens and adjacent placeholders; dropping them reduces coverage for BuildDumpFileNameRegexPattern and makes regressions easier to miss.
  • Files reviewed: 37/37 changed files
  • Comments generated: 1

…ents
The earlier comment in CrashDumpEnvironmentVariableProvider above the
'crashReportEnabled' assignment said 'IsEnabledAsync gates this method,
so at least one of --crashdump / --crash-report / --crash-report-if-supported
is set here.' That wording suggested '--crash-report-if-supported' alone
is sufficient to reach UpdateAsync / ValidateTestHostEnvironmentVariablesAsync
even on Windows / .NET Framework, where the option is intentionally a
no-op (IsCrashReportEffective returns false and IsEnabledAsync is false
unless '--crashdump' is also set).
Reword both occurrences to refer to an *effective* crash-report request
so future readers do not misinterpret the precondition.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings May 29, 2026 16:45

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 37/37 changed files
  • Comments generated: 0 new

@Evangelink
Amaury Levé (Evangelink) merged commit 35f4f1e into mainMay 31, 2026
25 of 26 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/crash-report-if-supported branch May 31, 2026 06:41
Amaury Levé (Evangelink) added a commit that referenced this pull request May 31, 2026
…om PR #8666 (#8716)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for freeto 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.

Add option to collect gcdump (MTPv2)

2 participants

@Evangelink
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Add --crash-report-if-supported and --hangdump-type-if-supported options - #8666

Merged
Amaury Levé (Evangelink) merged 5 commits into
mainfrom
dev/amauryleve/crash-report-if-supported
May 31, 2026
Merged

Add --crash-report-if-supported and --hangdump-type-if-supported options#8666
Amaury Levé (Evangelink) merged 5 commits into
mainfrom
dev/amauryleve/crash-report-if-supported

Conversation

@Evangelink

@EvangelinkAmaury Levé (Evangelink) commented May 28, 2026

Copy link
Copy Markdown
Member

Closes#7126 (companion options for --crash-report and --hangdump-type).

Problem

@bart-vmware pointed out that --crash-report errors out on Windows because the .NET runtime ignores DOTNET_EnableCrashReportOnly there. The same kind of friction exists for --hangdump-type Triage on .NET Framework (Triage is a netcoreapp-only dump type). The current behaviour forces consumers to maintain different CLI commands per OS / TFM in their CI scripts.

Solution

Introduce two new -if-supported companion options that behave identically to the strict variants when the underlying mechanism is supported, and silently no-op (with a single info line on the console) when it is not.

StrictNew companion
--crash-report (errors on Windows)--crash-report-if-supported (no-op on Windows / .NET Framework)
--hangdump-type <Mini|Heap|Full|Triage|None> (Triage rejected on netfx)--hangdump-type-if-supported <…> (Triage on netfx maps to Mini)

This lets users keep a single CI invocation across all build legs.

Naming rationale

We considered short forms (--crash-report?, --crash-report-best-effort, etc.) and decided on the explicit long -if-supported suffix:

  • The semantics are obvious from the name.
  • A short form would still need aliasing in the parser; the saving is small.
  • Future -if-supported variants can follow the same pattern.

Behaviour matrix

--crash-report-if-supported

RuntimeOSBehaviour
.NET FrameworkWindows / Linux / macOSNo-op (info message)
.NET (Core)WindowsNo-op (info message)
.NET (Core)Linux / macOSSame as --crash-report

Mutually exclusive with --crash-report.

--hangdump-type-if-supported <type>

TFMRequested typeResult
.NET (Core)any of Mini, Heap, Full, Triage, NoneHonored unchanged
.NET FrameworkMini / Heap / Full / NoneHonored unchanged
.NET FrameworkTriageMapped to Mini (info message), as Mini is the closest equivalent

Mutually exclusive with --hangdump-type.

Implementation notes

The lifetime handler's IsEnabledAsync returns true for the no-op case (so it can emit the info message), but the env-var provider's IsEnabledAsync and the lifecycle methods are gated on IsCrashReportEffective / IsHangDumpTypeSupportedOnCurrentRuntime to avoid:

  • Hard-erroring on .NET Framework via ValidateTestHostEnvironmentVariablesAsync.
  • Setting DbgEnableMiniDump=1 on Windows when the mechanism is known to be ignored.
  • Tripping ApplicationStateGuard.Ensure checks on a dump file name pattern that was never set up.

Tests

  • Unit tests for IsCrashReportEffective and MapToSupportedDumpType (added to CrashDumpTests / HangDumpTests).
  • Validation tests: mutual-exclusion error, accepted alongside --crashdump, never rejected on any platform, satisfies the -main-option-missing rule, both variants registered as arity-0.
  • Updated HelpInfoAllExtensionsTests expectations for both human-readable and structured --info output.

Local validation: 85/89 tests pass on net8.0 (4 Windows-skipped pre-existing CrashReport tests), 84/88 on net472 (same 4 skipped). Production projects (Microsoft.Testing.Extensions.CrashDump, Microsoft.Testing.Extensions.HangDump) and the unit-test project all build clean (0 warnings, 0 errors).

Acceptance tests for end-to-end behaviour aren't included here yet; happy to follow up if reviewers want them.

Why not an environment variable?

@bart-vmware also suggested keeping the hard error but letting users opt into a "downgrade to info" via an environment variable. We discarded that route in favour of an explicit CLI option for the following reasons:

  • Discoverability. A new CLI option shows up in --help / --info and is grep-able in CI scripts. An environment variable only surfaces when the user already hit the error and read the message, which is exactly the friction we are trying to remove.
  • Self-documenting CI scripts.--crash-report-if-supported clearly conveys the user's intent ("I want a crash report when I can get one"). A script that sets MTP_ALLOW_UNSUPPORTED_CRASH_REPORT=1 (or similar) and then calls --crash-report hides that intent in the environment.
  • Scope. An env-var-suppression mechanism would need to be replicated per option family (--crash-report, --hangdump-type Triage, plus every future option in the same situation), inflating the env-var surface. The -if-supported suffix is a uniform naming convention we can reuse going forward.
  • Local debugging. When investigating a build leg, an explicit CLI flag is much easier to reason about than "is there an environment variable set somewhere up the call stack?". Env vars also leak between commands in a CI step.
  • Composability. Users who genuinely want to fail fast on unsupported runtimes can keep using the strict --crash-report / --hangdump-type — the two variants coexist, are mutually exclusive at validation time, and a single CI matrix can mix the two if it really wants to.

The strict --crash-report / --hangdump-type are unchanged, so callers that prefer the fail-fast contract keep their current behaviour.

Companion options that silently no-op when the underlying mechanism is
unsupported on the current OS/TFM, so a single CLI line works on every
build leg (issue #7126).
- --crash-report-if-supported (arity 0): mirrors --crash-report but is
ignored on Windows (DOTNET_EnableCrashReportOnly is not honored there)
and on .NET Framework (no createdump runtime).
- --hangdump-type-if-supported <Mini|Heap|Full|Triage|None> (arity 1):
mirrors --hangdump-type but maps requested types unsupported on the
current TFM (today: Triage on .NET Framework) to the closest
equivalent (Mini).
Each variant emits a single informational line when it no-ops so users
can see the substitution happened.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings May 28, 2026 16:47

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds “best-effort” companion CLI options in Microsoft.Testing.Platform diagnostics extensions to reduce CI matrix friction by silently no-op’ing (with a single console message) when the underlying crash-report or dump-type mechanism isn’t supported on the current runtime/OS.

Changes:

  • Add --crash-report-if-supported (CrashDump) and --hangdump-type-if-supported (HangDump) options with mutual-exclusion validation against their strict counterparts.
  • Implement runtime/OS gating and fallback behavior (CrashReport ignored on Windows/.NET Framework; HangDump type mapping when requested type isn’t supported).
  • Add/extend unit tests, update help/info acceptance expectations, and update localized resources.
Show a summary per file
FileDescription
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/HangDumpTests.csAdds unit coverage for --hangdump-type-if-supported validation, mutual exclusion, and mapping helpers.
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/CrashDumpTests.csAdds unit coverage for --crash-report-if-supported, mutual exclusion, arity, and “effective” gating helper.
test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoAllExtensionsTests.csUpdates --help / --info expectations to include the new options and their descriptions.
src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpCommandLineProvider.csRegisters --hangdump-type-if-supported, validates values across TFMs, enforces mutual exclusion, and adds mapping helpers.
src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpProcessLifetimeHandler.csApplies best-effort dump-type mapping and emits a single message when a fallback occurs.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/ExtensionResources.resxAdds new HangDump option description + mutual-exclusion/fallback messages.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.cs.xlfLocalization update for new HangDump strings (Czech).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.de.xlfLocalization update for new HangDump strings (German).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.es.xlfLocalization update for new HangDump strings (Spanish).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.fr.xlfLocalization update for new HangDump strings (French).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.it.xlfLocalization update for new HangDump strings (Italian).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ja.xlfLocalization update for new HangDump strings (Japanese).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ko.xlfLocalization update for new HangDump strings (Korean).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.pl.xlfLocalization update for new HangDump strings (Polish).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.pt-BR.xlfLocalization update for new HangDump strings (Portuguese - Brazil).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ru.xlfLocalization update for new HangDump strings (Russian).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.tr.xlfLocalization update for new HangDump strings (Turkish).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.zh-Hans.xlfLocalization update for new HangDump strings (Chinese Simplified).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.zh-Hant.xlfLocalization update for new HangDump strings (Chinese Traditional).
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpCommandLineOptions.csDefines the new crash-report-if-supported option name constant.
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpCommandLineProvider.csRegisters --crash-report-if-supported, enforces mutual exclusion, and treats it as a main option.
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpEnvironmentVariableProvider.csGates env-var application via IsCrashReportEffective so Windows/.NET Framework no-op cases don’t error.
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpProcessLifetimeHandler.csEnables handler for --crash-report-if-supported to emit the informational line and avoids artifact scanning when ineffective.
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/CrashDumpResources.resxAdds CrashDump option description + mutual-exclusion and “ignored” info messages; updates Windows unsupported message.
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.cs.xlfLocalization update for new CrashDump strings (Czech).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.de.xlfLocalization update for new CrashDump strings (German).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.es.xlfLocalization update for new CrashDump strings (Spanish).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.fr.xlfLocalization update for new CrashDump strings (French).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.it.xlfLocalization update for new CrashDump strings (Italian).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.ja.xlfLocalization update for new CrashDump strings (Japanese).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.ko.xlfLocalization update for new CrashDump strings (Korean).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.pl.xlfLocalization update for new CrashDump strings (Polish).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.pt-BR.xlfLocalization update for new CrashDump strings (Portuguese - Brazil).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.ru.xlfLocalization update for new CrashDump strings (Russian).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.tr.xlfLocalization update for new CrashDump strings (Turkish).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.zh-Hans.xlfLocalization update for new CrashDump strings (Chinese Simplified).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.zh-Hant.xlfLocalization update for new CrashDump strings (Chinese Traditional).

Copilot's findings

  • Files reviewed: 37/37 changed files
  • Comments generated: 3

Aligns three locations that still described --hangdump-type-if-supported
as falling back to the default 'Full' (the original design) instead of
the actual closest-supported-type mapping (Triage -> Mini on netfx):
- HangDumpCommandLineProvider.cs: AllHangDumpTypeOptions comment.
- HelpInfoAllExtensionsTests.cs: --help and --info expectations.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Review of PR #8666--crash-report-if-supported / --hangdump-type-if-supported

Summary

The overall design is sound and well-structured: the new -if-supported companions are wired in at every layer (CLI validation, env-var provider, lifecycle callbacks), the mutual-exclusion checks are correct, the IsCrashReportEffective predicate cleanly avoids double-activation, and the MapToSupportedDumpType / IsHangDumpTypeSupportedOnCurrentRuntime pair is a solid runtime-dispatch pattern.

21-dimension verdict

#DimensionVerdictNotes
1Algorithmic CorrectnessIsCrashReportEffective, MapToSupportedDumpType, and the IsCrashHandlingEffective guard all trace correctly for every branch (netfx/net·win/net·unix). ApplicationStateGuard.Ensure guards are preserved.
2Threading & Concurrency⚠️_ifSupportedIgnoredMessageEmitted is a non-volatilebool read/written across potential thread switches; see inline comment.
3SecurityNo new file operations or untrusted input.
4Public API / Binary CompatAll new constants and helpers are internal. No PublicAPI.Unshipped.txt changes needed.
5PerformanceCold path only; no hot-path impact.
6Cross-TFM Compatibility#if !NETCOREAPP / #if NET guards are correct and consistent.
7Resource / IDisposableNo new disposables.
8Defensive CodingExisting ApplicationStateGuard.Ensure guards preserved; new guards added only for the effective paths.
9LocalizationAll strings in .resx. XLF files carry target state="new" markers (build-generated, not hand-edited).
10Test IsolationNo shared static mutable state added.
11Assertion QualityUnit tests use MSTest assertions as required for MTP test projects.
12FlakinessNo time-dependent assertions.
13CLI / Option Consistency⚠️--hangdump-type-if-supported is classified as a "sub-option" (requires --hangdump), consistent with --hangdump-type — but the option name implies it could stand alone. The PR description says this is intentional; worth a note in the --help description or error message so users aren't confused.
14Output / UX⚠️WarningMessageOutputDeviceData (yellow) used for graceful no-op paths. When the user chose -if-supportedbecause they expect the platform not to support it, a yellow warning is noise. See inline comments on CrashDumpProcessLifetimeHandler.cs:102 and HangDumpProcessLifetimeHandler.cs:121.
15Test CoverageUnit tests cover IsCrashReportEffective, MapToSupportedDumpType, mutual exclusion, and argument validation.
16Naming & ConventionsNaming is clear and consistent with the existing --crashdump / --hangdump family.
17Comment QualityInline comments are detailed and reference the upstream runtime issue (dotnet/runtime#80191).
18Error MessagesMutual-exclusion messages guide the user toward the correct option.
19Scope DisciplinePR is tightly focused on the two new companion options.
20Help/Info Test UpdatesHelpInfoAllExtensionsTests expectations updated.
21XLF / Localization PipelineXLF files correctly updated with target state="new" by the build tool.

Actionable items

  1. _ifSupportedIgnoredMessageEmitted — add volatile (CrashDumpProcessLifetimeHandler.cs:44): the "emit once" guard can be bypassed under concurrent test-host restarts without a memory barrier.
  2. WarningMessageOutputDeviceData → informational format (CrashDumpProcessLifetimeHandler.cs:102/110, HangDumpProcessLifetimeHandler.cs:121): the -if-supported variants are explicitly opt-in best-effort; a yellow warning contradicts the intent and adds noise to CI logs.

Generated by Expert Code Review (on open) for issue #8666 · sonnet46 3.6M

- Use FormattedTextOutputDeviceData instead of WarningMessageOutputDeviceData
for the '-if-supported' no-op / fallback messages. These are expected,
graceful paths; rendering them as yellow warnings would mislead CI users.
(CrashDumpProcessLifetimeHandler.cs x2, HangDumpProcessLifetimeHandler.cs x1)
- Replace the plain bool one-shot guard in CrashDumpProcessLifetimeHandler
with Interlocked.Exchange on an int field, so that concurrent invocations
(e.g. test-host controller retries) cannot race past the guard. Also
restructure to early-return when the option will not emit anything on the
current runtime/OS, so the guard is only claimed when we actually emit.
- Collapse the nested 'if' in HangDumpCommandLineProvider.ValidateOptionArgumentsAsync
for --hangdump-type-if-supported into a single conditional return (also
satisfies IDE0046).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings May 28, 2026 17:12

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

Comments suppressed due to low confidence (1)

test/UnitTests/Microsoft.Testing.Extensions.UnitTests/CrashDumpTests.cs:359

  • The placeholder-to-regex conversion test no longer covers several common createdump placeholders/pattern shapes (e.g. %e, %h, %t, literal-only patterns). Those DataRow cases previously validated that placeholders are expanded to wildcards across multiple tokens and adjacent placeholders; dropping them reduces coverage for BuildDumpFileNameRegexPattern and makes regressions easier to miss.
  • Files reviewed: 37/37 changed files
  • Comments generated: 1

…ents
The earlier comment in CrashDumpEnvironmentVariableProvider above the
'crashReportEnabled' assignment said 'IsEnabledAsync gates this method,
so at least one of --crashdump / --crash-report / --crash-report-if-supported
is set here.' That wording suggested '--crash-report-if-supported' alone
is sufficient to reach UpdateAsync / ValidateTestHostEnvironmentVariablesAsync
even on Windows / .NET Framework, where the option is intentionally a
no-op (IsCrashReportEffective returns false and IsEnabledAsync is false
unless '--crashdump' is also set).
Reword both occurrences to refer to an *effective* crash-report request
so future readers do not misinterpret the precondition.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings May 29, 2026 16:45

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 37/37 changed files
  • Comments generated: 0 new

@Evangelink
Amaury Levé (Evangelink) merged commit 35f4f1e into mainMay 31, 2026
25 of 26 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/crash-report-if-supported branch May 31, 2026 06:41
Amaury Levé (Evangelink) added a commit that referenced this pull request May 31, 2026
…om PR #8666 (#8716)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for freeto 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.

Add option to collect gcdump (MTPv2)

2 participants

@Evangelink
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Add --crash-report-if-supported and --hangdump-type-if-supported options - #8666

Merged
Amaury Levé (Evangelink) merged 5 commits into
mainfrom
dev/amauryleve/crash-report-if-supported
May 31, 2026
Merged

Add --crash-report-if-supported and --hangdump-type-if-supported options#8666
Amaury Levé (Evangelink) merged 5 commits into
mainfrom
dev/amauryleve/crash-report-if-supported

Conversation

@Evangelink

@EvangelinkAmaury Levé (Evangelink) commented May 28, 2026

Copy link
Copy Markdown
Member

Closes#7126 (companion options for --crash-report and --hangdump-type).

Problem

@bart-vmware pointed out that --crash-report errors out on Windows because the .NET runtime ignores DOTNET_EnableCrashReportOnly there. The same kind of friction exists for --hangdump-type Triage on .NET Framework (Triage is a netcoreapp-only dump type). The current behaviour forces consumers to maintain different CLI commands per OS / TFM in their CI scripts.

Solution

Introduce two new -if-supported companion options that behave identically to the strict variants when the underlying mechanism is supported, and silently no-op (with a single info line on the console) when it is not.

StrictNew companion
--crash-report (errors on Windows)--crash-report-if-supported (no-op on Windows / .NET Framework)
--hangdump-type <Mini|Heap|Full|Triage|None> (Triage rejected on netfx)--hangdump-type-if-supported <…> (Triage on netfx maps to Mini)

This lets users keep a single CI invocation across all build legs.

Naming rationale

We considered short forms (--crash-report?, --crash-report-best-effort, etc.) and decided on the explicit long -if-supported suffix:

  • The semantics are obvious from the name.
  • A short form would still need aliasing in the parser; the saving is small.
  • Future -if-supported variants can follow the same pattern.

Behaviour matrix

--crash-report-if-supported

RuntimeOSBehaviour
.NET FrameworkWindows / Linux / macOSNo-op (info message)
.NET (Core)WindowsNo-op (info message)
.NET (Core)Linux / macOSSame as --crash-report

Mutually exclusive with --crash-report.

--hangdump-type-if-supported <type>

TFMRequested typeResult
.NET (Core)any of Mini, Heap, Full, Triage, NoneHonored unchanged
.NET FrameworkMini / Heap / Full / NoneHonored unchanged
.NET FrameworkTriageMapped to Mini (info message), as Mini is the closest equivalent

Mutually exclusive with --hangdump-type.

Implementation notes

The lifetime handler's IsEnabledAsync returns true for the no-op case (so it can emit the info message), but the env-var provider's IsEnabledAsync and the lifecycle methods are gated on IsCrashReportEffective / IsHangDumpTypeSupportedOnCurrentRuntime to avoid:

  • Hard-erroring on .NET Framework via ValidateTestHostEnvironmentVariablesAsync.
  • Setting DbgEnableMiniDump=1 on Windows when the mechanism is known to be ignored.
  • Tripping ApplicationStateGuard.Ensure checks on a dump file name pattern that was never set up.

Tests

  • Unit tests for IsCrashReportEffective and MapToSupportedDumpType (added to CrashDumpTests / HangDumpTests).
  • Validation tests: mutual-exclusion error, accepted alongside --crashdump, never rejected on any platform, satisfies the -main-option-missing rule, both variants registered as arity-0.
  • Updated HelpInfoAllExtensionsTests expectations for both human-readable and structured --info output.

Local validation: 85/89 tests pass on net8.0 (4 Windows-skipped pre-existing CrashReport tests), 84/88 on net472 (same 4 skipped). Production projects (Microsoft.Testing.Extensions.CrashDump, Microsoft.Testing.Extensions.HangDump) and the unit-test project all build clean (0 warnings, 0 errors).

Acceptance tests for end-to-end behaviour aren't included here yet; happy to follow up if reviewers want them.

Why not an environment variable?

@bart-vmware also suggested keeping the hard error but letting users opt into a "downgrade to info" via an environment variable. We discarded that route in favour of an explicit CLI option for the following reasons:

  • Discoverability. A new CLI option shows up in --help / --info and is grep-able in CI scripts. An environment variable only surfaces when the user already hit the error and read the message, which is exactly the friction we are trying to remove.
  • Self-documenting CI scripts.--crash-report-if-supported clearly conveys the user's intent ("I want a crash report when I can get one"). A script that sets MTP_ALLOW_UNSUPPORTED_CRASH_REPORT=1 (or similar) and then calls --crash-report hides that intent in the environment.
  • Scope. An env-var-suppression mechanism would need to be replicated per option family (--crash-report, --hangdump-type Triage, plus every future option in the same situation), inflating the env-var surface. The -if-supported suffix is a uniform naming convention we can reuse going forward.
  • Local debugging. When investigating a build leg, an explicit CLI flag is much easier to reason about than "is there an environment variable set somewhere up the call stack?". Env vars also leak between commands in a CI step.
  • Composability. Users who genuinely want to fail fast on unsupported runtimes can keep using the strict --crash-report / --hangdump-type — the two variants coexist, are mutually exclusive at validation time, and a single CI matrix can mix the two if it really wants to.

The strict --crash-report / --hangdump-type are unchanged, so callers that prefer the fail-fast contract keep their current behaviour.

Companion options that silently no-op when the underlying mechanism is
unsupported on the current OS/TFM, so a single CLI line works on every
build leg (issue #7126).
- --crash-report-if-supported (arity 0): mirrors --crash-report but is
ignored on Windows (DOTNET_EnableCrashReportOnly is not honored there)
and on .NET Framework (no createdump runtime).
- --hangdump-type-if-supported <Mini|Heap|Full|Triage|None> (arity 1):
mirrors --hangdump-type but maps requested types unsupported on the
current TFM (today: Triage on .NET Framework) to the closest
equivalent (Mini).
Each variant emits a single informational line when it no-ops so users
can see the substitution happened.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings May 28, 2026 16:47

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds “best-effort” companion CLI options in Microsoft.Testing.Platform diagnostics extensions to reduce CI matrix friction by silently no-op’ing (with a single console message) when the underlying crash-report or dump-type mechanism isn’t supported on the current runtime/OS.

Changes:

  • Add --crash-report-if-supported (CrashDump) and --hangdump-type-if-supported (HangDump) options with mutual-exclusion validation against their strict counterparts.
  • Implement runtime/OS gating and fallback behavior (CrashReport ignored on Windows/.NET Framework; HangDump type mapping when requested type isn’t supported).
  • Add/extend unit tests, update help/info acceptance expectations, and update localized resources.
Show a summary per file
FileDescription
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/HangDumpTests.csAdds unit coverage for --hangdump-type-if-supported validation, mutual exclusion, and mapping helpers.
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/CrashDumpTests.csAdds unit coverage for --crash-report-if-supported, mutual exclusion, arity, and “effective” gating helper.
test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoAllExtensionsTests.csUpdates --help / --info expectations to include the new options and their descriptions.
src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpCommandLineProvider.csRegisters --hangdump-type-if-supported, validates values across TFMs, enforces mutual exclusion, and adds mapping helpers.
src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpProcessLifetimeHandler.csApplies best-effort dump-type mapping and emits a single message when a fallback occurs.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/ExtensionResources.resxAdds new HangDump option description + mutual-exclusion/fallback messages.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.cs.xlfLocalization update for new HangDump strings (Czech).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.de.xlfLocalization update for new HangDump strings (German).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.es.xlfLocalization update for new HangDump strings (Spanish).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.fr.xlfLocalization update for new HangDump strings (French).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.it.xlfLocalization update for new HangDump strings (Italian).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ja.xlfLocalization update for new HangDump strings (Japanese).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ko.xlfLocalization update for new HangDump strings (Korean).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.pl.xlfLocalization update for new HangDump strings (Polish).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.pt-BR.xlfLocalization update for new HangDump strings (Portuguese - Brazil).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ru.xlfLocalization update for new HangDump strings (Russian).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.tr.xlfLocalization update for new HangDump strings (Turkish).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.zh-Hans.xlfLocalization update for new HangDump strings (Chinese Simplified).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.zh-Hant.xlfLocalization update for new HangDump strings (Chinese Traditional).
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpCommandLineOptions.csDefines the new crash-report-if-supported option name constant.
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpCommandLineProvider.csRegisters --crash-report-if-supported, enforces mutual exclusion, and treats it as a main option.
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpEnvironmentVariableProvider.csGates env-var application via IsCrashReportEffective so Windows/.NET Framework no-op cases don’t error.
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpProcessLifetimeHandler.csEnables handler for --crash-report-if-supported to emit the informational line and avoids artifact scanning when ineffective.
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/CrashDumpResources.resxAdds CrashDump option description + mutual-exclusion and “ignored” info messages; updates Windows unsupported message.
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.cs.xlfLocalization update for new CrashDump strings (Czech).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.de.xlfLocalization update for new CrashDump strings (German).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.es.xlfLocalization update for new CrashDump strings (Spanish).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.fr.xlfLocalization update for new CrashDump strings (French).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.it.xlfLocalization update for new CrashDump strings (Italian).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.ja.xlfLocalization update for new CrashDump strings (Japanese).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.ko.xlfLocalization update for new CrashDump strings (Korean).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.pl.xlfLocalization update for new CrashDump strings (Polish).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.pt-BR.xlfLocalization update for new CrashDump strings (Portuguese - Brazil).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.ru.xlfLocalization update for new CrashDump strings (Russian).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.tr.xlfLocalization update for new CrashDump strings (Turkish).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.zh-Hans.xlfLocalization update for new CrashDump strings (Chinese Simplified).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.zh-Hant.xlfLocalization update for new CrashDump strings (Chinese Traditional).

Copilot's findings

  • Files reviewed: 37/37 changed files
  • Comments generated: 3

Aligns three locations that still described --hangdump-type-if-supported
as falling back to the default 'Full' (the original design) instead of
the actual closest-supported-type mapping (Triage -> Mini on netfx):
- HangDumpCommandLineProvider.cs: AllHangDumpTypeOptions comment.
- HelpInfoAllExtensionsTests.cs: --help and --info expectations.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Review of PR #8666--crash-report-if-supported / --hangdump-type-if-supported

Summary

The overall design is sound and well-structured: the new -if-supported companions are wired in at every layer (CLI validation, env-var provider, lifecycle callbacks), the mutual-exclusion checks are correct, the IsCrashReportEffective predicate cleanly avoids double-activation, and the MapToSupportedDumpType / IsHangDumpTypeSupportedOnCurrentRuntime pair is a solid runtime-dispatch pattern.

21-dimension verdict

#DimensionVerdictNotes
1Algorithmic CorrectnessIsCrashReportEffective, MapToSupportedDumpType, and the IsCrashHandlingEffective guard all trace correctly for every branch (netfx/net·win/net·unix). ApplicationStateGuard.Ensure guards are preserved.
2Threading & Concurrency⚠️_ifSupportedIgnoredMessageEmitted is a non-volatilebool read/written across potential thread switches; see inline comment.
3SecurityNo new file operations or untrusted input.
4Public API / Binary CompatAll new constants and helpers are internal. No PublicAPI.Unshipped.txt changes needed.
5PerformanceCold path only; no hot-path impact.
6Cross-TFM Compatibility#if !NETCOREAPP / #if NET guards are correct and consistent.
7Resource / IDisposableNo new disposables.
8Defensive CodingExisting ApplicationStateGuard.Ensure guards preserved; new guards added only for the effective paths.
9LocalizationAll strings in .resx. XLF files carry target state="new" markers (build-generated, not hand-edited).
10Test IsolationNo shared static mutable state added.
11Assertion QualityUnit tests use MSTest assertions as required for MTP test projects.
12FlakinessNo time-dependent assertions.
13CLI / Option Consistency⚠️--hangdump-type-if-supported is classified as a "sub-option" (requires --hangdump), consistent with --hangdump-type — but the option name implies it could stand alone. The PR description says this is intentional; worth a note in the --help description or error message so users aren't confused.
14Output / UX⚠️WarningMessageOutputDeviceData (yellow) used for graceful no-op paths. When the user chose -if-supportedbecause they expect the platform not to support it, a yellow warning is noise. See inline comments on CrashDumpProcessLifetimeHandler.cs:102 and HangDumpProcessLifetimeHandler.cs:121.
15Test CoverageUnit tests cover IsCrashReportEffective, MapToSupportedDumpType, mutual exclusion, and argument validation.
16Naming & ConventionsNaming is clear and consistent with the existing --crashdump / --hangdump family.
17Comment QualityInline comments are detailed and reference the upstream runtime issue (dotnet/runtime#80191).
18Error MessagesMutual-exclusion messages guide the user toward the correct option.
19Scope DisciplinePR is tightly focused on the two new companion options.
20Help/Info Test UpdatesHelpInfoAllExtensionsTests expectations updated.
21XLF / Localization PipelineXLF files correctly updated with target state="new" by the build tool.

Actionable items

  1. _ifSupportedIgnoredMessageEmitted — add volatile (CrashDumpProcessLifetimeHandler.cs:44): the "emit once" guard can be bypassed under concurrent test-host restarts without a memory barrier.
  2. WarningMessageOutputDeviceData → informational format (CrashDumpProcessLifetimeHandler.cs:102/110, HangDumpProcessLifetimeHandler.cs:121): the -if-supported variants are explicitly opt-in best-effort; a yellow warning contradicts the intent and adds noise to CI logs.

Generated by Expert Code Review (on open) for issue #8666 · sonnet46 3.6M

- Use FormattedTextOutputDeviceData instead of WarningMessageOutputDeviceData
for the '-if-supported' no-op / fallback messages. These are expected,
graceful paths; rendering them as yellow warnings would mislead CI users.
(CrashDumpProcessLifetimeHandler.cs x2, HangDumpProcessLifetimeHandler.cs x1)
- Replace the plain bool one-shot guard in CrashDumpProcessLifetimeHandler
with Interlocked.Exchange on an int field, so that concurrent invocations
(e.g. test-host controller retries) cannot race past the guard. Also
restructure to early-return when the option will not emit anything on the
current runtime/OS, so the guard is only claimed when we actually emit.
- Collapse the nested 'if' in HangDumpCommandLineProvider.ValidateOptionArgumentsAsync
for --hangdump-type-if-supported into a single conditional return (also
satisfies IDE0046).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings May 28, 2026 17:12

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

Comments suppressed due to low confidence (1)

test/UnitTests/Microsoft.Testing.Extensions.UnitTests/CrashDumpTests.cs:359

  • The placeholder-to-regex conversion test no longer covers several common createdump placeholders/pattern shapes (e.g. %e, %h, %t, literal-only patterns). Those DataRow cases previously validated that placeholders are expanded to wildcards across multiple tokens and adjacent placeholders; dropping them reduces coverage for BuildDumpFileNameRegexPattern and makes regressions easier to miss.
  • Files reviewed: 37/37 changed files
  • Comments generated: 1

…ents
The earlier comment in CrashDumpEnvironmentVariableProvider above the
'crashReportEnabled' assignment said 'IsEnabledAsync gates this method,
so at least one of --crashdump / --crash-report / --crash-report-if-supported
is set here.' That wording suggested '--crash-report-if-supported' alone
is sufficient to reach UpdateAsync / ValidateTestHostEnvironmentVariablesAsync
even on Windows / .NET Framework, where the option is intentionally a
no-op (IsCrashReportEffective returns false and IsEnabledAsync is false
unless '--crashdump' is also set).
Reword both occurrences to refer to an *effective* crash-report request
so future readers do not misinterpret the precondition.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings May 29, 2026 16:45

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 37/37 changed files
  • Comments generated: 0 new

@Evangelink
Amaury Levé (Evangelink) merged commit 35f4f1e into mainMay 31, 2026
25 of 26 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/crash-report-if-supported branch May 31, 2026 06:41
Amaury Levé (Evangelink) added a commit that referenced this pull request May 31, 2026
…om PR #8666 (#8716)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for freeto 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.

Add option to collect gcdump (MTPv2)

2 participants

@Evangelink
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Add --crash-report-if-supported and --hangdump-type-if-supported options - #8666

Merged
Amaury Levé (Evangelink) merged 5 commits into
mainfrom
dev/amauryleve/crash-report-if-supported
May 31, 2026
Merged

Add --crash-report-if-supported and --hangdump-type-if-supported options#8666
Amaury Levé (Evangelink) merged 5 commits into
mainfrom
dev/amauryleve/crash-report-if-supported

Conversation

@Evangelink

@EvangelinkAmaury Levé (Evangelink) commented May 28, 2026

Copy link
Copy Markdown
Member

Closes#7126 (companion options for --crash-report and --hangdump-type).

Problem

@bart-vmware pointed out that --crash-report errors out on Windows because the .NET runtime ignores DOTNET_EnableCrashReportOnly there. The same kind of friction exists for --hangdump-type Triage on .NET Framework (Triage is a netcoreapp-only dump type). The current behaviour forces consumers to maintain different CLI commands per OS / TFM in their CI scripts.

Solution

Introduce two new -if-supported companion options that behave identically to the strict variants when the underlying mechanism is supported, and silently no-op (with a single info line on the console) when it is not.

StrictNew companion
--crash-report (errors on Windows)--crash-report-if-supported (no-op on Windows / .NET Framework)
--hangdump-type <Mini|Heap|Full|Triage|None> (Triage rejected on netfx)--hangdump-type-if-supported <…> (Triage on netfx maps to Mini)

This lets users keep a single CI invocation across all build legs.

Naming rationale

We considered short forms (--crash-report?, --crash-report-best-effort, etc.) and decided on the explicit long -if-supported suffix:

  • The semantics are obvious from the name.
  • A short form would still need aliasing in the parser; the saving is small.
  • Future -if-supported variants can follow the same pattern.

Behaviour matrix

--crash-report-if-supported

RuntimeOSBehaviour
.NET FrameworkWindows / Linux / macOSNo-op (info message)
.NET (Core)WindowsNo-op (info message)
.NET (Core)Linux / macOSSame as --crash-report

Mutually exclusive with --crash-report.

--hangdump-type-if-supported <type>

TFMRequested typeResult
.NET (Core)any of Mini, Heap, Full, Triage, NoneHonored unchanged
.NET FrameworkMini / Heap / Full / NoneHonored unchanged
.NET FrameworkTriageMapped to Mini (info message), as Mini is the closest equivalent

Mutually exclusive with --hangdump-type.

Implementation notes

The lifetime handler's IsEnabledAsync returns true for the no-op case (so it can emit the info message), but the env-var provider's IsEnabledAsync and the lifecycle methods are gated on IsCrashReportEffective / IsHangDumpTypeSupportedOnCurrentRuntime to avoid:

  • Hard-erroring on .NET Framework via ValidateTestHostEnvironmentVariablesAsync.
  • Setting DbgEnableMiniDump=1 on Windows when the mechanism is known to be ignored.
  • Tripping ApplicationStateGuard.Ensure checks on a dump file name pattern that was never set up.

Tests

  • Unit tests for IsCrashReportEffective and MapToSupportedDumpType (added to CrashDumpTests / HangDumpTests).
  • Validation tests: mutual-exclusion error, accepted alongside --crashdump, never rejected on any platform, satisfies the -main-option-missing rule, both variants registered as arity-0.
  • Updated HelpInfoAllExtensionsTests expectations for both human-readable and structured --info output.

Local validation: 85/89 tests pass on net8.0 (4 Windows-skipped pre-existing CrashReport tests), 84/88 on net472 (same 4 skipped). Production projects (Microsoft.Testing.Extensions.CrashDump, Microsoft.Testing.Extensions.HangDump) and the unit-test project all build clean (0 warnings, 0 errors).

Acceptance tests for end-to-end behaviour aren't included here yet; happy to follow up if reviewers want them.

Why not an environment variable?

@bart-vmware also suggested keeping the hard error but letting users opt into a "downgrade to info" via an environment variable. We discarded that route in favour of an explicit CLI option for the following reasons:

  • Discoverability. A new CLI option shows up in --help / --info and is grep-able in CI scripts. An environment variable only surfaces when the user already hit the error and read the message, which is exactly the friction we are trying to remove.
  • Self-documenting CI scripts.--crash-report-if-supported clearly conveys the user's intent ("I want a crash report when I can get one"). A script that sets MTP_ALLOW_UNSUPPORTED_CRASH_REPORT=1 (or similar) and then calls --crash-report hides that intent in the environment.
  • Scope. An env-var-suppression mechanism would need to be replicated per option family (--crash-report, --hangdump-type Triage, plus every future option in the same situation), inflating the env-var surface. The -if-supported suffix is a uniform naming convention we can reuse going forward.
  • Local debugging. When investigating a build leg, an explicit CLI flag is much easier to reason about than "is there an environment variable set somewhere up the call stack?". Env vars also leak between commands in a CI step.
  • Composability. Users who genuinely want to fail fast on unsupported runtimes can keep using the strict --crash-report / --hangdump-type — the two variants coexist, are mutually exclusive at validation time, and a single CI matrix can mix the two if it really wants to.

The strict --crash-report / --hangdump-type are unchanged, so callers that prefer the fail-fast contract keep their current behaviour.

Companion options that silently no-op when the underlying mechanism is
unsupported on the current OS/TFM, so a single CLI line works on every
build leg (issue #7126).
- --crash-report-if-supported (arity 0): mirrors --crash-report but is
ignored on Windows (DOTNET_EnableCrashReportOnly is not honored there)
and on .NET Framework (no createdump runtime).
- --hangdump-type-if-supported <Mini|Heap|Full|Triage|None> (arity 1):
mirrors --hangdump-type but maps requested types unsupported on the
current TFM (today: Triage on .NET Framework) to the closest
equivalent (Mini).
Each variant emits a single informational line when it no-ops so users
can see the substitution happened.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings May 28, 2026 16:47

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds “best-effort” companion CLI options in Microsoft.Testing.Platform diagnostics extensions to reduce CI matrix friction by silently no-op’ing (with a single console message) when the underlying crash-report or dump-type mechanism isn’t supported on the current runtime/OS.

Changes:

  • Add --crash-report-if-supported (CrashDump) and --hangdump-type-if-supported (HangDump) options with mutual-exclusion validation against their strict counterparts.
  • Implement runtime/OS gating and fallback behavior (CrashReport ignored on Windows/.NET Framework; HangDump type mapping when requested type isn’t supported).
  • Add/extend unit tests, update help/info acceptance expectations, and update localized resources.
Show a summary per file
FileDescription
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/HangDumpTests.csAdds unit coverage for --hangdump-type-if-supported validation, mutual exclusion, and mapping helpers.
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/CrashDumpTests.csAdds unit coverage for --crash-report-if-supported, mutual exclusion, arity, and “effective” gating helper.
test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoAllExtensionsTests.csUpdates --help / --info expectations to include the new options and their descriptions.
src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpCommandLineProvider.csRegisters --hangdump-type-if-supported, validates values across TFMs, enforces mutual exclusion, and adds mapping helpers.
src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpProcessLifetimeHandler.csApplies best-effort dump-type mapping and emits a single message when a fallback occurs.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/ExtensionResources.resxAdds new HangDump option description + mutual-exclusion/fallback messages.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.cs.xlfLocalization update for new HangDump strings (Czech).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.de.xlfLocalization update for new HangDump strings (German).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.es.xlfLocalization update for new HangDump strings (Spanish).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.fr.xlfLocalization update for new HangDump strings (French).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.it.xlfLocalization update for new HangDump strings (Italian).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ja.xlfLocalization update for new HangDump strings (Japanese).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ko.xlfLocalization update for new HangDump strings (Korean).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.pl.xlfLocalization update for new HangDump strings (Polish).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.pt-BR.xlfLocalization update for new HangDump strings (Portuguese - Brazil).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ru.xlfLocalization update for new HangDump strings (Russian).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.tr.xlfLocalization update for new HangDump strings (Turkish).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.zh-Hans.xlfLocalization update for new HangDump strings (Chinese Simplified).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.zh-Hant.xlfLocalization update for new HangDump strings (Chinese Traditional).
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpCommandLineOptions.csDefines the new crash-report-if-supported option name constant.
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpCommandLineProvider.csRegisters --crash-report-if-supported, enforces mutual exclusion, and treats it as a main option.
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpEnvironmentVariableProvider.csGates env-var application via IsCrashReportEffective so Windows/.NET Framework no-op cases don’t error.
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpProcessLifetimeHandler.csEnables handler for --crash-report-if-supported to emit the informational line and avoids artifact scanning when ineffective.
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/CrashDumpResources.resxAdds CrashDump option description + mutual-exclusion and “ignored” info messages; updates Windows unsupported message.
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.cs.xlfLocalization update for new CrashDump strings (Czech).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.de.xlfLocalization update for new CrashDump strings (German).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.es.xlfLocalization update for new CrashDump strings (Spanish).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.fr.xlfLocalization update for new CrashDump strings (French).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.it.xlfLocalization update for new CrashDump strings (Italian).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.ja.xlfLocalization update for new CrashDump strings (Japanese).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.ko.xlfLocalization update for new CrashDump strings (Korean).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.pl.xlfLocalization update for new CrashDump strings (Polish).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.pt-BR.xlfLocalization update for new CrashDump strings (Portuguese - Brazil).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.ru.xlfLocalization update for new CrashDump strings (Russian).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.tr.xlfLocalization update for new CrashDump strings (Turkish).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.zh-Hans.xlfLocalization update for new CrashDump strings (Chinese Simplified).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.zh-Hant.xlfLocalization update for new CrashDump strings (Chinese Traditional).

Copilot's findings

  • Files reviewed: 37/37 changed files
  • Comments generated: 3

Aligns three locations that still described --hangdump-type-if-supported
as falling back to the default 'Full' (the original design) instead of
the actual closest-supported-type mapping (Triage -> Mini on netfx):
- HangDumpCommandLineProvider.cs: AllHangDumpTypeOptions comment.
- HelpInfoAllExtensionsTests.cs: --help and --info expectations.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Review of PR #8666--crash-report-if-supported / --hangdump-type-if-supported

Summary

The overall design is sound and well-structured: the new -if-supported companions are wired in at every layer (CLI validation, env-var provider, lifecycle callbacks), the mutual-exclusion checks are correct, the IsCrashReportEffective predicate cleanly avoids double-activation, and the MapToSupportedDumpType / IsHangDumpTypeSupportedOnCurrentRuntime pair is a solid runtime-dispatch pattern.

21-dimension verdict

#DimensionVerdictNotes
1Algorithmic CorrectnessIsCrashReportEffective, MapToSupportedDumpType, and the IsCrashHandlingEffective guard all trace correctly for every branch (netfx/net·win/net·unix). ApplicationStateGuard.Ensure guards are preserved.
2Threading & Concurrency⚠️_ifSupportedIgnoredMessageEmitted is a non-volatilebool read/written across potential thread switches; see inline comment.
3SecurityNo new file operations or untrusted input.
4Public API / Binary CompatAll new constants and helpers are internal. No PublicAPI.Unshipped.txt changes needed.
5PerformanceCold path only; no hot-path impact.
6Cross-TFM Compatibility#if !NETCOREAPP / #if NET guards are correct and consistent.
7Resource / IDisposableNo new disposables.
8Defensive CodingExisting ApplicationStateGuard.Ensure guards preserved; new guards added only for the effective paths.
9LocalizationAll strings in .resx. XLF files carry target state="new" markers (build-generated, not hand-edited).
10Test IsolationNo shared static mutable state added.
11Assertion QualityUnit tests use MSTest assertions as required for MTP test projects.
12FlakinessNo time-dependent assertions.
13CLI / Option Consistency⚠️--hangdump-type-if-supported is classified as a "sub-option" (requires --hangdump), consistent with --hangdump-type — but the option name implies it could stand alone. The PR description says this is intentional; worth a note in the --help description or error message so users aren't confused.
14Output / UX⚠️WarningMessageOutputDeviceData (yellow) used for graceful no-op paths. When the user chose -if-supportedbecause they expect the platform not to support it, a yellow warning is noise. See inline comments on CrashDumpProcessLifetimeHandler.cs:102 and HangDumpProcessLifetimeHandler.cs:121.
15Test CoverageUnit tests cover IsCrashReportEffective, MapToSupportedDumpType, mutual exclusion, and argument validation.
16Naming & ConventionsNaming is clear and consistent with the existing --crashdump / --hangdump family.
17Comment QualityInline comments are detailed and reference the upstream runtime issue (dotnet/runtime#80191).
18Error MessagesMutual-exclusion messages guide the user toward the correct option.
19Scope DisciplinePR is tightly focused on the two new companion options.
20Help/Info Test UpdatesHelpInfoAllExtensionsTests expectations updated.
21XLF / Localization PipelineXLF files correctly updated with target state="new" by the build tool.

Actionable items

  1. _ifSupportedIgnoredMessageEmitted — add volatile (CrashDumpProcessLifetimeHandler.cs:44): the "emit once" guard can be bypassed under concurrent test-host restarts without a memory barrier.
  2. WarningMessageOutputDeviceData → informational format (CrashDumpProcessLifetimeHandler.cs:102/110, HangDumpProcessLifetimeHandler.cs:121): the -if-supported variants are explicitly opt-in best-effort; a yellow warning contradicts the intent and adds noise to CI logs.

Generated by Expert Code Review (on open) for issue #8666 · sonnet46 3.6M

- Use FormattedTextOutputDeviceData instead of WarningMessageOutputDeviceData
for the '-if-supported' no-op / fallback messages. These are expected,
graceful paths; rendering them as yellow warnings would mislead CI users.
(CrashDumpProcessLifetimeHandler.cs x2, HangDumpProcessLifetimeHandler.cs x1)
- Replace the plain bool one-shot guard in CrashDumpProcessLifetimeHandler
with Interlocked.Exchange on an int field, so that concurrent invocations
(e.g. test-host controller retries) cannot race past the guard. Also
restructure to early-return when the option will not emit anything on the
current runtime/OS, so the guard is only claimed when we actually emit.
- Collapse the nested 'if' in HangDumpCommandLineProvider.ValidateOptionArgumentsAsync
for --hangdump-type-if-supported into a single conditional return (also
satisfies IDE0046).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings May 28, 2026 17:12

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

Comments suppressed due to low confidence (1)

test/UnitTests/Microsoft.Testing.Extensions.UnitTests/CrashDumpTests.cs:359

  • The placeholder-to-regex conversion test no longer covers several common createdump placeholders/pattern shapes (e.g. %e, %h, %t, literal-only patterns). Those DataRow cases previously validated that placeholders are expanded to wildcards across multiple tokens and adjacent placeholders; dropping them reduces coverage for BuildDumpFileNameRegexPattern and makes regressions easier to miss.
  • Files reviewed: 37/37 changed files
  • Comments generated: 1

…ents
The earlier comment in CrashDumpEnvironmentVariableProvider above the
'crashReportEnabled' assignment said 'IsEnabledAsync gates this method,
so at least one of --crashdump / --crash-report / --crash-report-if-supported
is set here.' That wording suggested '--crash-report-if-supported' alone
is sufficient to reach UpdateAsync / ValidateTestHostEnvironmentVariablesAsync
even on Windows / .NET Framework, where the option is intentionally a
no-op (IsCrashReportEffective returns false and IsEnabledAsync is false
unless '--crashdump' is also set).
Reword both occurrences to refer to an *effective* crash-report request
so future readers do not misinterpret the precondition.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings May 29, 2026 16:45

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 37/37 changed files
  • Comments generated: 0 new

@Evangelink
Amaury Levé (Evangelink) merged commit 35f4f1e into mainMay 31, 2026
25 of 26 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/crash-report-if-supported branch May 31, 2026 06:41
Amaury Levé (Evangelink) added a commit that referenced this pull request May 31, 2026
…om PR #8666 (#8716)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for freeto 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.

Add option to collect gcdump (MTPv2)

2 participants

@Evangelink
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Add --crash-report-if-supported and --hangdump-type-if-supported options - #8666

Merged
Amaury Levé (Evangelink) merged 5 commits into
mainfrom
dev/amauryleve/crash-report-if-supported
May 31, 2026
Merged

Add --crash-report-if-supported and --hangdump-type-if-supported options#8666
Amaury Levé (Evangelink) merged 5 commits into
mainfrom
dev/amauryleve/crash-report-if-supported

Conversation

@Evangelink

@EvangelinkAmaury Levé (Evangelink) commented May 28, 2026

Copy link
Copy Markdown
Member

Closes#7126 (companion options for --crash-report and --hangdump-type).

Problem

@bart-vmware pointed out that --crash-report errors out on Windows because the .NET runtime ignores DOTNET_EnableCrashReportOnly there. The same kind of friction exists for --hangdump-type Triage on .NET Framework (Triage is a netcoreapp-only dump type). The current behaviour forces consumers to maintain different CLI commands per OS / TFM in their CI scripts.

Solution

Introduce two new -if-supported companion options that behave identically to the strict variants when the underlying mechanism is supported, and silently no-op (with a single info line on the console) when it is not.

StrictNew companion
--crash-report (errors on Windows)--crash-report-if-supported (no-op on Windows / .NET Framework)
--hangdump-type <Mini|Heap|Full|Triage|None> (Triage rejected on netfx)--hangdump-type-if-supported <…> (Triage on netfx maps to Mini)

This lets users keep a single CI invocation across all build legs.

Naming rationale

We considered short forms (--crash-report?, --crash-report-best-effort, etc.) and decided on the explicit long -if-supported suffix:

  • The semantics are obvious from the name.
  • A short form would still need aliasing in the parser; the saving is small.
  • Future -if-supported variants can follow the same pattern.

Behaviour matrix

--crash-report-if-supported

RuntimeOSBehaviour
.NET FrameworkWindows / Linux / macOSNo-op (info message)
.NET (Core)WindowsNo-op (info message)
.NET (Core)Linux / macOSSame as --crash-report

Mutually exclusive with --crash-report.

--hangdump-type-if-supported <type>

TFMRequested typeResult
.NET (Core)any of Mini, Heap, Full, Triage, NoneHonored unchanged
.NET FrameworkMini / Heap / Full / NoneHonored unchanged
.NET FrameworkTriageMapped to Mini (info message), as Mini is the closest equivalent

Mutually exclusive with --hangdump-type.

Implementation notes

The lifetime handler's IsEnabledAsync returns true for the no-op case (so it can emit the info message), but the env-var provider's IsEnabledAsync and the lifecycle methods are gated on IsCrashReportEffective / IsHangDumpTypeSupportedOnCurrentRuntime to avoid:

  • Hard-erroring on .NET Framework via ValidateTestHostEnvironmentVariablesAsync.
  • Setting DbgEnableMiniDump=1 on Windows when the mechanism is known to be ignored.
  • Tripping ApplicationStateGuard.Ensure checks on a dump file name pattern that was never set up.

Tests

  • Unit tests for IsCrashReportEffective and MapToSupportedDumpType (added to CrashDumpTests / HangDumpTests).
  • Validation tests: mutual-exclusion error, accepted alongside --crashdump, never rejected on any platform, satisfies the -main-option-missing rule, both variants registered as arity-0.
  • Updated HelpInfoAllExtensionsTests expectations for both human-readable and structured --info output.

Local validation: 85/89 tests pass on net8.0 (4 Windows-skipped pre-existing CrashReport tests), 84/88 on net472 (same 4 skipped). Production projects (Microsoft.Testing.Extensions.CrashDump, Microsoft.Testing.Extensions.HangDump) and the unit-test project all build clean (0 warnings, 0 errors).

Acceptance tests for end-to-end behaviour aren't included here yet; happy to follow up if reviewers want them.

Why not an environment variable?

@bart-vmware also suggested keeping the hard error but letting users opt into a "downgrade to info" via an environment variable. We discarded that route in favour of an explicit CLI option for the following reasons:

  • Discoverability. A new CLI option shows up in --help / --info and is grep-able in CI scripts. An environment variable only surfaces when the user already hit the error and read the message, which is exactly the friction we are trying to remove.
  • Self-documenting CI scripts.--crash-report-if-supported clearly conveys the user's intent ("I want a crash report when I can get one"). A script that sets MTP_ALLOW_UNSUPPORTED_CRASH_REPORT=1 (or similar) and then calls --crash-report hides that intent in the environment.
  • Scope. An env-var-suppression mechanism would need to be replicated per option family (--crash-report, --hangdump-type Triage, plus every future option in the same situation), inflating the env-var surface. The -if-supported suffix is a uniform naming convention we can reuse going forward.
  • Local debugging. When investigating a build leg, an explicit CLI flag is much easier to reason about than "is there an environment variable set somewhere up the call stack?". Env vars also leak between commands in a CI step.
  • Composability. Users who genuinely want to fail fast on unsupported runtimes can keep using the strict --crash-report / --hangdump-type — the two variants coexist, are mutually exclusive at validation time, and a single CI matrix can mix the two if it really wants to.

The strict --crash-report / --hangdump-type are unchanged, so callers that prefer the fail-fast contract keep their current behaviour.

Companion options that silently no-op when the underlying mechanism is
unsupported on the current OS/TFM, so a single CLI line works on every
build leg (issue #7126).
- --crash-report-if-supported (arity 0): mirrors --crash-report but is
ignored on Windows (DOTNET_EnableCrashReportOnly is not honored there)
and on .NET Framework (no createdump runtime).
- --hangdump-type-if-supported <Mini|Heap|Full|Triage|None> (arity 1):
mirrors --hangdump-type but maps requested types unsupported on the
current TFM (today: Triage on .NET Framework) to the closest
equivalent (Mini).
Each variant emits a single informational line when it no-ops so users
can see the substitution happened.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings May 28, 2026 16:47

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds “best-effort” companion CLI options in Microsoft.Testing.Platform diagnostics extensions to reduce CI matrix friction by silently no-op’ing (with a single console message) when the underlying crash-report or dump-type mechanism isn’t supported on the current runtime/OS.

Changes:

  • Add --crash-report-if-supported (CrashDump) and --hangdump-type-if-supported (HangDump) options with mutual-exclusion validation against their strict counterparts.
  • Implement runtime/OS gating and fallback behavior (CrashReport ignored on Windows/.NET Framework; HangDump type mapping when requested type isn’t supported).
  • Add/extend unit tests, update help/info acceptance expectations, and update localized resources.
Show a summary per file
FileDescription
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/HangDumpTests.csAdds unit coverage for --hangdump-type-if-supported validation, mutual exclusion, and mapping helpers.
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/CrashDumpTests.csAdds unit coverage for --crash-report-if-supported, mutual exclusion, arity, and “effective” gating helper.
test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoAllExtensionsTests.csUpdates --help / --info expectations to include the new options and their descriptions.
src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpCommandLineProvider.csRegisters --hangdump-type-if-supported, validates values across TFMs, enforces mutual exclusion, and adds mapping helpers.
src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpProcessLifetimeHandler.csApplies best-effort dump-type mapping and emits a single message when a fallback occurs.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/ExtensionResources.resxAdds new HangDump option description + mutual-exclusion/fallback messages.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.cs.xlfLocalization update for new HangDump strings (Czech).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.de.xlfLocalization update for new HangDump strings (German).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.es.xlfLocalization update for new HangDump strings (Spanish).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.fr.xlfLocalization update for new HangDump strings (French).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.it.xlfLocalization update for new HangDump strings (Italian).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ja.xlfLocalization update for new HangDump strings (Japanese).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ko.xlfLocalization update for new HangDump strings (Korean).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.pl.xlfLocalization update for new HangDump strings (Polish).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.pt-BR.xlfLocalization update for new HangDump strings (Portuguese - Brazil).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ru.xlfLocalization update for new HangDump strings (Russian).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.tr.xlfLocalization update for new HangDump strings (Turkish).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.zh-Hans.xlfLocalization update for new HangDump strings (Chinese Simplified).
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.zh-Hant.xlfLocalization update for new HangDump strings (Chinese Traditional).
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpCommandLineOptions.csDefines the new crash-report-if-supported option name constant.
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpCommandLineProvider.csRegisters --crash-report-if-supported, enforces mutual exclusion, and treats it as a main option.
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpEnvironmentVariableProvider.csGates env-var application via IsCrashReportEffective so Windows/.NET Framework no-op cases don’t error.
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpProcessLifetimeHandler.csEnables handler for --crash-report-if-supported to emit the informational line and avoids artifact scanning when ineffective.
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/CrashDumpResources.resxAdds CrashDump option description + mutual-exclusion and “ignored” info messages; updates Windows unsupported message.
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.cs.xlfLocalization update for new CrashDump strings (Czech).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.de.xlfLocalization update for new CrashDump strings (German).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.es.xlfLocalization update for new CrashDump strings (Spanish).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.fr.xlfLocalization update for new CrashDump strings (French).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.it.xlfLocalization update for new CrashDump strings (Italian).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.ja.xlfLocalization update for new CrashDump strings (Japanese).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.ko.xlfLocalization update for new CrashDump strings (Korean).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.pl.xlfLocalization update for new CrashDump strings (Polish).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.pt-BR.xlfLocalization update for new CrashDump strings (Portuguese - Brazil).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.ru.xlfLocalization update for new CrashDump strings (Russian).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.tr.xlfLocalization update for new CrashDump strings (Turkish).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.zh-Hans.xlfLocalization update for new CrashDump strings (Chinese Simplified).
src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.zh-Hant.xlfLocalization update for new CrashDump strings (Chinese Traditional).

Copilot's findings

  • Files reviewed: 37/37 changed files
  • Comments generated: 3

Aligns three locations that still described --hangdump-type-if-supported
as falling back to the default 'Full' (the original design) instead of
the actual closest-supported-type mapping (Triage -> Mini on netfx):
- HangDumpCommandLineProvider.cs: AllHangDumpTypeOptions comment.
- HelpInfoAllExtensionsTests.cs: --help and --info expectations.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Review of PR #8666--crash-report-if-supported / --hangdump-type-if-supported

Summary

The overall design is sound and well-structured: the new -if-supported companions are wired in at every layer (CLI validation, env-var provider, lifecycle callbacks), the mutual-exclusion checks are correct, the IsCrashReportEffective predicate cleanly avoids double-activation, and the MapToSupportedDumpType / IsHangDumpTypeSupportedOnCurrentRuntime pair is a solid runtime-dispatch pattern.

21-dimension verdict

#DimensionVerdictNotes
1Algorithmic CorrectnessIsCrashReportEffective, MapToSupportedDumpType, and the IsCrashHandlingEffective guard all trace correctly for every branch (netfx/net·win/net·unix). ApplicationStateGuard.Ensure guards are preserved.
2Threading & Concurrency⚠️_ifSupportedIgnoredMessageEmitted is a non-volatilebool read/written across potential thread switches; see inline comment.
3SecurityNo new file operations or untrusted input.
4Public API / Binary CompatAll new constants and helpers are internal. No PublicAPI.Unshipped.txt changes needed.
5PerformanceCold path only; no hot-path impact.
6Cross-TFM Compatibility#if !NETCOREAPP / #if NET guards are correct and consistent.
7Resource / IDisposableNo new disposables.
8Defensive CodingExisting ApplicationStateGuard.Ensure guards preserved; new guards added only for the effective paths.
9LocalizationAll strings in .resx. XLF files carry target state="new" markers (build-generated, not hand-edited).
10Test IsolationNo shared static mutable state added.
11Assertion QualityUnit tests use MSTest assertions as required for MTP test projects.
12FlakinessNo time-dependent assertions.
13CLI / Option Consistency⚠️--hangdump-type-if-supported is classified as a "sub-option" (requires --hangdump), consistent with --hangdump-type — but the option name implies it could stand alone. The PR description says this is intentional; worth a note in the --help description or error message so users aren't confused.
14Output / UX⚠️WarningMessageOutputDeviceData (yellow) used for graceful no-op paths. When the user chose -if-supportedbecause they expect the platform not to support it, a yellow warning is noise. See inline comments on CrashDumpProcessLifetimeHandler.cs:102 and HangDumpProcessLifetimeHandler.cs:121.
15Test CoverageUnit tests cover IsCrashReportEffective, MapToSupportedDumpType, mutual exclusion, and argument validation.
16Naming & ConventionsNaming is clear and consistent with the existing --crashdump / --hangdump family.
17Comment QualityInline comments are detailed and reference the upstream runtime issue (dotnet/runtime#80191).
18Error MessagesMutual-exclusion messages guide the user toward the correct option.
19Scope DisciplinePR is tightly focused on the two new companion options.
20Help/Info Test UpdatesHelpInfoAllExtensionsTests expectations updated.
21XLF / Localization PipelineXLF files correctly updated with target state="new" by the build tool.

Actionable items

  1. _ifSupportedIgnoredMessageEmitted — add volatile (CrashDumpProcessLifetimeHandler.cs:44): the "emit once" guard can be bypassed under concurrent test-host restarts without a memory barrier.
  2. WarningMessageOutputDeviceData → informational format (CrashDumpProcessLifetimeHandler.cs:102/110, HangDumpProcessLifetimeHandler.cs:121): the -if-supported variants are explicitly opt-in best-effort; a yellow warning contradicts the intent and adds noise to CI logs.

Generated by Expert Code Review (on open) for issue #8666 · sonnet46 3.6M

- Use FormattedTextOutputDeviceData instead of WarningMessageOutputDeviceData
for the '-if-supported' no-op / fallback messages. These are expected,
graceful paths; rendering them as yellow warnings would mislead CI users.
(CrashDumpProcessLifetimeHandler.cs x2, HangDumpProcessLifetimeHandler.cs x1)
- Replace the plain bool one-shot guard in CrashDumpProcessLifetimeHandler
with Interlocked.Exchange on an int field, so that concurrent invocations
(e.g. test-host controller retries) cannot race past the guard. Also
restructure to early-return when the option will not emit anything on the
current runtime/OS, so the guard is only claimed when we actually emit.
- Collapse the nested 'if' in HangDumpCommandLineProvider.ValidateOptionArgumentsAsync
for --hangdump-type-if-supported into a single conditional return (also
satisfies IDE0046).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings May 28, 2026 17:12

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

Comments suppressed due to low confidence (1)

test/UnitTests/Microsoft.Testing.Extensions.UnitTests/CrashDumpTests.cs:359

  • The placeholder-to-regex conversion test no longer covers several common createdump placeholders/pattern shapes (e.g. %e, %h, %t, literal-only patterns). Those DataRow cases previously validated that placeholders are expanded to wildcards across multiple tokens and adjacent placeholders; dropping them reduces coverage for BuildDumpFileNameRegexPattern and makes regressions easier to miss.
  • Files reviewed: 37/37 changed files
  • Comments generated: 1

…ents
The earlier comment in CrashDumpEnvironmentVariableProvider above the
'crashReportEnabled' assignment said 'IsEnabledAsync gates this method,
so at least one of --crashdump / --crash-report / --crash-report-if-supported
is set here.' That wording suggested '--crash-report-if-supported' alone
is sufficient to reach UpdateAsync / ValidateTestHostEnvironmentVariablesAsync
even on Windows / .NET Framework, where the option is intentionally a
no-op (IsCrashReportEffective returns false and IsEnabledAsync is false
unless '--crashdump' is also set).
Reword both occurrences to refer to an *effective* crash-report request
so future readers do not misinterpret the precondition.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings May 29, 2026 16:45

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 37/37 changed files
  • Comments generated: 0 new

@Evangelink
Amaury Levé (Evangelink) merged commit 35f4f1e into mainMay 31, 2026
25 of 26 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/crash-report-if-supported branch May 31, 2026 06:41
Amaury Levé (Evangelink) added a commit that referenced this pull request May 31, 2026
…om PR #8666 (#8716)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for freeto 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.

Add option to collect gcdump (MTPv2)

2 participants

@Evangelink