Refactor ANSI handling for better readability#52525
Merged
Youssef1313 merged 1 commit intomainfrom Jan 19, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors ANSI handling in the terminal test reporter by replacing two boolean flags (UseAnsi and UseCIAnsi) with a single, more expressive AnsiMode enum. This change improves code readability and maintainability by making the different ANSI modes explicit.
Changes:
- Introduced
AnsiModeenum with four values:NoAnsi,SimpleAnsi,AnsiIfPossible, andForceAnsi - Replaced boolean properties
UseAnsiandUseCIAnsiinTerminalTestReporterOptionswithAnsiModeproperty - Updated
TerminalTestReporterconstructor to use the new enum for clearer logic flow - Modified
MicrosoftTestingPlatformTestCommandto map command-line flags and CI detection to appropriateAnsiModevalues
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Cli/dotnet/Commands/Test/MTP/Terminal/TerminalTestReporterOptions.cs | Replaced boolean properties with AnsiMode enum; added well-documented AnsiMode enum with four values |
| src/Cli/dotnet/Commands/Test/MTP/Terminal/TerminalTestReporter.cs | Refactored constructor logic to use AnsiMode enum instead of booleans; simplified branching logic |
| src/Cli/dotnet/Commands/Test/MTP/MicrosoftTestingPlatformTestCommand.cs | Updated initialization logic to map --no-ansi flag and CI detection to AnsiMode values |
09aacbf to
0267f6d
Compare
mariam-abdulla
approved these changes
Jan 19, 2026
Member
Author
|
/backport to release/10.0.2xx |
Contributor
|
Started backporting to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sync with microsoft/testfx#7245