dotnet / dotnet/wpf

Revisit Seekability of writable zip streams

Open
#1,364 4 comments 0 reactions 0 assignees View on GitHub
Bug
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

In PR #1311 (issue #585) two writable streams ([Certificate.cs](https://github.com/dotnet/wpf/blob/master/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/Certificate.cs#L134) and [XmlDigitalSignatureProcessor.cs](https://github.com/dotnet/wpf/blob/master/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/XmlDigitalSignatureProcessor.cs#L940)) get wrapped in a memory stream by calling the new method `GetSeekableStream(FileMode.Create, FileAccess.Write)`. It is unclear from the PR source how the written data will be propagated to the actual zip stream. Since this was noticed after the PR merged I'm opening a separate issue to revisit the handling of writable streams.

I'd also argue that the current implementation of [GetSeekableStream](https://github.com/dotnet/wpf/blob/master/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/IO/Packaging/PackagePartExtensions.cs#L60) should not have had `FileMode` and `FileAccess` paramters, since the only case which is handled correctly is the open/read combination.

I'd suggest either providing a dedicated stream wrapper class and keeping FileMode/FileAccess, or remove FileMode/FileAccess and provide a separate code path for callers who want to write data.

Related: issue #1363 apparently still has call sites which do not get wrapped

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.