Skip to content

Introduces attribute to set invariant culture for tests#12691

Merged
MichalPavlik merged 4 commits into
mainfrom
dev/mipavlik/invariant-culture-tests
Oct 23, 2025
Merged

Introduces attribute to set invariant culture for tests#12691
MichalPavlik merged 4 commits into
mainfrom
dev/mipavlik/invariant-culture-tests

Conversation

@MichalPavlik

Copy link
Copy Markdown
Member

Some tests implicitly depend on the current culture and may fail when run in cultures that use different number formatting, for example.

Copilot AI review requested due to automatic review settings October 23, 2025 09:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a UseInvariantCultureAttribute to ensure tests run with consistent number formatting and culture-dependent behavior across different locales, preventing culture-related test failures.

Key Changes:

  • New UseInvariantCultureAttribute class that sets InvariantCulture before tests and restores original culture after
  • Replaced manual culture setup/teardown in test classes with the new attribute
  • Applied the attribute to test classes and methods that depend on culture-invariant formatting

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Xunit.NetCore.Extensions/UseInvariantCultureAttribute.cs New xUnit attribute class that manages culture state around test execution
src/Build.UnitTests/TerminalLogger_Tests.cs Applied class-level attribute, removed manual culture management from constructor and Dispose
src/Build.UnitTests/NodeStatus_Transition_Tests.cs Applied class-level attribute, added required using statements
src/Build.UnitTests/NodeStatus_SizeChange_Tests.cs Applied class-level attribute, removed IDisposable implementation and manual culture management
src/Build.UnitTests/Graph/ProjectGraph_Tests.cs Added using statement for the new attribute namespace
src/Build.UnitTests/Evaluation/IntrinsicFunctionOverload_Tests.cs Applied class-level attribute
src/Build.UnitTests/Evaluation/Expander_Tests.cs Applied method-level attribute to specific culture-sensitive tests
Comments suppressed due to low confidence (1)

src/Build.UnitTests/NodeStatus_SizeChange_Tests.cs:5

  • The System.Globalization import is no longer needed after removing manual culture management and should be removed.
using System.Globalization;

Comment thread src/Xunit.NetCore.Extensions/UseInvariantCultureAttribute.cs Outdated
Comment thread src/Xunit.NetCore.Extensions/UseInvariantCultureAttribute.cs Outdated
@MichalPavlik MichalPavlik enabled auto-merge (squash) October 23, 2025 09:12
@MichalPavlik MichalPavlik self-assigned this Oct 23, 2025
Comment thread src/Xunit.NetCore.Extensions/UseInvariantCultureAttribute.cs Outdated
Comment thread src/Xunit.NetCore.Extensions/UseInvariantCultureAttribute.cs Outdated
@MichalPavlik MichalPavlik merged commit 75992cc into main Oct 23, 2025
10 checks passed
@MichalPavlik MichalPavlik deleted the dev/mipavlik/invariant-culture-tests branch October 23, 2025 10:35
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