Restore bounded string difference indicators#10145
Conversation
Add grapheme-safe contextual previews, caret and inline mismatch markers, and Unicode code-point diagnostics while preserving full structured assertion values. Amend RFC 012 and cover short, long, escaped, culture-aware, and Unicode comparisons. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ba230828-c09c-4eb1-a388-1cf5d2f2e2b6
There was a problem hiding this comment.
Pull request overview
Restores visual string-difference diagnostics for Assert.AreEqual.
Changes:
- Adds bounded previews, carets, inline markers, and Unicode diagnostics.
- Preserves full structured expected/actual values.
- Expands tests and RFC documentation.
Show a summary per file
| File | Description |
|---|---|
Assert.StringDifference.cs |
Implements difference rendering. |
Assert.AreEqual.String.cs |
Integrates diagnostics into string overloads. |
Assert.AreEqual.cs |
Integrates diagnostics into generic equality. |
AssertTests.AreEqualTests.cs |
Adds focused diagnostic tests. |
012-Structured-Assertion-Messages.md |
Documents the rendering contract. |
Review details
Comments suppressed due to low confidence (1)
src/TestFramework/TestFramework/Assertions/Assert.StringDifference.cs:104
HasFormattersis global to the async flow, not specific to strings. Registering an unrelated formatter such asAddValueFormatter<DateTime>therefore changes a built-in string failure from the caret form to inline fragments, even though unrelated types are required to fall through unchanged (AssertTests.AddValueFormatter.cs:72-79). Base this decision on whether these string values were actually custom-rendered rather than on the presence of any formatter.
bool useCaret =
!AssertionValueFormatterRegistry.HasFormatters
&& !expectedWindow.MismatchRequiresPlaceholder
- Files reviewed: 5/5 changed files
- Comments generated: 4
- Review effort level: Medium
This comment has been minimized.
This comment has been minimized.
Honor custom string formatters without leaking raw values, keep unrelated formatters from changing diagnostics, correct RFC examples and source encoding, and strengthen string-difference tests with exact full-message assertions. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ba230828-c09c-4eb1-a388-1cf5d2f2e2b6
This comment has been minimized.
This comment has been minimized.
Compare rendered strings against the built-in escaped representation without allocating another full copy, document oversized text-element placeholders, and cover escape matching plus zero-allocation behavior. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ba230828-c09c-4eb1-a388-1cf5d2f2e2b6
Lock the bounded [[<text element>]] fallback and code-point summary with an exact full-message regression test. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ba230828-c09c-4eb1-a388-1cf5d2f2e2b6
Head branch was modified
🧪 Test quality grade — PR #10145
This advisory comment was generated automatically. Grades are heuristic Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
|
/backport to rel/4.3 |
|
Started backporting to rel/4.3: https://github.com/microsoft/testfx/actions/runs/30012155771 |
|
@Evangelink backporting to rel/4.3 failed, the patch most likely resulted in conflicts: $ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Patch format detection failed.
Error: The process '/usr/bin/git' failed with exit code 128NOTE: A PR will be created, but needs to be revised manually! |
|
@Evangelink backporting to rel/4.3 failed, the patch most likely resulted in conflicts: $ git am --continue
fatal: Resolve operation not in progress, we are not resuming.
Error: The process '/usr/bin/git' failed with exit code 128NOTE: A PR will be created, but needs to be revised manually! |
1 similar comment
|
@Evangelink backporting to rel/4.3 failed, the patch most likely resulted in conflicts: $ git am --continue
fatal: Resolve operation not in progress, we are not resuming.
Error: The process '/usr/bin/git' failed with exit code 128NOTE: A PR will be created, but needs to be revised manually! |
|
@Evangelink backporting to rel/4.3 failed, the patch most likely resulted in conflicts: $ git am --continue
fatal: Resolve operation not in progress, we are not resuming.
Error: The process '/usr/bin/git' failed with exit code 128NOTE: A PR will be created, but needs to be revised manually! |
15 similar comments
|
@Evangelink backporting to rel/4.3 failed, the patch most likely resulted in conflicts: $ git am --continue
fatal: Resolve operation not in progress, we are not resuming.
Error: The process '/usr/bin/git' failed with exit code 128NOTE: A PR will be created, but needs to be revised manually! |
|
@Evangelink backporting to rel/4.3 failed, the patch most likely resulted in conflicts: $ git am --continue
fatal: Resolve operation not in progress, we are not resuming.
Error: The process '/usr/bin/git' failed with exit code 128NOTE: A PR will be created, but needs to be revised manually! |
|
@Evangelink backporting to rel/4.3 failed, the patch most likely resulted in conflicts: $ git am --continue
fatal: Resolve operation not in progress, we are not resuming.
Error: The process '/usr/bin/git' failed with exit code 128NOTE: A PR will be created, but needs to be revised manually! |
|
@Evangelink backporting to rel/4.3 failed, the patch most likely resulted in conflicts: $ git am --continue
fatal: Resolve operation not in progress, we are not resuming.
Error: The process '/usr/bin/git' failed with exit code 128NOTE: A PR will be created, but needs to be revised manually! |
|
@Evangelink backporting to rel/4.3 failed, the patch most likely resulted in conflicts: $ git am --continue
fatal: Resolve operation not in progress, we are not resuming.
Error: The process '/usr/bin/git' failed with exit code 128NOTE: A PR will be created, but needs to be revised manually! |
|
@Evangelink backporting to rel/4.3 failed, the patch most likely resulted in conflicts: $ git am --continue
fatal: Resolve operation not in progress, we are not resuming.
Error: The process '/usr/bin/git' failed with exit code 128NOTE: A PR will be created, but needs to be revised manually! |
|
@Evangelink backporting to rel/4.3 failed, the patch most likely resulted in conflicts: $ git am --continue
fatal: Resolve operation not in progress, we are not resuming.
Error: The process '/usr/bin/git' failed with exit code 128NOTE: A PR will be created, but needs to be revised manually! |
|
@Evangelink backporting to rel/4.3 failed, the patch most likely resulted in conflicts: $ git am --continue
fatal: Resolve operation not in progress, we are not resuming.
Error: The process '/usr/bin/git' failed with exit code 128NOTE: A PR will be created, but needs to be revised manually! |
|
@Evangelink backporting to rel/4.3 failed, the patch most likely resulted in conflicts: $ git am --continue
fatal: Resolve operation not in progress, we are not resuming.
Error: The process '/usr/bin/git' failed with exit code 128NOTE: A PR will be created, but needs to be revised manually! |
|
@Evangelink backporting to rel/4.3 failed, the patch most likely resulted in conflicts: $ git am --continue
fatal: Resolve operation not in progress, we are not resuming.
Error: The process '/usr/bin/git' failed with exit code 128NOTE: A PR will be created, but needs to be revised manually! |
|
@Evangelink backporting to rel/4.3 failed, the patch most likely resulted in conflicts: $ git am --continue
fatal: Resolve operation not in progress, we are not resuming.
Error: The process '/usr/bin/git' failed with exit code 128NOTE: A PR will be created, but needs to be revised manually! |
|
@Evangelink backporting to rel/4.3 failed, the patch most likely resulted in conflicts: $ git am --continue
fatal: Resolve operation not in progress, we are not resuming.
Error: The process '/usr/bin/git' failed with exit code 128NOTE: A PR will be created, but needs to be revised manually! |
|
@Evangelink backporting to rel/4.3 failed, the patch most likely resulted in conflicts: $ git am --continue
fatal: Resolve operation not in progress, we are not resuming.
Error: The process '/usr/bin/git' failed with exit code 128NOTE: A PR will be created, but needs to be revised manually! |
|
@Evangelink backporting to rel/4.3 failed, the patch most likely resulted in conflicts: $ git am --continue
fatal: Resolve operation not in progress, we are not resuming.
Error: The process '/usr/bin/git' failed with exit code 128NOTE: A PR will be created, but needs to be revised manually! |
|
@Evangelink backporting to rel/4.3 failed, the patch most likely resulted in conflicts: $ git am --continue
fatal: Resolve operation not in progress, we are not resuming.
Error: The process '/usr/bin/git' failed with exit code 128NOTE: A PR will be created, but needs to be revised manually! |
|
Potential infinite loop guard hit. Stopping |
…(backport to rel/4.3) (#10172) Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Summary
Assert.AreEqualstring failuresexpected near:/actual near:previews for long strings while retaining full expected and actual values[[...]]markers otherwiseExpectedText,ActualText, exception data, and MTP protocol fieldsExamples
Short strings use the full values directly:
Long strings receive bounded context before the unchanged full evidence:
When a Unicode or grapheme prefix makes display-column alignment unreliable, the complete mismatching text elements are marked inline:
Non-ASCII differences also include code-point diagnostics:
Servicing assessment
This fixes the loss of the visual string-difference locator during the RFC 012 migration in MSTest 4.3. It changes no public API or passing-test behavior, preserves the existing structured expected/actual fields, and only adds diagnostics when an assertion has already failed. The affected files on
rel/4.3are identical to this PR's base, so the commits are suitable for a clean backport to the 4.3 servicing branch after validation onmain.Validation
Fixes #10045