Repository navigation
Conversation
…ckage Saving a Strict package re-created every relationship that was translated to its transitional type on load, including relationships whose part had been deleted since, so the saved package could not be read again. A relationship is now rewritten only if the collection still holds the same object. Relationships hidden by an ignore filter are rewritten as before. Every part is loaded before the first container is saved, so relationships loaded later in the save are also translated. Fixes dotnet#2155
This branch has not been deployed
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
Saving an ISO Strict package put back the relationship to a part that was deleted after the package was opened. The saved package then could not be read again (
Part: /xl/calcChain.xml doesn't exist in the package.). This change rewrites only the relationships that are still there.Fixes #2155
Problem
StrictNamespaceExtensions.UseTransitionalRelationshipNamespacesrecords each Strict relationship that it translates to its transitional type on load. On save, it removes and re-creates every recorded relationship. It did not check that the relationship was still in its collection. So:DeletePartremoves the relationship, but the record stays, and the save creates the relationship again. This applies to part relationships (a calc chain or a worksheet) and to package relationships (for example the extended properties)._rels/.relswith Strict types.Change
PackageRelationshipBuilder. AContains(id)check alone is not enough, because of the reused-id case.IsRemoved, for example afterIgnoreCalculationChainPartRelationship()) is never in the collection, and cannot be removed through it. It is rewritten as before.Foundgetter already did is nowStrictNamespaceFeature.EnsureAllPartsLoaded(), and both use it.TrySavePartContentalready readsStrictRelationshipFoundfor every part, so this adds no new work in practice.Tests
New
test/DocumentFormat.OpenXml.Tests/IsoStrictTest/StrictRelationshipSaveTests.cs, with 6 tests. All 6 fail onmain, and all pass with this change:O14ISOStrict/Excel/2D Rotation-O12-XL-OartEffects.xlsx;The tests check the saved package with
System.IO.Packaging: no internal relationship points to a missing part, and no relationship keeps a Strict type.Existing suites on net10.0 pass: DocumentFormat.OpenXml.Tests (2,319 passed, 3 skipped as before), Packaging.Tests (190), Framework.Tests (192), Framework.Features.Tests (7) and Linq.Tests (22). The Framework project builds for every target framework with no warnings.