Repository navigation
Replace trimmable manifest LINQ XML generation with lightweight XML model - #11488
simonrozsival with Copilot wants to merge 6 commits into
Conversation
|
@copilot build fails: |
... Fixed in e6721fd by aliasing the trimmable manifest model type in |
simonrozsival
left a comment
There was a problem hiding this comment.
@copilot please address these comments
| app.Add (new XElement ("uses-library", | ||
| new XAttribute (AttName, ul.Name), | ||
| new XAttribute (AndroidNs + "required", ul.Required ? "true" : "false"))); | ||
| if (!app.Elements ("uses-library").Any (e => e.AndroidAttribute (ManifestConstants.AttributeName) == ul.Name)) { |
There was a problem hiding this comment.
If we're implementing a new class, we can add helper methods for common operations, such as HasElementWithAndroidAttribute("uses-library", ManifestConstants.AttributeName, ul.Name)
| { | ||
| var existingPermissions = new HashSet<string> ( | ||
| manifest.Elements ("permission").Select (e => (string?)e.Attribute (AttName)).OfType<string> ()); | ||
| manifest.Elements ("permission").Select (e => e.AndroidAttribute (ManifestConstants.AttributeName)).OfType<string> ()); |
There was a problem hiding this comment.
This could be a helper method GetElementAttributeValues("permission", ManifestConstants.AttributeName)
There was a problem hiding this comment.
I'm just wondering if this is actually more efficient than XElement... it would be interesting to see these two implementations in a few BDN microbenchmarks (no need to include them in the PR, just report the difference in performance).
Agent-Logs-Url: https://github.com/dotnet/android/sessions/730ad033-35a2-44fe-8072-0a2e1f387b4b Co-authored-by: simonrozsival <[email protected]>
Addressed in 9d2e430 by adding |
|
@copilot this added complexity does not justify the very minor perf improvement. I wonder if we really need the read-modify-write flow everywhere and if it cannot be simplified. I think the problem is that we're storing the full XML tree instead of keeping just a well defined subset of the data. |
Agent-Logs-Url: https://github.com/dotnet/android/sessions/59bef1f8-44dc-4e30-a3cc-b0082dd1a6b4 Co-authored-by: simonrozsival <[email protected]>
Addressed in 22c6763 by simplifying the model so it no longer stores a generic XML node tree: it now keeps only manifest elements and attributes, dropping the text/comment/CDATA node hierarchy. Targeted build and trimmable typemap tests pass. |
|
@copilot run local BDN test project with the new implementation and compare it to the previous XDocument/XElement based one. Is there meaningful improvement now? |
|
This PR is not showing meaningful perf improvements |
The trimmable typemap manifest path used
System.Xml.Linqfor template parsing, read/modify/write merging, rooting, and final output. This PR moves production manifest generation to a purpose-built XML model that stores only the manifest elements and attributes needed by the trimmable pipeline while preserving existing manifest behavior.Manifest model
ManifestDocument/element/attribute model.XmlReader.XmlWriter.Generation pipeline
GenerateTrimmableTypeMap,TrimmableTypeMapGenerator, andGeneratedManifestto passManifestDocumentinstead ofXDocument.Files.CopyIfStreamChanged(...).Manifest merge helpers
XElementmutation to lightweight model mutation.Rooting
Example API shift: