Skip to content

[Bug]: Test display names format numeric arguments with the current culture #7126

Closed

Description

@Quattordici

Bug report checklist

  • I've searched existing issues to ensure this isn't a duplicate
  • I've read the documentation and this isn't expected behavior
  • I'm using the latest version of TUnit

Description

ArgumentFormatter, which builds the argument part of test display names, formats primitives with
ToString(), i.e. the machine's current culture. Under cultures with a decimal comma (sv-SE, de-DE, fr-FR, …)
a double/float/decimal argument is rendered with a comma, which collides with the , separator between
arguments. The same test therefore gets a different, and ambiguous, display name depending on the machine it
runs on.

Expected Behavior

Display names are the same on every machine, and numeric arguments can't be confused with the argument
separator, e.g. Test(1.5, 2) regardless of culture. This would match TestNameFormatter.FormatArgumentValue,
which already formats double/float/decimal with CultureInfo.InvariantCulture ("to avoid
culture-specific formatting issues").

Actual Behavior

Culture Display name for [Arguments(1.5, 2)]
en-US Test(1.5, 2)
sv-SE Test(1,5, 2)
de-DE Test(1,5, 2)

Test(1,5, 2) reads as three arguments. Negative numbers are also affected under cultures that use
U+2212 MINUS SIGN (sv-SE, fi-FI, nb-NO, …): -1 is displayed as −1.

Steps to Reproduce

  1. Create a TUnit test project with:

    public class CultureDisplayNameTests
    {
        [Test]
        [Arguments(1.5, 2)]
        public void Test(double value, int count)
        {
        }
    }
  2. List the tests under two cultures:

    LANG=en_US.UTF-8 dotnet run -- --list-tests   # Test(1.5, 2)
    LANG=sv_SE.UTF-8 dotnet run -- --list-tests   # Test(1,5, 2)

    (On Windows, change the region format instead of LANG.) The same difference shows in IDE test explorers.

Inside the TUnit repository, tests/TUnit.TestProject/Bugs/2136/Tests.cs shows it too:
GenericArgumentsTest<double>(1.1, 1·1) under en-US vs GenericArgumentsTest<double>(1,1, 1·1) under sv-SE.

TUnit Version

1.75.0 (latest release), and current main.

.NET Version

.NET SDK 10.0.402; observed on net8.0, net9.0 and net10.0 test targets.

Operating System

macOS

IDE / Test Runner

JetBrains Rider

Error Output / Stack Trace

Additional Context

  • Display names come from ArgumentFormatter.Format in TestContext.Metadata, DisplayNameAttribute,
    DisplayNameSubstitutor and the engine's DisplayNameBuilder, which fall back to ToString() for
    primitives.
  • ArgumentFormatter already replaces . in string arguments with · "to prevent VS Test Explorer from
    interpreting them as namespace separators", but a numeric argument under en-US still produces a raw .
    (1.5), which that comment suggests can be mis-split as well.
  • Suggested direction: format IFormattable primitives with CultureInfo.InvariantCulture (matching
    TestNameFormatter), and decide whether numeric dots should get the same · treatment as strings.
  • Impact: display names (and anything derived from them, e.g. saved filters or test history) would change
    for users in decimal-comma cultures, so this may warrant a release note.
  • I'm happy to take this on and open a PR. If you agree with the direction, or prefer a different one (for
    example on the numeric · escaping), let me know and I'll implement it accordingly.

IDE-Specific Issue?

  • I've confirmed this issue occurs when running via dotnet test or dotnet run, not just in my IDE

Activity

  1. added a commit that references this issue on Oct 20, 2026
    86566fc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions