Skip to content

Cleanup terminal reporter exception flattening by removing FlatException DTO#8212

Closed
Copilot wants to merge 2 commits into
mainfrom
copilot/cleanup-terminal-test-reporter
Closed

Cleanup terminal reporter exception flattening by removing FlatException DTO#8212
Copilot wants to merge 2 commits into
mainfrom
copilot/cleanup-terminal-test-reporter

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 14, 2026

✨ Enhancement

The terminal reporter still carried a local FlatException wrapper that added indirection without adding behavior. This change simplifies exception shaping by removing that type and using a single shared value shape end-to-end.

  • What does this improve?

    • Removes the terminal-specific FlatException record from the exception flattening path.
    • Standardizes flattened exception data as named tuples (ErrorMessage, ErrorType, StackTrace) across terminal rendering and dotnet-test IPC conversion.
    • Reduces type surface area in reporter internals while preserving output semantics.
  • Why is this valuable?

    • Eliminates a redundant transport type in a hot formatting path.
    • Makes exception-flow code easier to follow by keeping the flattened payload structural and lightweight.
    • Lowers maintenance overhead when evolving error formatting/forwarding logic.
  • Implementation approach:

    • Updated ExceptionFlattener.Flatten(...) to return:
      (string? ErrorMessage, string? ErrorType, string? StackTrace)[]
    • Removed FlatException and updated all consumers:
      • Terminal test completion/rendering methods
      • Terminal formatting helpers (FormatErrorMessage, FormatStackTrace, inner exception formatting)
      • DotnetTest IPC exception mapping
      • Unit tests that assert flatten ordering/content

Example (new shape):

(string? ErrorMessage, string? ErrorType, string? StackTrace)[] exceptions =
    ExceptionFlattener.Flatten(errorMessage, exception);

Copilot AI self-assigned this May 14, 2026
Copilot AI review requested due to automatic review settings May 14, 2026 09:21
Copilot AI review requested due to automatic review settings May 14, 2026 09:21
Copilot AI linked an issue May 14, 2026 that may be closed by this pull request
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 14, 2026 09:28
Copilot AI changed the title [WIP] Cleanup terminal test reporter for optimizations Cleanup terminal reporter exception flattening by removing FlatException DTO May 14, 2026
Copilot AI requested a review from Evangelink May 14, 2026 09:29
@Evangelink Evangelink marked this pull request as ready for review May 14, 2026 09:32
Copilot AI review requested due to automatic review settings May 14, 2026 09:32
@Evangelink
Copy link
Copy Markdown
Member

It doesn't seem to be simplifying code, I'd say the opposite so closing

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 removes the terminal reporter’s FlatException DTO and standardizes flattened exception data as a named tuple array (ErrorMessage, ErrorType, StackTrace) across terminal rendering, dotnet-test IPC conversion, and the associated unit tests.

Changes:

  • Updated ExceptionFlattener.Flatten(...) to return an array of named tuples instead of FlatException[].
  • Updated terminal reporter formatting + test completion paths to consume the tuple shape directly.
  • Updated dotnet-test IPC exception mapping and unit tests to use the new flattened exception shape.
Show a summary per file
File Description
test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs Updates tests to assert against tuple-shaped flattened exceptions.
src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/IPC/DotnetTestDataConsumer.cs Adapts IPC exception mapping to consume the tuple-shaped flattening output.
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporter.TestCompletion.cs Threads tuple-shaped flattened exceptions through test completion/rendering pipeline.
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporter.Formatting.cs Updates formatting helpers to accept and read tuple-shaped flattened exception data.
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/ExceptionFlattener.cs Removes FlatException record and emits named tuples directly from Flatten(...).

Copilot's findings

  • Files reviewed: 5/5 changed files
  • Comments generated: 0

Sign up for free to 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.

Cleanup terminal test reporter

3 participants