Skip to content

Fix CA1305 in Assert.That test (int.ToString() needs IFormatProvider)#8358

Merged
Evangelink merged 1 commit into
mainfrom
dev/amauryleve/fix-ca1305-assertthat-tostring
May 19, 2026
Merged

Fix CA1305 in Assert.That test (int.ToString() needs IFormatProvider)#8358
Evangelink merged 1 commit into
mainfrom
dev/amauryleve/fix-ca1305-assertthat-tostring

Conversation

@Evangelink
Copy link
Copy Markdown
Member

The Windows build is failing with CA1305 in That_Coalesce_ShortCircuit_PassingAssertion_DoesNotInvokeRight because int.ToString() is called without a format provider. This blocks PR #8348 (and any other PR built against main).

Fix: pass CultureInfo.InvariantCulture to int.ToString.

The bug was introduced in #8307 / #8306.

…keRight

Use CultureInfo.InvariantCulture for int.ToString() to satisfy CA1305.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 19, 2026 10:53
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

Fixes a CA1305 globalization analyzer failure in the Assert.That unit tests by providing an explicit IFormatProvider when converting an int to string, unblocking Windows builds that treat this warning as an error.

Changes:

  • Update counter.Increment().ToString() to counter.Increment().ToString(CultureInfo.InvariantCulture) in the That_Coalesce_ShortCircuit_PassingAssertion_DoesNotInvokeRight test.
Show a summary per file
File Description
test/UnitTests/TestFramework.UnitTests/Assertions/AssertTests.That.cs Passes CultureInfo.InvariantCulture to int.ToString to satisfy CA1305 in the Assert.That coalesce short-circuit test.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

Copy link
Copy Markdown
Member Author

@Evangelink Evangelink left a comment

Choose a reason for hiding this comment

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

✅ 21/21 dimensions clean — no findings.

The fix correctly resolves CA1305 by passing CultureInfo.InvariantCulture to int.ToString(). For integer formatting, InvariantCulture is semantically equivalent to the default, so test behavior is unchanged. The change is minimal, correctly scoped to the test file, and unblocks the CI build.

Generated by Expert Code Review (on open) for issue #8358 · ● 3.2M

@Evangelink Evangelink merged commit b885b59 into main May 19, 2026
32 of 35 checks passed
@Evangelink Evangelink deleted the dev/amauryleve/fix-ca1305-assertthat-tostring branch May 19, 2026 11:38
Evangelink pushed a commit that referenced this pull request May 19, 2026
…ted reference

Resets PR #8308 onto current main and re-adds the unique contribution from
@jakubjares as a single test plus its helper types.

After PR #8307 was merged via #8306 and PR #8358 added the CA1305 fix, the
old branch was hopelessly diverged from main. Instead of trying to thread
the needle through 16+ source conflicts, this commit takes main's
source/test files verbatim and only adds:

* That_TwoCallsReturningSameMutatedReference_DeduplicatesInDetails
* Shape (helper)
* BoxOfShapes (helper)

The test pins down the current UX limitation: when two calls return the
SAME mutable reference and the comparison is reference-inequality, the
cache stores the same reference for both call expressions; by the time
details are extracted the object has been mutated, both slots resolve to
the same value, and TryAddExpressionValue's same-value dedupe means only
one entry surfaces (`Shape: Circle`). Documenting this behavior gives
us a regression guard if we ever decide to improve the diagnostic.

Replaces the previous `WithMessage("non")` placeholder with the real
expected message. All 76 That_* tests pass.

Co-authored-by: Jakub Jareš <me@jakubjares.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Evangelink pushed a commit that referenced this pull request May 19, 2026
…ted reference

Resets PR #8308 onto current main and re-adds the unique contribution from
@jakubjares as a single test plus its helper types.

After PR #8307 was merged via #8306 and PR #8358 added the CA1305 fix, the
old branch was hopelessly diverged from main. Instead of trying to thread
the needle through 16+ source conflicts, this commit takes main's
source/test files verbatim and only adds:

* That_TwoCallsReturningSameMutatedReference_DeduplicatesInDetails
* Shape (helper)
* BoxOfShapes (helper)

The test pins down the current UX limitation: when two calls return the
SAME mutable reference and the comparison is reference-inequality, the
cache stores the same reference for both call expressions; by the time
details are extracted the object has been mutated, both slots resolve to
the same value, and TryAddExpressionValue's same-value dedupe means only
one entry surfaces (`Shape: Circle`). Documenting this behavior gives
us a regression guard if we ever decide to improve the diagnostic.

Replaces the previous `WithMessage("non")` placeholder with the real
expected message. All 76 That_* tests pass.

Co-authored-by: Jakub Jareš <me@jakubjares.com>
Co-authored-by: Copilot <223556219+Copilot@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.

2 participants