Skip to content

feat: show a line diff for multi-line strings with several differences - #1832

Merged
vbreuss merged 2 commits into
mainfrom
feat/multiline-string-diff
Oct 15, 2026
Merged

vbreuss merged 2 commits into
mainfrom
feat/multiline-string-diff

Conversation

@vbreuss

@vbreuss vbreuss commented Oct 15, 2026

Copy link
Copy Markdown
Member

When multi-line strings compared with IsEqualTo differ in at least two places, the failure message gets a Differences context before Actual: and Expected: that lists each changed line with its line numbers in the actual and the expected value and one line of context, limited to MaximumNumberOfCollectionItems differences.

Lines are compared with the string options, so lines that only differ in what the options ignore are not listed. Pattern, prefix and suffix match types and negated expectations are unchanged.

When multi-line strings compared with `IsEqualTo` differ in at least two places, the failure message gets a `Differences` context before `Actual:` and `Expected:` that lists each changed line with its line numbers in the actual and the expected value and one line of context, limited to `MaximumNumberOfCollectionItems` differences.

Lines are compared with the string options, so lines that only differ in what the options ignore are not listed. Pattern, prefix and suffix match types and negated expectations are unchanged.
@vbreuss vbreuss self-assigned this Oct 15, 2026
…or custom comparers

Lines that only differed in their line break, trailing spaces or tabs looked identical in the `Differences` context, and a custom comparer that defines equality for whole values could produce a diff that contradicts it.
@vbreuss
vbreuss force-pushed the feat/multiline-string-diff branch from 91e1b56 to 660f6b0 Compare October 15, 2026 16:46
@vbreuss
vbreuss merged commit 3db1184 into main Oct 15, 2026
12 checks passed
@vbreuss
vbreuss deleted the feat/multiline-string-diff branch October 15, 2026 16:47
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

This is addressed in release v3.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant