Skip to content

Apply structured assertion messages (RFC 012) to Assert.StartsWith / EndsWith#8258

Merged
Evangelink merged 2 commits into
mainfrom
dev/amauryleve/assert-startswith-endswith-rfc012
May 16, 2026
Merged

Apply structured assertion messages (RFC 012) to Assert.StartsWith / EndsWith#8258
Evangelink merged 2 commits into
mainfrom
dev/amauryleve/assert-startswith-endswith-rfc012

Conversation

@Evangelink
Copy link
Copy Markdown
Member

Continues the rollout of RFC 012 — Structured Assertion Messages by migrating Assert.StartsWith / Assert.DoesNotStartWith / Assert.EndsWith / Assert.DoesNotEndWith to the structured-message format. Follows the patterns used by previously migrated assertions (#8170, #8187, #8210, #8214).

Output format

Assert.StartsWith(""world"", ""hello world""):

Assertion failed. Expected string to start with the specified prefix.

expected prefix: ""world""
actual:          ""hello world""
comparison:      Ordinal

Assert.StartsWith(""world"", ""hello world"")

Assert.DoesNotEndWith(""world"", ""hello world"", StringComparison.OrdinalIgnoreCase, ""should not end with world""):

Assertion failed. Expected string to not end with the specified suffix.
should not end with world

unexpected suffix: ""world""
actual:            ""hello world""
comparison:        OrdinalIgnoreCase

Assert.DoesNotEndWith(""world"", ""hello world"")

Notes

  • Adds StartsWithFailedSummary / DoesNotStartWithFailedSummary / EndsWithFailedSummary / DoesNotEndWithFailedSummary resource entries (XLF files regenerated via UpdateXlf).
  • Removes the now-unused BuildUserMessageFor*PrefixExpression* / *SuffixExpression* helpers from Assert.cs since the call-site is now reconstructed by FormatCallSiteExpression.
  • StringAssert.StartsWith / StringAssert.EndsWith are intentionally unchanged and continue to use FrameworkMessages.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

…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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 StructuredAssertionMessage evidence 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

Comment thread src/TestFramework/TestFramework/Assertions/Assert.StartsWith.cs
Comment thread src/TestFramework/TestFramework/Assertions/Assert.EndsWith.cs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink Evangelink merged commit 648e44a into main May 16, 2026
43 checks passed
@Evangelink Evangelink deleted the dev/amauryleve/assert-startswith-endswith-rfc012 branch May 16, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants