Uh oh!
There was an error while loading. Please reload this page.
Port TypeMapObjectsXmlFile.Import to XmlReader streaming - #11126
Conversation
Replace XDocument.Load (full DOM parse per assembly) with forward-only XmlReader streaming in the Import path. This avoids allocating the entire XML DOM tree for each .typemap.xml file. - Replace Import, ImportDebugData, ImportReleaseData methods to use XmlReader - Add ReadDebugEntries, ReadReleaseEntries, ReadReleaseScratchEntries, ReadReleaseEntry helper methods for streaming reads - Use depth-tracking to robustly detect container end-elements - Remove unused System.Linq, System.Xml.Linq, NuGet.Packaging usings - Export side (XmlWriter) is unchanged Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR refactors TypeMapObjectsXmlFile.Import to use forward-only XmlReader streaming instead of XDocument.Load, reducing per-assembly allocations during typemap XML import in the build tasks.
Changes:
- Replaced DOM-based import (
XDocument/XElement) with streamingXmlReaderparsing. - Added streaming helpers to read debug/release entries with depth-based container termination.
- Removed now-unused
System.Linq,System.Xml.Linq, andNuGet.Packagingusings.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Use Guid.Parse / Convert.ToBoolean / Convert.ChangeType to throw on invalid values (matching original GetAttributeOrDefault behavior) - Add GetAttributeOrDefault<T> helper for XmlReader - Include filename in error messages - Check IsNullOrWhiteSpace for 'type' attribute (matching GetRequiredAttribute) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Use GetAttributeOrDefault for mvid-bytes to handle whitespace the same way as the original GetAttributeOrDefault<T> on XElement - Use entries.Add() instead of entries[key] to throw on duplicate keys, matching the original NuGet.Packaging AddRange behavior Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jonathanpeppers
left a comment
There was a problem hiding this comment.
🤖 AI Review Summary
Verdict: ✅ LGTM
Found 3 items: 1
⚠️ Nullable: Use.IsNullOrWhiteSpace ()extension method per repo convention (4 occurrences)- 💡 Code organization:
foundJniNativeRegistrationparsing can use the newGetAttributeOrDefaulthelper for consistency - 💡 Performance:
Convert.ChangeTypeshould specifyCultureInfo.InvariantCulturefor round-trip safety
👍 Clean port from XDocument to XmlReader streaming. The depth-tracking pattern is correct and robust. Good removal of System.Linq, System.Xml.Linq, and NuGet.Packaging usings. Export side is correctly left unchanged.
Review generated by android-reviewer from review guidelines.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Use .IsNullOrWhiteSpace() extension methods for NRT flow analysis - Reuse GetAttributeOrDefault for found-jni-native-registration - Pass CultureInfo.InvariantCulture to Convert.ChangeType for round-trip safety with Export side Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
simonrozsival
left a comment
There was a problem hiding this comment.
Code changes look reasonable, CI failures are unrelated.
Uh oh!
There was an error while loading. Please reload this page.
Summary
Replace
XDocument.Load(full DOM parse per assembly) with forward-onlyXmlReaderstreaming in theImportpath ofTypeMapObjectsXmlFile. This avoids allocating the entire XML DOM tree for each.typemap.xmlfile during the build.Changes
Import,ImportDebugData,ImportReleaseDatamethods to useXmlReaderReadDebugEntries,ReadReleaseEntries,ReadReleaseScratchEntries,ReadReleaseEntryhelper methods for streaming readsSystem.Linq,System.Xml.Linq,NuGet.PackagingusingsXmlWriter) is unchanged