diff --git a/XmlSchemaClassGenerator.Tests/XmlTests.cs b/XmlSchemaClassGenerator.Tests/XmlTests.cs
index 6ddd507e..b32f931a 100644
--- a/XmlSchemaClassGenerator.Tests/XmlTests.cs
+++ b/XmlSchemaClassGenerator.Tests/XmlTests.cs
@@ -739,13 +739,39 @@ public void AssemblyVisibleIsInternalInterface()
Assert.Contains("internal partial interface INamedElement", content);
}
+ [Fact]
+ public void DecimalSeparatorTest()
+ {
+ // see https://github.com/mganss/XmlSchemaClassGenerator/issues/101
+
+ const string xsd = @"
+
+
+
+
+";
+
+ var generator = new Generator
+ {
+ NamespaceProvider = new NamespaceProvider
+ {
+ GenerateNamespace = key => "Test",
+ },
+ GenerateInterfaces = true,
+ AssemblyVisible = true
+ };
+ var contents = ConvertXml(nameof(ComplexTypeWithAttributeGroupExtension), xsd, generator);
+ var content = Assert.Single(contents);
+
+ Assert.Contains("private decimal _someAttr = 1.5m;", content);
+ }
+
private static void CompareOutput(string expected, string actual)
{
string Normalize(string input) => Regex.Replace(input, @"[ \t]*\r\n", "\n");
Assert.Equal(Normalize(expected), Normalize(actual));
}
-
[Theory]
[InlineData(typeof(decimal), "decimal")]
[InlineData(typeof(long), "long")]
diff --git a/XmlSchemaClassGenerator/TypeModel.cs b/XmlSchemaClassGenerator/TypeModel.cs
index 680d39ea..b535d0e2 100644
--- a/XmlSchemaClassGenerator/TypeModel.cs
+++ b/XmlSchemaClassGenerator/TypeModel.cs
@@ -6,6 +6,7 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics;
+using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml;
@@ -1275,7 +1276,7 @@ public override CodeExpression GetDefaultValueFor(string defaultString, bool att
return rv;
}
- return new CodePrimitiveExpression(Convert.ChangeType(defaultString, ValueType));
+ return new CodePrimitiveExpression(Convert.ChangeType(defaultString, ValueType, CultureInfo.InvariantCulture));
}
public IEnumerable GetRestrictionAttributes()