docs: open ODT output files with File.Create instead of File.OpenWrite - #224
Merged
Merged
Conversation
…ite can corrupt (#138) Found by the independent review of the OpenDocument support.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Follow-up to #138 (closed), from the independent review of the OpenDocument support.
Problem
docs/for-developers/opendocument.mdrecommendedFile.OpenWritefor the output stream.File.OpenWritedoes not truncate. When it overwrites an existing, longer file, the old bytes after the new content remain, and the result is a corrupt ZIP. #221 now cuts off seekable outputs inOdtPackage.Save, but the docs should not depend on that or teach the pattern.Fix
File.Create, which creates or truncates the file.File.Createfor files and explains the truncation problem withFile.OpenWrite.File.Createanyway.File.OpenWrite. The DOCX docs (quick-start.md,Examples.md) already useFile.Createand mentionFile.OpenWriteonly as the write-only stream that fails, so they stay as they are. TheOdtPackageXML doc is part of the package work and is not changed here.Tests
OpenDocumentSamplesTestsmirrors the changed sample, which now usesFile.Create(renamed toOdtTemplateProcessor_BytesAndOutputStream).OdtPackageTestsstill covers write-only outputs and truncation.mkdocs build --strict, the Release CI build, all tests on net10/9/8,dotnet format --verify-no-changesanddotnet packpass.Public API impact: none (documentation only).