Introduces attribute to set invariant culture for tests#12691
Merged
Conversation
Contributor
There was a problem hiding this comment.
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
UseInvariantCultureAttributeclass that setsInvariantCulturebefore 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.Globalizationimport is no longer needed after removing manual culture management and should be removed.
using System.Globalization;
Co-authored-by: Copilot <[email protected]>
JanProvaznik
approved these changes
Oct 23, 2025
This was referenced Oct 23, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some tests implicitly depend on the current culture and may fail when run in cultures that use different number formatting, for example.