You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[class-parse] Use InvariantCulture to format floating-point values (#131)
Fixes: #129
The System.Double/Single ["Round-trip Format Specifier"][0] varies by
culture, so cultures which use `,` as the decimal separator character
use `,` within e.g. `42.0.ToString("r")`.
For example, the Java declaration:
class E {
public static final double V = 42.5;
}
on french systems would result in `class-parse` emitting:
<field name="V" value="42,5" .../>
which, when run through `generator`, emits:
public const double V = (double) 42,5;
...which promptly fails with a CS1001. Oops.
Fix our `double` and `float` serialization in
`XmlClassDeclarationBuilder` so that `CultureInfo.InvariantCulture` is
used, which ensures that `.` is the decimal separator character,
ensuring that `class-parse` and `generator` output is as expected.
[0]: https://msdn.microsoft.com/en-us/library/dwhawy9k(v=vs.110).aspx#RFormatString
0 commit comments