Commit e35b03e
authored
[class-parse] Use InvariantCulture to format floating-point values (dotnet#131)
Fixes: dotnet#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#RFormatString1 parent 1d01fd3 commit e35b03e
File tree
1 file changed
+13
-2
lines changed- src/Xamarin.Android.Tools.Bytecode
1 file changed
+13
-2
lines changedLines changed: 13 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
443 | 444 | | |
444 | 445 | | |
445 | 446 | | |
446 | | - | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
447 | 459 | | |
448 | | - | |
449 | 460 | | |
450 | 461 | | |
451 | 462 | | |
| |||
0 commit comments