Test with local de-CH is failing

Hello,
I have a build running on appveyor which fails constantly when doing tests with locale de-CH. On my local system (de-DE the test runs fine).
I've enhanced the exception output and I receive a weird response for decimal formats:

System.FormatException : Huh: Formatting '1.0' with de-CH failed (delimiter: ',', separator: '�')\r\n---- System.FormatException : Input string was not in a correct format.

The input string is 1.0 which is valid for de-CH.

Is there any limitation on localizations within the build server environment?

Best regards

  1. Hi Stephen,

    Take a look at this thread for the solution: http://help.appveyor.com/discussions/problems/2491-period-instead-o...

  2. This won't help. I'm doing tests in the source code with different locales. It this problem related to specific locales?

  3. Can you please drop an example of such test?

    - Feodor

  4. [Fact]
            public void DecimalDeCh()
            {
                CultureInfo info = new CultureInfo("de-CH");
                Assert.Equal("de-CH", info.Name);
                info.TextInfo.ListSeparator = ";";

                string data = "Test1;Test3;\"Test\";\nData1;Data2;1.0\nData1;Data2;2.0\nData1;Data2\nData1;Data2;2.43\n";
                CsvStreamImporter streamImporter = new CsvStreamImporter(GenerateStreamFromString(data), info);
                streamImporter.SetHeader(true);
                streamImporter.SetupColumns();
                streamImporter.SetDataType("Test", typeof(DecimalColumnDefinition));
                Assert.True(streamImporter.Read());
                Assert.Equal(1M, streamImporter.GetValue(2));
                Assert.True(streamImporter.Read());
                Assert.Equal(2M, streamImporter.GetValue(2));
                Assert.True(streamImporter.Read());
                Assert.Equal(0M, streamImporter.GetValue(2));
                Assert.True(streamImporter.Read());
                Assert.Equal(2.43M, streamImporter.GetValue(2));
            }

    The internal routine is doing the following conversion:

                try
                {
                    return System.Convert.ToDecimal(value, cultureInfo);
                }
                catch (FormatException fe)
                {
                    throw new FormatException(string.Format("Huh: Formatting {0} with {1} failed (delimiter: '{2}', separator: '{3}'", value, cultureInfo.Name, cultureInfo.NumberFormat.NumberDecimalSeparator, cultureInfo.NumberFormat.NumberGroupSeparator), fe);
                }

  5. At least for de-DE it's working fine. If added the following workaround for de-CH to get things running:

    #if FIX_APVOYER
                info.NumberFormat.NumberDecimalSeparator = ".";
                info.NumberFormat.NumberGroupSeparator = "'";
    #endif

    Anyhow I would like to see this fixed if possible.

    Regards
    Stephen

  6. Indeed, the problem exists. This fails on AppVeyor but works locally.

    Will take a look into that.

  7. What framework version do you use?

  8. 4.5.1

  9. OK, this issue has been fixed on all servers.

  10. Thx, works like a charm now

  11. stephen closed this discussion on 28 Jul, 2015 07:51 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions