Summary
The IfcXml readers resolve Express type names by upper-casing the XML element name with the
culture-sensitive string.ToUpper(), while the metadata dictionary is keyed on invariant upper
case. Under the Turkish (and Azeri) casing rules i maps to İ (U+0130), so the lookup never
matches:
tr-TR "IfcOrganization".ToUpper() => "IFCORGANİZATİON"
invariant "IfcOrganization".ToUpperInvariant() => "IFCORGANIZATION"
Every IFC type name contains an i, so on a machine whose current culture is Turkish, reading
IfcXml fails completely.
Reproduction
[Theory]
[InlineData("en-US")]
[InlineData("tr-TR")]
public void Can_read_ifcxml_regardless_of_current_culture(string culture)
{
var previous = CultureInfo.CurrentCulture;
try
{
CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo(culture);
using var model = new MemoryModel(new EntityFactoryIfc4());
model.LoadXml(@"TestFiles\Dimensions.ifcxml");
Assert.True(model.Instances.Count > 0);
}
finally
{
CultureInfo.CurrentCulture = previous;
}
}
en-US passes. tr-TR fails with:
Xbim.Common.Exceptions.XbimParserException : IfcProjectLibraryis not an IPersistEntity type
Running the whole Xbim.Essentials.Tests suite on a tr-TR machine gives 30 failures on current
master (e3c8777), for both net48 and net10.0. A typical message is:
Error reading XML, Line=14, Position=6, Tag='IfcOrganization'
---> System.Exception: Illegal XML element tag
CI does not catch this because it runs under an English culture.
Affected call sites
Reading (the cause of the failures above):
Xbim.IO.MemoryModel/Xml/XbimXmlReader4.cs - GetExpresType (2 calls)
Xbim.IO.MemoryModel/Xml/XbimXmlReader3.cs - IsIfcProperty, IsIfcType (2 calls), IsIfcEntity
Writing (same class of problem, surfaced by the round-trip and serialization tests):
Xbim.IO.MemoryModel/Xml/XbimXmlWriter4.cs - enum values
Xbim.IO.MemoryModel/Xml/IfcXmlWriter3.cs - enum values
Xbim.Common/Step21/Part21Writer.cs - select type names and enum values
Xbim.Common/Step21/StepFileHeader.cs - schema name
Xbim.IO.Esent/IPersistEntityExtensions.cs - select type names
Suggested fix
Use ToUpperInvariant() / ToLowerInvariant() on these paths. With that change the suites are
green on a tr-TR machine: 497/497 in Xbim.Essentials.Tests and 95/95 in
Xbim.Essentials.NetCore.Tests.
I have the fix and the culture-parameterised regression test working locally. Happy to open a PR
against develop if you would like it.
Environment
- XbimEssentials
master @ e3c8777
- .NET SDK 10.0.302, targets
net10.0 and net48
- Windows 11,
CurrentCulture = tr-TR
Summary
The IfcXml readers resolve Express type names by upper-casing the XML element name with the
culture-sensitive
string.ToUpper(), while the metadata dictionary is keyed on invariant uppercase. Under the Turkish (and Azeri) casing rules
imaps toİ(U+0130), so the lookup nevermatches:
Every IFC type name contains an
i, so on a machine whose current culture is Turkish, readingIfcXml fails completely.
Reproduction
en-USpasses.tr-TRfails with:Running the whole
Xbim.Essentials.Testssuite on a tr-TR machine gives 30 failures on currentmaster(e3c8777), for bothnet48andnet10.0. A typical message is:CI does not catch this because it runs under an English culture.
Affected call sites
Reading (the cause of the failures above):
Xbim.IO.MemoryModel/Xml/XbimXmlReader4.cs-GetExpresType(2 calls)Xbim.IO.MemoryModel/Xml/XbimXmlReader3.cs-IsIfcProperty,IsIfcType(2 calls),IsIfcEntityWriting (same class of problem, surfaced by the round-trip and serialization tests):
Xbim.IO.MemoryModel/Xml/XbimXmlWriter4.cs- enum valuesXbim.IO.MemoryModel/Xml/IfcXmlWriter3.cs- enum valuesXbim.Common/Step21/Part21Writer.cs- select type names and enum valuesXbim.Common/Step21/StepFileHeader.cs- schema nameXbim.IO.Esent/IPersistEntityExtensions.cs- select type namesSuggested fix
Use
ToUpperInvariant()/ToLowerInvariant()on these paths. With that change the suites aregreen on a tr-TR machine: 497/497 in
Xbim.Essentials.Testsand 95/95 inXbim.Essentials.NetCore.Tests.I have the fix and the culture-parameterised regression test working locally. Happy to open a PR
against
developif you would like it.Environment
master@ e3c8777net10.0andnet48CurrentCulture= tr-TR