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

Fix Qodana-flagged possible multiple enumeration and unused auto-property warnings - #3300

Merged
dennisdoomen merged 2 commits into
mainfrom
dennisdoomen-fix-qodana-failures
Aug 10, 2026
Merged

dennisdoomen merged 2 commits into
mainfrom
dennisdoomen-fix-qodana-failures

Conversation

@dennisdoomen

Copy link
Copy Markdown
Member

Summary

The Qodana workflow on main has been failing (fail threshold 0) due to 10 new problems introduced by recent PRs:

  • 4× Possible multiple enumeration in GenericCollectionAssertions.BeProperSubsetOf/BeProperSupersetOf — the expectedProperSuperset/expectedProperSubset parameters were enumerated more than once (once inside the shared AssertSubsetOf/AssertContainment helper, again via ConvertOrCastToSet(), and again when passed to FailWith).
  • 6× Auto-property accessor is never used in the new ObjectAssertionSpecs.BeJsonSerializable.cs test helper DTOs, whose properties are only ever set (never read) but are required for JSON round-trip testing.

Changes

  • BeProperSubsetOf/BeProperSupersetOf now materialize the expected collection once into an ICollection<T> and derive any ISet<T> needed for comparisons from that materialized collection, instead of re-enumerating the original IEnumerable<T> parameter multiple times. Error messages and null-argument guard messages are unchanged.
  • Added [UsedImplicitly] (already used elsewhere in this file) to the test DTO properties flagged as unused, since they're populated via JSON serialization/object initializers rather than read directly.

Verification

  • dotnet build succeeds with 0 warnings/errors.
  • dotnet test for the Collections and BeJsonSerializable specs: all pass (928/928 on net6.0/net8.0, 906/906 on net47).
  • No public API or behavioral changes; no AcceptApiChanges run needed.

…uto-property accessors

- BeProperSubsetOf/BeProperSupersetOf now materialize the expected
  collection once instead of enumerating it multiple times.
- Mark test-only DTO properties with [UsedImplicitly] to suppress
  false-positive unused-accessor warnings.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

Test Results

    37 files  ±0      37 suites  ±0   2m 48s ⏱️ -6s
 6 434 tests ±0   6 433 ✅ +1  1 💤 ±0  0 ❌  - 1 
39 950 runs  ±0  39 944 ✅ +1  6 💤 ±0  0 ❌  - 1 

Results for commit d47f7dc. ± Comparison against base commit 7c5f77a.

This pull request removes 10 and adds 8 tests. Note that renamed tests count towards both.
FluentAssertions.Specs.Streams.StreamAssertionSpecs+HaveLength ‑ When_a_throwing_stream_should_have_a_length_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object.
FluentAssertions.Specs.Streams.StreamAssertionSpecs+HaveLength ‑ When_a_throwing_stream_should_have_a_length_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object.
FluentAssertions.Specs.Streams.StreamAssertionSpecs+HavePosition ‑ When_a_throwing_stream_should_have_a_position_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object.
FluentAssertions.Specs.Streams.StreamAssertionSpecs+HavePosition ‑ When_a_throwing_stream_should_have_a_position_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object.
FluentAssertions.Specs.Streams.StreamAssertionSpecs+NotHaveLength ‑ When_a_throwing_stream_should_not_have_a_length_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object.
FluentAssertions.Specs.Streams.StreamAssertionSpecs+NotHaveLength ‑ When_a_throwing_stream_should_not_have_a_length_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object.
FluentAssertions.Specs.Streams.StreamAssertionSpecs+NotHavePosition ‑ When_a_throwing_stream_should_not_have_a_position_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object.
FluentAssertions.Specs.Streams.StreamAssertionSpecs+NotHavePosition ‑ When_a_throwing_stream_should_not_have_a_position_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'GetLengthExceptionMessage'.)
Object name: 'GetPositionExceptionMessage'.)
FluentAssertions.Specs.Streams.StreamAssertionSpecs+HaveLength ‑ When_a_throwing_stream_should_have_a_length_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'GetLengthExceptionMessage'.)
FluentAssertions.Specs.Streams.StreamAssertionSpecs+HaveLength ‑ When_a_throwing_stream_should_have_a_length_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'GetLengthExceptionMessage'.)
FluentAssertions.Specs.Streams.StreamAssertionSpecs+HavePosition ‑ When_a_throwing_stream_should_have_a_position_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'GetPositionExceptionMessage'.)
FluentAssertions.Specs.Streams.StreamAssertionSpecs+HavePosition ‑ When_a_throwing_stream_should_have_a_position_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'GetPositionExceptionMessage'.)
FluentAssertions.Specs.Streams.StreamAssertionSpecs+NotHaveLength ‑ When_a_throwing_stream_should_not_have_a_length_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'GetLengthExceptionMessage'.)
FluentAssertions.Specs.Streams.StreamAssertionSpecs+NotHaveLength ‑ When_a_throwing_stream_should_not_have_a_length_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'GetLengthExceptionMessage'.)
FluentAssertions.Specs.Streams.StreamAssertionSpecs+NotHavePosition ‑ When_a_throwing_stream_should_not_have_a_position_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'GetPositionExceptionMessage'.)
FluentAssertions.Specs.Streams.StreamAssertionSpecs+NotHavePosition ‑ When_a_throwing_stream_should_not_have_a_position_it_should_fail(exception: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'GetPositionExceptionMessage'.)

♻️ This comment has been updated with latest results.

PR #3293 added the BeJsonSerializable extension methods but the
net6.0 approved-API baseline was never updated, causing the
Approval.Tests.ApiApproval test (and thus the Build pipeline) to
fail on main.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@coveralls

coveralls commented Aug 10, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 31398681247

Warning

No base build found for commit 7c5f77a on main.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 97.183%

Details

  • Patch coverage: 13 of 13 lines across 1 file are fully covered (100%).

Uncovered Changes

No uncovered changes found.

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 13471
Covered Lines: 13245
Line Coverage: 98.32%
Relevant Branches: 4382
Covered Branches: 4105
Branch Coverage: 93.68%
Branches in Coverage %: Yes
Coverage Strength: 67224.06 hits per line

💛 - Coveralls

@github-actions

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 merged commit 5574c67 into main Aug 10, 2026
14 checks passed
@dennisdoomen
dennisdoomen deleted the dennisdoomen-fix-qodana-failures branch August 10, 2026 17:21
This was referenced Sep 14, 2026
This was referenced Oct 2, 2026

This branch was previously deployed

1 inactive deployment
qodana-pr — d47f7dc1 Deployed Aug 10, 2026 by dennisdoomen via Qodana Scan #82
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.

3 participants