FormatCommandLine wrote option and value arguments using the ambient thread culture via value.ToString(), while the parser reads them back with ParserSettings.ParsingCulture (invariant by default). On threads whose culture uses a comma decimal separator (for example de-DE) a double 1.5 was unparsed as "1,5" and reparsed as 15, and a sequence [1.5, 2.5] became "1,5,2,5" and reparsed as four elements [1,5,2,5], so the format/parse round-trip was broken. Format IFormattable values (numeric and date/time types) with the parser ParsingCulture instead of the current thread culture, for both scalar and separator-joined sequence values. Other types keep their default string representation, so behaviour on invariant/en-US is unchanged. Add round-trip tests under de-DE for a scalar double and a comma-separated double sequence.
13 lines
374 B
C#
13 lines
374 B
C#
// Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information.
|
|
|
|
using System.Collections.Generic;
|
|
|
|
namespace CommandLine.Tests.Fakes
|
|
{
|
|
class Options_With_Double_Sequence
|
|
{
|
|
[Option("dbls", Separator = ',')]
|
|
public IEnumerable<double> DoubleSequence { get; set; }
|
|
}
|
|
}
|