Apply structured assertion messages (RFC 012) to Assert.StartsWith / EndsWith#8258
Merged
Evangelink merged 2 commits intoMay 16, 2026
Merged
Conversation
…EndsWith Migrates Assert.StartsWith / DoesNotStartWith / EndsWith / DoesNotEndWith to the structured assertion message format defined in RFC 012, following the patterns used by IsTrue/IsFalse, IsNull/IsNotNull, AreSame, and IsInstanceOfType. Each evidence block carries the expected/unexpected prefix or suffix, the actual string, and the StringComparison used so non-default comparisons (e.g. OrdinalIgnoreCase) are visible at a glance. Removes the now-unused BuildUserMessageFor*PrefixExpression* / *SuffixExpression* helpers from Assert.cs since the call-site is now reconstructed via FormatCallSiteExpression. StringAssert.StartsWith / EndsWith are unaffected and continue to use FrameworkMessages.StartsWithFail / EndsWithFail. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Migrates Assert.StartsWith / DoesNotStartWith and Assert.EndsWith / DoesNotEndWith failure messages to the RFC 012 structured assertion format, including new resource summaries and regenerated localization XLF entries.
Changes:
- Replaces legacy formatted failure messages with
StructuredAssertionMessageevidence blocks, expected/actual metadata, and call-site expressions. - Adds new summary resources for starts-with/ends-with assertions.
- Updates localized XLF files with the new resource IDs.
Show a summary per file
| File | Description |
|---|---|
src/TestFramework/TestFramework/Assertions/Assert.StartsWith.cs |
Adds structured failure reporting for start-prefix assertions. |
src/TestFramework/TestFramework/Assertions/Assert.EndsWith.cs |
Adds structured failure reporting for end-suffix assertions. |
src/TestFramework/TestFramework/Assertions/Assert.cs |
Removes now-unused prefix/suffix caller-expression user-message helpers. |
src/TestFramework/TestFramework/Resources/FrameworkMessages.resx |
Adds new structured assertion summary resources. |
src/TestFramework/TestFramework/Resources/xlf/FrameworkMessages.cs.xlf |
Adds localized resource placeholders for new summaries. |
src/TestFramework/TestFramework/Resources/xlf/FrameworkMessages.de.xlf |
Adds localized resource placeholders for new summaries. |
src/TestFramework/TestFramework/Resources/xlf/FrameworkMessages.es.xlf |
Adds localized resource placeholders for new summaries. |
src/TestFramework/TestFramework/Resources/xlf/FrameworkMessages.fr.xlf |
Adds localized resource placeholders for new summaries. |
src/TestFramework/TestFramework/Resources/xlf/FrameworkMessages.it.xlf |
Adds localized resource placeholders for new summaries. |
src/TestFramework/TestFramework/Resources/xlf/FrameworkMessages.ja.xlf |
Adds localized resource placeholders for new summaries. |
src/TestFramework/TestFramework/Resources/xlf/FrameworkMessages.ko.xlf |
Adds localized resource placeholders for new summaries. |
src/TestFramework/TestFramework/Resources/xlf/FrameworkMessages.pl.xlf |
Adds localized resource placeholders for new summaries. |
src/TestFramework/TestFramework/Resources/xlf/FrameworkMessages.pt-BR.xlf |
Adds localized resource placeholders for new summaries. |
src/TestFramework/TestFramework/Resources/xlf/FrameworkMessages.ru.xlf |
Adds localized resource placeholders for new summaries. |
src/TestFramework/TestFramework/Resources/xlf/FrameworkMessages.tr.xlf |
Adds localized resource placeholders for new summaries. |
src/TestFramework/TestFramework/Resources/xlf/FrameworkMessages.zh-Hans.xlf |
Adds localized resource placeholders for new summaries. |
src/TestFramework/TestFramework/Resources/xlf/FrameworkMessages.zh-Hant.xlf |
Adds localized resource placeholders for new summaries. |
Copilot's findings
- Files reviewed: 17/17 changed files
- Comments generated: 2
This was referenced May 15, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Continues the rollout of RFC 012 — Structured Assertion Messages by migrating
Assert.StartsWith/Assert.DoesNotStartWith/Assert.EndsWith/Assert.DoesNotEndWithto the structured-message format. Follows the patterns used by previously migrated assertions (#8170, #8187, #8210, #8214).Output format
Assert.StartsWith(""world"", ""hello world""):Assert.DoesNotEndWith(""world"", ""hello world"", StringComparison.OrdinalIgnoreCase, ""should not end with world""):Notes
StartsWithFailedSummary/DoesNotStartWithFailedSummary/EndsWithFailedSummary/DoesNotEndWithFailedSummaryresource entries (XLF files regenerated viaUpdateXlf).BuildUserMessageFor*PrefixExpression*/*SuffixExpression*helpers fromAssert.cssince the call-site is now reconstructed byFormatCallSiteExpression.StringAssert.StartsWith/StringAssert.EndsWithare intentionally unchanged and continue to useFrameworkMessages.StartsWithFail/EndsWithFail.Validation
dotnet build src/TestFramework/TestFramework/TestFramework.csproj -c Debug— clean.dotnet test test/UnitTests/TestFramework.UnitTests/TestFramework.UnitTests.csproj -c Debug— 3535/3535 passed.Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com