feat: trim common white-space from subject#739
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new feature to automatically trim common whitespace from assertion subjects in error messages, improving readability when dealing with multi-line formatted code. The primary change adds a TrimCommonWhiteSpace extension method and applies it to the ExpectationBuilder subject processing.
- Adds a new
TrimCommonWhiteSpacestring extension method that identifies and removes common leading whitespace from multi-line strings - Integrates the whitespace trimming into the
ExpectationBuilderto automatically clean up subject expressions - Temporarily sets build scope to
CoreOnlyfor development/testing purposes
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Source/aweXpect.Core/Core/Helpers/StringExtensions.cs | Implements the TrimCommonWhiteSpace method with logic to find and remove common leading whitespace from multi-line strings |
| Source/aweXpect.Core/Core/ExpectationBuilder.cs | Applies whitespace trimming to subject expressions in the constructor |
| Tests/aweXpect.Core.Tests/Core/Helpers/StringExtensionsTests.cs | Restructures existing tests into nested classes and adds comprehensive test coverage for the new TrimCommonWhiteSpace method |
| Tests/aweXpect.Core.Tests/Core/ExpectationBuilderTests.cs | Adds integration test verifying that multi-line subjects have their whitespace properly trimmed in error messages |
| Pipeline/Build.cs | Temporarily changes build scope to CoreOnly (likely for development/testing) |
|
Contributor
|
This is addressed in release v2.22.0. |
This was referenced Sep 8, 2025
This was referenced Sep 15, 2025
This was referenced Sep 29, 2025
This was referenced Mar 30, 2026
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.



This PR introduces a new feature to automatically trim common whitespace from assertion subjects in error messages, improving readability when dealing with multi-line formatted code. The primary change adds a
TrimCommonWhiteSpaceextension method and applies it to theExpectationBuildersubject processing.Key changes
TrimCommonWhiteSpacestring extension method that identifies and removes common leading whitespace from multi-line stringsExpectationBuilderto automatically clean up subject expressionsCoreOnlyfor development/testing purposes