Skip to content

Changing templating system from XmlDocument based to XDocument based#946

Open
michelebastione wants to merge 3 commits intomini-software:masterfrom
michelebastione:XmlDocument-to-XDocument
Open

Changing templating system from XmlDocument based to XDocument based#946
michelebastione wants to merge 3 commits intomini-software:masterfrom
michelebastione:XmlDocument-to-XDocument

Conversation

@michelebastione
Copy link
Copy Markdown
Contributor

@michelebastione michelebastione commented Apr 11, 2026

This PR swaps the templating system implementation, currently based on the use of XmlDocument, with one based on the more modern, more readable and LINQ-supporting XDocument.

It also improves on the implementation of the OpenXmlZip class to make better use of the new .NET 10's ZipArchive's async API throughout the codebase.

Resolves #758
Resolves #804

- Changed `OpenXmlZip` to make use of `ZipArchive`'s asynchronous `CreateAsync` and `DisposeAsync` methods by adding an asynchronous factory method and the IAsyncDisposable implementation
- Updated all entry points for `OpenXmlZip` and `ZipArchive` in all methods across the codebase
- Added `SynchronousHelper` with extension methods for ensuring compatibility with the SyncMethodGenerator
- Other minor code cleanups
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the OpenXml template engine to use XDocument and XElement instead of XmlDocument, introduces asynchronous initialization for ZIP archives, and improves cross-framework compatibility. While the migration to System.Xml.Linq modernizes the codebase, several critical issues were identified: a variable corruption bug in the XML writing loop, the destruction of XML structure when handling merged cells via XElement.Value, and a performance bottleneck in formula processing due to redundant XML round-trips. Furthermore, a regression in ZIP entry lookups introduced case-sensitivity, and unsafe attribute access poses a risk of null reference exceptions.

@michelebastione michelebastione marked this pull request as ready for review April 12, 2026 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XDocument vs XmlDocument Optimize sheetData.InnerText split

1 participant