Port TypeMapObjectsXmlFile.Import to XmlReader streaming#11126
Merged
jonathanpeppers merged 5 commits intomainfrom Apr 17, 2026
Merged
Port TypeMapObjectsXmlFile.Import to XmlReader streaming#11126jonathanpeppers merged 5 commits intomainfrom
jonathanpeppers merged 5 commits intomainfrom
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>
Contributor
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.
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>
- 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
commented
Apr 16, 2026
Member
Author
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.
- 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
approved these changes
Apr 17, 2026
Member
simonrozsival
left a comment
There was a problem hiding this comment.
Code changes look reasonable, CI failures are unrelated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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