Skip to content

Commit 2540ef1

Browse files
committed
[dotnet-svcutil] defer known types import to resolve IsReference inheritance issue
1 parent f4aaf2f commit 2540ef1

File tree

1 file changed

+17
-1
lines changed
  • src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization

1 file changed

+17
-1
lines changed

src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/SchemaImporter.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ internal class SchemaImporter
2828
private SchemaObjectDictionary _schemaObjects;
2929
private List<XmlSchemaRedefine> _redefineList;
3030
private bool _needToImportKnownTypesForObject;
31+
private List<XmlQualifiedName> _deferredKnownTypesImport;
3132

3233

3334
// TODO: [Fx.Tag.SecurityNote(Critical = "Static field used to store serialization schema elements from future versions."
@@ -129,6 +130,17 @@ internal void Import()
129130
}
130131
}
131132
ImportKnownTypesForObject();
133+
134+
// Import known types for all deferred types after all main types have been imported
135+
if (_deferredKnownTypesImport != null)
136+
{
137+
// Create a copy of the list to avoid collection modification during enumeration
138+
var deferredTypesToProcess = new List<XmlQualifiedName>(_deferredKnownTypesImport);
139+
foreach (XmlQualifiedName typeName in deferredTypesToProcess)
140+
{
141+
ImportKnownTypes(typeName);
142+
}
143+
}
132144
}
133145

134146
internal static void CompileSchemaSet(XmlSchemaSet schemaSet)
@@ -490,7 +502,11 @@ private DataContract ImportType(XmlSchemaType type, XmlQualifiedName typeName, b
490502
ImportTopLevelElement(typeName);
491503
ImportDataContractExtension(type, dataContract);
492504
ImportGenericInfo(type, dataContract);
493-
ImportKnownTypes(typeName);
505+
506+
// Defer known types import - add to list for later processing
507+
if (_deferredKnownTypesImport == null)
508+
_deferredKnownTypesImport = new List<XmlQualifiedName>();
509+
_deferredKnownTypesImport.Add(typeName);
494510

495511
return dataContract;
496512
}

0 commit comments

Comments
 (0)