Sitelet https://github.com/fluentassertions/fluentassertions/pull/3293
Skip to content

Add BeJsonSerializable round-trip assertions - #3293

Merged
dennisdoomen merged 1 commit into
mainfrom
dennisdoomen-add-json-roundtrip-assertion
Aug 10, 2026
Merged

dennisdoomen merged 1 commit into
mainfrom
dennisdoomen-add-json-roundtrip-assertion

Conversation

@dennisdoomen

@dennisdoomen dennisdoomen commented Aug 7, 2026 •

Copy link
Copy Markdown
Member

Adds first-class round-trip assertions for System.Text.Json, which is the serializer many users rely on today and which was missing alongside the existing XML and data contract helpers.

The implementation adds BeJsonSerializable() / BeJsonSerializable<T>() overloads, supports custom equivalency configuration, and accepts JsonSerializerOptions so callers can use custom converters and other serializer settings. The comparison follows System.Text.Json semantics by checking properties by default and excluding [JsonIgnore] members from the round-trip equivalency check.

The JSON assertion is only compiled on NET6_0_OR_GREATER, matching the existing JSON equivalency API surface.

The specs cover successful round-tripping, serializer failures, ignored members, custom converter scenarios, and null option guards. The unreleased notes and serialization docs were updated to document the new assertion and ignored-member behavior.

Closes #3264

IMPORTANT

  • If the PR touches the public API, the changes have been approved in a separate issue with the "api-approved" label.
  • The code complies with the Coding Guidelines for C#.
  • The changes are covered by unit tests which follow the Arrange-Act-Assert syntax and the naming conventions such as is used in these tests.
  • If the PR adds a feature or fixes a bug, please update the release notes with a functional description that explains what the change means to consumers of this library, which are published on the website.
  • If the PR changes the public API the changes needs to be included by running AcceptApiChanges.ps1 or AcceptApiChanges.sh.
  • If the PR affects the documentation, please include your changes in this pull request so the documentation will appear on the website.
    • Please also run ./build.sh --target spellcheck or .\build.ps1 --target spellcheck before pushing and check the good outcome

CONTRIBUTOR LICENSE GRANT

By submitting this contribution, the contributor hereby irrevocably grants to the project owners and maintainers a perpetual, worldwide, royalty-free, irrevocable license to use, reproduce, modify, distribute, sublicense, and create derivative works of the contribution for any purpose and under any terms, including proprietary licensing.

The contributor waives any moral rights in the contribution to the extent permitted by law and agrees not to assert any claim of authorship or control over the contribution. The contributor represents that they are the sole author of the contribution and that it is provided free of any third-party claims.

The contributor understands and agrees that the maintainers may, at their sole discretion, use, license, or redistribute the contribution as part of any work and under any terms they choose, without further permission or attribution.

  • I have read the Contributor License Grant and accept the conditions
  • I'm interested in a free license for Fluent Assertions and will share my email address through sales@xceed.com

Comment thread Src/FluentAssertions/ObjectAssertionsExtensions.cs Fixed
@github-actions

github-actions Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

Test Results

    37 files  ± 0      37 suites  ±0   2m 45s ⏱️ -14s
 6 433 tests +10   6 431 ✅ + 9  1 💤 ±0  1 ❌ +1 
39 944 runs  +60  39 937 ✅ +59  6 💤 ±0  1 ❌ +1 

For more details on these failures, see this check.

Results for commit d7c33e2. ± Comparison against base commit f4026e7.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

Qodana for .NET

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

@dennisdoomen
dennisdoomen force-pushed the dennisdoomen-add-json-roundtrip-assertion branch from 6d5b095 to ef80ed3 Compare August 7, 2026 20:02
@dennisdoomen dennisdoomen added this to the 8.11 milestone Aug 7, 2026
@dennisdoomen
dennisdoomen force-pushed the dennisdoomen-add-json-roundtrip-assertion branch from 23bcbf5 to 0d96f00 Compare August 8, 2026 17:02
@dennisdoomen
dennisdoomen force-pushed the dennisdoomen-add-json-roundtrip-assertion branch from 0d96f00 to 8a3ce20 Compare August 8, 2026 17:02
@dennisdoomen
dennisdoomen force-pushed the dennisdoomen-add-json-roundtrip-assertion branch from 8a3ce20 to 7a191a1 Compare August 8, 2026 17:08
@dennisdoomen
dennisdoomen force-pushed the dennisdoomen-add-json-roundtrip-assertion branch from 7a191a1 to b4dd21a Compare August 8, 2026 17:19
@dennisdoomen
dennisdoomen force-pushed the dennisdoomen-add-json-roundtrip-assertion branch from b4dd21a to 5295137 Compare August 8, 2026 17:28
@dennisdoomen
dennisdoomen force-pushed the dennisdoomen-add-json-roundtrip-assertion branch from 5295137 to 90d3f0e Compare August 8, 2026 20:12
@dennisdoomen
dennisdoomen force-pushed the dennisdoomen-add-json-roundtrip-assertion branch from 90d3f0e to c935db7 Compare August 8, 2026 20:15
@dennisdoomen
dennisdoomen force-pushed the dennisdoomen-add-json-roundtrip-assertion branch from c935db7 to 9029670 Compare August 8, 2026 20:15
@dennisdoomen
dennisdoomen marked this pull request as ready for review August 8, 2026 20:17
@dennisdoomen
dennisdoomen requested a review from jnyrup August 8, 2026 20:18
Comment thread docs/_pages/releases.md Outdated
Comment thread Src/FluentAssertions/ObjectAssertionsExtensions.cs Outdated
Comment thread Src/FluentAssertions/ObjectAssertionsExtensions.cs Outdated
@dennisdoomen
dennisdoomen force-pushed the dennisdoomen-add-json-roundtrip-assertion branch from 9029670 to 2f797d5 Compare August 9, 2026 05:48
This was referenced Oct 2, 2026

This branch was previously deployed

1 inactive deployment
qodana-pr — d7c33e2d Deployed Aug 10, 2026 by dennisdoomen via Qodana Scan #70
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add BeJsonSerializable<T>() round-trip assertion

2 participants