Fix Qodana-flagged possible multiple enumeration and unused auto-property warnings - #3300
Conversation
…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>
Test Results 37 files ±0 37 suites ±0 2m 48s ⏱️ -6s 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.♻️ 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>
Coverage Report for CI Build 31398681247Warning No base build found for commit Coverage: 97.183%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats💛 - Coveralls |
Qodana for .NETIt 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 Contact Qodana teamContact us at qodana-support@jetbrains.com
|
Summary
The Qodana workflow on
mainhas been failing (fail threshold 0) due to 10 new problems introduced by recent PRs:GenericCollectionAssertions.BeProperSubsetOf/BeProperSupersetOf— theexpectedProperSuperset/expectedProperSubsetparameters were enumerated more than once (once inside the sharedAssertSubsetOf/AssertContainmenthelper, again viaConvertOrCastToSet(), and again when passed toFailWith).ObjectAssertionSpecs.BeJsonSerializable.cstest helper DTOs, whose properties are only ever set (never read) but are required for JSON round-trip testing.Changes
BeProperSubsetOf/BeProperSupersetOfnow materialize the expected collection once into anICollection<T>and derive anyISet<T>needed for comparisons from that materialized collection, instead of re-enumerating the originalIEnumerable<T>parameter multiple times. Error messages and null-argument guard messages are unchanged.[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 buildsucceeds with 0 warnings/errors.dotnet testfor theCollectionsandBeJsonSerializablespecs: all pass (928/928 on net6.0/net8.0, 906/906 on net47).AcceptApiChangesrun needed.