Skip to content

Fix Should optional overload generation#5820

Merged
thomhurst merged 1 commit intomainfrom
fix/should-generate-optional-overloads
May 2, 2026
Merged

Fix Should optional overload generation#5820
thomhurst merged 1 commit intomainfrom
fix/should-generate-optional-overloads

Conversation

@thomhurst
Copy link
Copy Markdown
Owner

Summary

  • Allow the Should source generator to wrap overloads whose assertion constructors have safe trailing optional defaults.
  • Add regression coverage for Should().Throw<T>().WithMessage("...") without StringComparison.
  • Update Should public API snapshots for the newly generated overloads.

Verification

  • TUnit.Assertions.Should.SourceGenerator.Tests regression on net8.0, net9.0, net10.0
  • TUnit.Assertions.Should.Tests regression on net8.0, net9.0, net10.0
  • TUnit.PublicAPI Should snapshot on net8.0, net9.0, net10.0 with TUNIT_OTEL_RECEIVER=0
  • git diff --check

Closes #5818

@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 5 complexity

Metric Results
Complexity 5

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@thomhurst thomhurst enabled auto-merge (squash) May 2, 2026 20:49
@thomhurst thomhurst merged commit 246d59f into main May 2, 2026
12 of 13 checks passed
@thomhurst thomhurst deleted the fix/should-generate-optional-overloads branch May 2, 2026 21:18
This was referenced May 2, 2026
github-actions Bot pushed a commit to IntelliTect/CodingGuidelines that referenced this pull request May 4, 2026
Updated [TUnit.Core](https://github.com/thomhurst/TUnit) from 1.40.10 to
1.43.11.

<details>
<summary>Release notes</summary>

_Sourced from [TUnit.Core's
releases](https://github.com/thomhurst/TUnit/releases)._

## 1.43.11

<!-- Release notes generated using configuration in .github/release.yml
at v1.43.11 -->

## What's Changed
### Other Changes
* perf(engine): skip execution ledger for independent tests by
@​thomhurst in thomhurst/TUnit#5813
* perf(engine): skip tracked object graph rediscovery by @​thomhurst in
thomhurst/TUnit#5814
* fix: suppress XML doc warnings in generated sources by @​mvanhorn in
thomhurst/TUnit#5797
* Fix xUnit Throws migration docs by @​thomhurst in
thomhurst/TUnit#5819
* Fix Should optional overload generation by @​thomhurst in
thomhurst/TUnit#5820
### Dependencies
* chore(deps): update dependency mockolate to 3.1.0 by @​thomhurst in
thomhurst/TUnit#5811
* chore(deps): update tunit to 1.43.2 by @​thomhurst in
thomhurst/TUnit#5809
* chore(deps): update dependency nunit.analyzers to 4.13.0 by
@​thomhurst in thomhurst/TUnit#5815
* chore(deps): update dependency yaml to v2.8.4 by @​thomhurst in
thomhurst/TUnit#5812

## New Contributors
* @​mvanhorn made their first contribution in
thomhurst/TUnit#5797

**Full Changelog**:
thomhurst/TUnit@v1.43.2...v1.43.11

## 1.43.2

<!-- Release notes generated using configuration in .github/release.yml
at v1.43.2 -->

## What's Changed
### Other Changes
* fix(assertions): emit auto-generated header in
MethodAssertionGenerator output by @​JohnVerheij in
thomhurst/TUnit#5796
* fix(engine): enforce runtime exclusion for global [NotInParallel]
(#​5800) by @​thomhurst in thomhurst/TUnit#5805
* feat(mocks): add Arg.AnyArgs() shortcut for setup/verify by
@​thomhurst in thomhurst/TUnit#5792
* fix(should): add specialized assertion sources by @​thomhurst in
thomhurst/TUnit#5806
### Dependencies
* chore(deps): update tunit to 1.41.0 by @​thomhurst in
thomhurst/TUnit#5789
* chore(deps): update microsoft.testing to 2.2.2 by @​thomhurst in
thomhurst/TUnit#5793
* chore(deps): update mstest to 4.2.2 by @​thomhurst in
thomhurst/TUnit#5794
* chore(deps): update docusaurus by @​thomhurst in
thomhurst/TUnit#5798
* chore(deps): update dependency dompurify to v3.4.2 by @​thomhurst in
thomhurst/TUnit#5799
* chore(deps): update dependency mockolate to v3 by @​thomhurst in
thomhurst/TUnit#5801


**Full Changelog**:
thomhurst/TUnit@v1.41.0...v1.43.2

## 1.41.0

<!-- Release notes generated using configuration in .github/release.yml
at v1.41.0 -->

## TUnit Should() Assertions (beta)
This versions comes with a beta version of TUnit.Assertions.Should -
meaning that you can do:
`myCode.Should().BeEqualTo(fluentShouldSyntax);`

For more information see the docs:
https://tunit.dev/docs/assertions/should-syntax

## What's Changed
### Other Changes
* fix(reporters): unwrap TestFailedException for failure grouping by
@​thomhurst in thomhurst/TUnit#5776
* Fix item-at Satisfies source typing by @​thomhurst in
thomhurst/TUnit#5764
* ci(docs): add link-check automation and tighten Docusaurus strictness
by @​thomhurst in thomhurst/TUnit#5779
* feat: add TUnit.Assertions.Should package by @​thomhurst in
thomhurst/TUnit#5785
### Dependencies
* chore(deps): update tunit to 1.40.10 by @​thomhurst in
thomhurst/TUnit#5775
* chore(deps): update actions/cache action to v5 by @​thomhurst in
thomhurst/TUnit#5780
* chore(deps): update dependency microsoft.net.test.sdk to 18.5.1 by
@​thomhurst in thomhurst/TUnit#5784


**Full Changelog**:
thomhurst/TUnit@v1.40.10...v1.41.0

Commits viewable in [compare
view](thomhurst/TUnit@v1.40.10...v1.43.11).
</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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.

[Bug]: TUnit.Assertions.Should requires a StringComparison for Throws().WithMessage

1 participant