diff --git a/XmlSchemaClassGenerator.Tests/XmlTests.cs b/XmlSchemaClassGenerator.Tests/XmlTests.cs index 8364e0b1..ef937215 100644 --- a/XmlSchemaClassGenerator.Tests/XmlTests.cs +++ b/XmlSchemaClassGenerator.Tests/XmlTests.cs @@ -112,6 +112,7 @@ private static IEnumerable ConvertXml(string name, string xsd, Generator const string GraphMLPattern = "xsd/graphml/ygraphml.xsd"; const string UnionPattern = "xsd/union/union.xsd"; const string GuidPattern = "xsd/guid/*.xsd"; + const string Guid2Pattern = "xsd/guid2/*.xsd"; const string NullableReferenceAttributesPattern = "xsd/nullablereferenceattributes/nullablereference.xsd"; // IATA test takes too long to perform every time @@ -157,11 +158,13 @@ public void TestClient() SharedTestFunctions.TestSamples(Output, "Client", ClientPattern); } - [Fact, TestPriority(1)] + [Theory, TestPriority(1)] + [InlineData(GuidPattern)] + [InlineData(Guid2Pattern)] [UseCulture("en-US")] - public void TestGuid() + public void TestGuid(string pattern) { - var assembly = Compiler.Generate("Guid", GuidPattern); + var assembly = Compiler.Generate("Guid", pattern); var testType = assembly.GetType("Guid.Test"); var idProperty = testType.GetProperty("Id"); var elementIdProperty = testType.GetProperty("ElementId"); diff --git a/XmlSchemaClassGenerator.Tests/xsd/guid2/guid.xsd b/XmlSchemaClassGenerator.Tests/xsd/guid2/guid.xsd new file mode 100644 index 00000000..b30a19d3 --- /dev/null +++ b/XmlSchemaClassGenerator.Tests/xsd/guid2/guid.xsd @@ -0,0 +1,14 @@ + + + + + + The representation of a GUID, generally the id of an element. + + + + + + + \ No newline at end of file diff --git a/XmlSchemaClassGenerator.Tests/xsd/guid2/guidtest.xsd b/XmlSchemaClassGenerator.Tests/xsd/guid2/guidtest.xsd new file mode 100644 index 00000000..6f400ad4 --- /dev/null +++ b/XmlSchemaClassGenerator.Tests/xsd/guid2/guidtest.xsd @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/XmlSchemaClassGenerator.Tests/xsd/guid2/header.xsd b/XmlSchemaClassGenerator.Tests/xsd/guid2/header.xsd new file mode 100644 index 00000000..877c180c --- /dev/null +++ b/XmlSchemaClassGenerator.Tests/xsd/guid2/header.xsd @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/XmlSchemaClassGenerator.Tests/xsd/guid2/uuid.xsd b/XmlSchemaClassGenerator.Tests/xsd/guid2/uuid.xsd new file mode 100644 index 00000000..92dba0b8 --- /dev/null +++ b/XmlSchemaClassGenerator.Tests/xsd/guid2/uuid.xsd @@ -0,0 +1,17 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/XmlSchemaClassGenerator/CodeUtilities.cs b/XmlSchemaClassGenerator/CodeUtilities.cs index 88b85b7b..74141f34 100644 --- a/XmlSchemaClassGenerator/CodeUtilities.cs +++ b/XmlSchemaClassGenerator/CodeUtilities.cs @@ -99,7 +99,11 @@ private static Type GetIntegerDerivedType(XmlSchemaDatatype xml, GeneratorConfig Type FromFallback() => configuration.UseIntegerDataTypeAsFallback && configuration.IntegerDataType != null ? configuration.IntegerDataType : typeof(string); } - private static readonly XmlQualifiedName GuidQualifiedName = new("guid", "http://microsoft.com/wsdl/types/"); + private static readonly XmlQualifiedName[] GuidQualifiedNames = + { + new("guid", "http://microsoft.com/wsdl/types/"), + new("guid", "http://schemas.microsoft.com/2003/10/Serialization/") + }; public static Type GetEffectiveType(this XmlSchemaDatatype type, GeneratorConfiguration configuration, IEnumerable restrictions, XmlSchemaType schemaType, bool attribute = false) { @@ -114,7 +118,7 @@ public static Type GetEffectiveType(this XmlSchemaDatatype type, GeneratorConfig _ => type.ValueType, }; - if (schemaType.IsDerivedFrom(GuidQualifiedName)) + if (GuidQualifiedNames.Any(schemaType.IsDerivedFrom)) { resultType = typeof(Guid); }