Skip to content

[Bug]: Number literals are interpreted differently depending on locale #8798

Closed

Description

@ladipro

Issue Description

Passing literals with dots and commas to property functions results in differently evaluated projects depending on locale / regional settings under which the MSBuild process runs.

Steps to Reproduce

<Project>
  <Target Name="Build">
    <Message Text="$([MSBuild]::Add('1,2', 1))"/>
  </Target>
</Project>

Expected Behavior

The Message task should print 13 regardless of locale.

Actual Behavior

English/invariant: 13

Switch Regional format to one that uses comma for decimal separator, for example French. The task prints 2,2.

Analysis

This is caused by calling the default overloads of double.Parse in evaluation.

Doesn't look like a recent regression but the .NET Framework-bundled MSBuild doesn't seem to have this bug.

Versions & Configurations

MSBuild version 17.7.0-preview-23267-02+fe79798bd for .NET Framework

Activity

  1. added
    Priority:2Work that is important, but not critical for the release
    Good First IssueSelf-contained issues good for first-time contributors.
    and removed
    needs-triageHave yet to determine what bucket this goes in.
    on May 30, 2023
  2. jrdodds commented on Jun 6, 2023

    @jrdodds
    Contributor

    The example in the steps to reproduce is resolved by PR #8710 for issue #8698 but that may not be a complete resolution of the locale issue.

    Please assign this issue to me. I'll check for other usages of the default overloads of double.Parse.

  3. jrdodds commented on Jun 28, 2023

    @jrdodds
    Contributor

    PR #8710 has been merged and contains all the changes from PR #8853. This issue has been completed by PR #8710.

  4. ladipro commented on Jul 3, 2023

    @ladipro
    MemberAuthor

    Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Good First IssueSelf-contained issues good for first-time contributors.Priority:2Work that is important, but not critical for the releasebugtriaged

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions