Fix startup scenario test failures on .NET 11 Preview 2#5119
Fix startup scenario test failures on .NET 11 Preview 2#5119LoopedBard3 wants to merge 2 commits intodotnet:mainfrom
Conversation
LoopedBard3
commented
Feb 13, 2026
- Update console template pre.py scripts to search for "Console.WriteLine" instead of the removed "// See https://aka.ms/new-console-template" comment
- Make insert_after() raise an exception when the search string is not found instead of silently succeeding
- Handle empty parser results in Reporter.WriteResultTable() to prevent InvalidOperationException on .Max() of empty sequence
- Add diagnostic logging and fail with exit code -1 when parser returns no results in Startup.cs
- Update console template pre.py scripts to search for "Console.WriteLine" instead of the removed "// See https://aka.ms/new-console-template" comment - Make insert_after() raise an exception when the search string is not found instead of silently succeeding - Handle empty parser results in Reporter.WriteResultTable() to prevent InvalidOperationException on .Max() of empty sequence - Add diagnostic logging and fail with exit code -1 when parser returns no results in Startup.cs
WPF Template and WPF SFC fail with CloseFailed on generic Helix CI VMs because CloseMainWindow() doesn't work in headless environments. This is the same issue that caused WinForms scenarios to be gated. Gate both WPF scenarios behind SYSTEM_TEAMPROJECT=internal, with IncludeVMFlakyScenarios override.
There was a problem hiding this comment.
Pull request overview
This PR fixes startup scenario test failures on .NET 11 Preview 2 by adapting to template changes and improving error handling. The .NET 11 Preview 2 console template removed the // See https://aka.ms/new-console-template comment that was previously used to locate where to insert logging calls. The PR updates template scripts to use a more stable search string and adds defensive error handling throughout the stack.
Changes:
- Updated console template pre.py scripts to search for "Console.WriteLine" instead of the removed template comment
- Made insert_after() fail fast with an exception when the search string is not found
- Added empty results handling in Reporter.WriteResultTable() and Startup.cs to prevent crashes and provide diagnostic information
- Restricted WPF scenarios to internal builds (matching WinForms pattern)
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/scenarios/emptyconsoletemplate/pre.py | Updated search string for add_onmain_logging to use "Console.WriteLine" |
| src/scenarios/emptyconsolenativeaot/pre.py | Updated search string for add_onmain_logging to use "Console.WriteLine" |
| src/scenarios/shared/codefixes.py | Added exception when insert_after() search string not found |
| src/tools/Reporting/Reporting/Reporter.cs | Added handling for empty parser results to prevent InvalidOperationException |
| src/tools/ScenarioMeasurement/Startup/Startup.cs | Added diagnostic logging and failure handling for empty parser results |
| eng/performance/scenarios.proj | Restricted WPF scenarios to internal builds or when IncludeVMFlakyScenarios=true |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (!test.Counters.Any() || test.Counters.All(c => c.Results == null || c.Results.Count == 0)) | ||
| { | ||
| ret.AppendLine(test.Name); | ||
| ret.AppendLine("No results captured. The trace may not contain the expected events."); | ||
| continue; | ||
| } |
There was a problem hiding this comment.
The new behavior to handle empty parser results is not covered by tests. Given that ReporterTests.cs contains comprehensive test coverage for other scenarios, a test case should be added to verify that WriteResultTable() correctly handles tests with no results or with all counters having null/empty results. This would ensure the fix prevents the InvalidOperationException and produces the expected "No results captured" message.
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |