Skip to content

[dotnet-svcutil] defer known types import to resolve IsReference inheritance issue #5810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ internal class SchemaImporter
private SchemaObjectDictionary _schemaObjects;
private List<XmlSchemaRedefine> _redefineList;
private bool _needToImportKnownTypesForObject;
private List<XmlQualifiedName> _deferredKnownTypesImport;


// TODO: [Fx.Tag.SecurityNote(Critical = "Static field used to store serialization schema elements from future versions."
Expand Down Expand Up @@ -129,6 +130,17 @@ internal void Import()
}
}
ImportKnownTypesForObject();

// Import known types for all deferred types after all main types have been imported
if (_deferredKnownTypesImport != null)
{
// Create a copy of the list to avoid collection modification during enumeration
var deferredTypesToProcess = new List<XmlQualifiedName>(_deferredKnownTypesImport);
foreach (XmlQualifiedName typeName in deferredTypesToProcess)
{
ImportKnownTypes(typeName);
}
}
}

internal static void CompileSchemaSet(XmlSchemaSet schemaSet)
Expand Down Expand Up @@ -490,7 +502,11 @@ private DataContract ImportType(XmlSchemaType type, XmlQualifiedName typeName, b
ImportTopLevelElement(typeName);
ImportDataContractExtension(type, dataContract);
ImportGenericInfo(type, dataContract);
ImportKnownTypes(typeName);

// Defer known types import - add to list for later processing
if (_deferredKnownTypesImport == null)
_deferredKnownTypesImport = new List<XmlQualifiedName>();
_deferredKnownTypesImport.Add(typeName);

return dataContract;
}
Expand Down
Loading