@@ -1523,11 +1523,27 @@ public IEnumerable<CodeAttributeDeclaration> GetRestrictionAttributes()
15231523
15241524 if ( minInclusive != null && maxInclusive != null )
15251525 {
1526- yield return new CodeAttributeDeclaration (
1527- CodeUtilities . CreateTypeReference ( typeof ( RangeAttribute ) , Configuration ) ,
1528- new CodeAttributeArgument ( new CodeTypeOfExpression ( minInclusive . Type ) ) ,
1529- new CodeAttributeArgument ( new CodePrimitiveExpression ( minInclusive . Value ) ) ,
1530- new CodeAttributeArgument ( new CodePrimitiveExpression ( maxInclusive . Value ) ) ) ;
1526+ var rangeAttribute = new CodeAttributeDeclaration (
1527+ CodeUtilities . CreateTypeReference ( typeof ( RangeAttribute ) , Configuration ) ,
1528+ new CodeAttributeArgument ( new CodeTypeOfExpression ( minInclusive . Type ) ) ,
1529+ new CodeAttributeArgument ( new CodePrimitiveExpression ( minInclusive . Value ) ) ,
1530+ new CodeAttributeArgument ( new CodePrimitiveExpression ( maxInclusive . Value ) ) ) ;
1531+
1532+ // see https://github.com/mganss/XmlSchemaClassGenerator/issues/268
1533+ if ( Configuration . NetCoreSpecificCode )
1534+ {
1535+ if ( minInclusive . Value . Contains ( "." ) || maxInclusive . Value . Contains ( "." ) )
1536+ {
1537+ rangeAttribute . Arguments . Add ( new CodeAttributeArgument ( "ParseLimitsInInvariantCulture" , new CodePrimitiveExpression ( true ) ) ) ;
1538+ }
1539+
1540+ if ( minInclusive . Type != typeof ( int ) && minInclusive . Type != typeof ( double ) )
1541+ {
1542+ rangeAttribute . Arguments . Add ( new CodeAttributeArgument ( "ConvertValueInInvariantCulture" , new CodePrimitiveExpression ( true ) ) ) ;
1543+ }
1544+ }
1545+
1546+ yield return rangeAttribute ;
15311547 }
15321548 }
15331549 }
0 commit comments