Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport System.IO.Compression docs #48841

Closed
wants to merge 18 commits into from

Conversation

carlossanlop
Copy link
Member

@carlossanlop carlossanlop commented Feb 26, 2021

Includes types from System.IO.Compression, except those found in Compression.ZipFile (PR in review) and Compression.Brotli (merged PR).

Backport automated using DocsPortingTool with this command:

DocsPortingTool.exe \
-CsProj D:\runtime\src\libraries\System.IO.Compression\src\System.IO.Compression.csproj \
-Docs D:\dotnet-api-docs\xml \
-Direction ToTripleSlash \
-IncludedAssemblies System.IO.Compression \
-IncludedNamespaces System.IO.Compression

Related PRs:

Please review by comparing against the files of origin (keep in mind what the related PRs are changing): https://github.com/dotnet/dotnet-api-docs/tree/master/xml/System.IO.Compression

@carlossanlop carlossanlop added documentation Documentation bug or enhancement, does not impact product or test code area-System.IO.Compression labels Feb 26, 2021
@carlossanlop carlossanlop added this to the 6.0.0 milestone Feb 26, 2021
@carlossanlop carlossanlop self-assigned this Feb 26, 2021
Copy link
Member Author

@carlossanlop carlossanlop left a comment

Choose a reason for hiding this comment

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

Pending reviewing more files.


// This is an abstract concept and NOT the ZLib compression level.
// There may or may not be any correspondence with the a possible implementation-specific level-parameter of the deflater.
/// <summary>Specifies values that indicate whether a compression operation emphasizes speed or compression size.</summary>
Copy link
Member Author

Choose a reason for hiding this comment

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

These double slash comments should probably stay:

Suggested change
/// <summary>Specifies values that indicate whether a compression operation emphasizes speed or compression size.</summary>
// This is an abstract concept and NOT the ZLib compression level.
// There may or may not be any correspondence with the a possible implementation-specific level-parameter of the deflater.
/// <summary>Specifies values that indicate whether a compression operation emphasizes speed or compression size.</summary>

/// [!code-vb[System.IO.Compression.DeflateStream#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.io.compression.deflatestream/vb/program1.vb#1)]
/// ]]></format></example>
/// <exception cref="System.ArgumentNullException"><paramref name="stream" /> is <see langword="null" />.</exception>
/// <exception cref="System.ArgumentException">The stream does not support write operations such as compression. (The <see cref="System.IO.Stream.CanWrite" /> property on the stream object is <see langword="false" />.)</exception>
public DeflateStream(Stream stream, CompressionLevel compressionLevel) : this(stream, compressionLevel, leaveOpen: false)
Copy link
Member Author

Choose a reason for hiding this comment

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

Double slash comments should probably stay, but I'll move them here:

Suggested change
public DeflateStream(Stream stream, CompressionLevel compressionLevel) : this(stream, compressionLevel, leaveOpen: false)
// Implies mode = Compress
public DeflateStream(Stream stream, CompressionLevel compressionLevel) : this(stream, compressionLevel, leaveOpen: false)

/// [!INCLUDE[remarks](~/includes/remarks/System.IO.Compression/DeflateStream/.ctor_Stream_CompressionLevel_Boolean.md)]
/// ]]></format></remarks>
/// <exception cref="System.ArgumentNullException"><paramref name="stream" /> is <see langword="null" />.</exception>
/// <exception cref="System.ArgumentException">The stream does not support write operations such as compression. (The <see cref="System.IO.Stream.CanWrite" /> property on the stream object is <see langword="false" />.)</exception>
public DeflateStream(Stream stream, CompressionLevel compressionLevel, bool leaveOpen) : this(stream, compressionLevel, leaveOpen, ZLibNative.Deflate_DefaultWindowBits)
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
public DeflateStream(Stream stream, CompressionLevel compressionLevel, bool leaveOpen) : this(stream, compressionLevel, leaveOpen, ZLibNative.Deflate_DefaultWindowBits)
// Implies mode = Compress
public DeflateStream(Stream stream, CompressionLevel compressionLevel, bool leaveOpen) : this(stream, compressionLevel, leaveOpen, ZLibNative.Deflate_DefaultWindowBits)

/// <param name="buffer">A region of memory. When this method returns, the contents of this region are replaced by the bytes read from the current source.</param>
/// <returns>The total number of bytes read into the buffer. This can be less than the number of bytes allocated in the buffer if that many bytes are not currently available, or zero (0) if the end of the stream has been reached.</returns>
/// <remarks>Use the <see cref="System.IO.Compression.DeflateStream.CanRead" /> property to determine whether the current instance supports reading. Use the <see cref="O:System.IO.Compression.DeflateStream.ReadAsync" /> method to read asynchronously from the current stream.
/// This method read a maximum of `buffer.Length` bytes from the current stream and store them in <paramref name="buffer" />. The current position within the Deflate stream is advanced by the number of bytes read; however, if an exception occurs, the current position within the Deflate stream remains unchanged. This method will block until at least one byte of data can be read, in the event that no data is available. `Read` returns 0 only when there is no more data in the stream and no more is expected (such as a closed socket or end of file). The method is free to return fewer bytes than requested even if the end of the stream has not been reached.
Copy link
Member Author

Choose a reason for hiding this comment

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

Need to double check the cref on VS for the Span argument:

Suggested change
/// This method read a maximum of `buffer.Length` bytes from the current stream and store them in <paramref name="buffer" />. The current position within the Deflate stream is advanced by the number of bytes read; however, if an exception occurs, the current position within the Deflate stream remains unchanged. This method will block until at least one byte of data can be read, in the event that no data is available. `Read` returns 0 only when there is no more data in the stream and no more is expected (such as a closed socket or end of file). The method is free to return fewer bytes than requested even if the end of the stream has not been reached.
/// This method read a maximum of <c>buffer.Length</c> bytes from the current stream and store them in <paramref name="buffer" />. The current position within the Deflate stream is advanced by the number of bytes read; however, if an exception occurs, the current position within the Deflate stream remains unchanged. This method will block until at least one byte of data can be read, in the event that no data is available. <see cref="System.IO.Compression.DeflateStream.Read(System.Span<System.Byte>)" /> returns 0 only when there is no more data in the stream and no more is expected (such as a closed socket or end of file). The method is free to return fewer bytes than requested even if the end of the stream has not been reached.

/// <param name="count">The maximum number of bytes to read.</param>
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="System.Threading.CancellationToken.None" />.</param>
/// <returns>A task that represents the asynchronous read operation, which wraps the total number of bytes read into the <paramref name="buffer" />. The result value can be less than the number of bytes requested if the number of bytes currently available is less than the requested number, or it can be 0 (zero) if the end of the Deflate stream has been reached.</returns>
/// <remarks>The `ReadAsync` method enables you to perform resource-intensive I/O operations without blocking the main thread. This performance consideration is particularly important in a Windows 8.x Store app or desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. The async methods are used in conjunction with the <see langword="async" /> and <see langword="await" /> keywords in Visual Basic and C#.
Copy link
Member Author

Choose a reason for hiding this comment

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

Need to double check the cref signature in VS:

Suggested change
/// <remarks>The `ReadAsync` method enables you to perform resource-intensive I/O operations without blocking the main thread. This performance consideration is particularly important in a Windows 8.x Store app or desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. The async methods are used in conjunction with the <see langword="async" /> and <see langword="await" /> keywords in Visual Basic and C#.
/// <remarks>The <see cref="System.IO.Compression.DeflateStream.ReadAsync(System.Byte[],System.Int32,System.Int32,System.Threading.CancellationToken)" /> method enables you to perform resource-intensive I/O operations without blocking the main thread. This performance consideration is particularly important in a Windows 8.x Store app or desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. The asynchronous methods are used in conjunction with the <see langword="async" /> and <see langword="await" /> keywords in Visual Basic and C#.

/// <param name="buffer">The region of memory to write the data into.</param>
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="System.Threading.CancellationToken.None" />.</param>
/// <returns>A task that represents the asynchronous read operation, which wraps the total number of bytes read into the buffer. The result value can be less than the number of bytes allocated in the buffer if that many bytes are not currently available, or it can be 0 (zero) if the end of the Deflate stream has been reached.</returns>
/// <remarks>The `ReadAsync` method enables you to perform resource-intensive I/O operations without blocking the main thread. This performance consideration is particularly important in a Windows 8.x Store app or desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. The async methods are used in conjunction with the <see langword="async" /> and <see langword="await" /> keywords in Visual Basic and C#.
Copy link
Member Author

Choose a reason for hiding this comment

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

Need to double check the signature:

Suggested change
/// <remarks>The `ReadAsync` method enables you to perform resource-intensive I/O operations without blocking the main thread. This performance consideration is particularly important in a Windows 8.x Store app or desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. The async methods are used in conjunction with the <see langword="async" /> and <see langword="await" /> keywords in Visual Basic and C#.
/// <remarks>The <see cref="System.IO.Compression.DeflateStream.ReadAsync(System.Memory<System.Byte>,System.Threading.CancellationToken)" /> method enables you to perform resource-intensive I/O operations without blocking the main thread. This performance consideration is particularly important in a Windows 8.x Store app or desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. The asynchronous methods are used in conjunction with the <see langword="async" /> and <see langword="await" /> keywords in Visual Basic and C#.

Comment on lines +835 to +837
/// <remarks>The `DisposeAsync` method enables you to perform a resource-intensive dispose operation without blocking the main thread. This performance consideration is particularly important in a Windows 8.x Store app or desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. The async methods are used in conjunction with the <see langword="async" /> and <see langword="await" /> keywords in Visual Basic and C#.
/// This method disposes the Deflate stream by writing any changes to the backing store and closing the stream to release resources.
/// Calling `DisposeAsync` allows the resources used by the <see cref="System.IO.Compression.DeflateStream" /> to be reallocated for other purposes. For more information, see [Cleaning Up Unmanaged Resources](/dotnet/standard/garbage-collection/unmanaged).</remarks>
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
/// <remarks>The `DisposeAsync` method enables you to perform a resource-intensive dispose operation without blocking the main thread. This performance consideration is particularly important in a Windows 8.x Store app or desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. The async methods are used in conjunction with the <see langword="async" /> and <see langword="await" /> keywords in Visual Basic and C#.
/// This method disposes the Deflate stream by writing any changes to the backing store and closing the stream to release resources.
/// Calling `DisposeAsync` allows the resources used by the <see cref="System.IO.Compression.DeflateStream" /> to be reallocated for other purposes. For more information, see [Cleaning Up Unmanaged Resources](/dotnet/standard/garbage-collection/unmanaged).</remarks>
/// <remarks>The <see cref="System.IO.Compression.DeflateStream.DisposeAsync()" /> method enables you to perform a resource-intensive dispose operation without blocking the main thread. This performance consideration is particularly important in a Windows 8.x Store app or desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. The async methods are used in conjunction with the <see langword="async" /> and <see langword="await" /> keywords in Visual Basic and C#.
/// This method disposes the Deflate stream by writing any changes to the backing store and closing the stream to release resources.
/// Calling <see cref="System.IO.Compression.DeflateStream.DisposeAsync()" /> allows the resources used by the <see cref="System.IO.Compression.DeflateStream" /> to be reallocated for other purposes. For more information, see [Cleaning Up Unmanaged Resources](/dotnet/standard/garbage-collection/unmanaged).</remarks>

/// <param name="count">The maximum number of bytes to write.</param>
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="System.Threading.CancellationToken.None" />.</param>
/// <returns>A task that represents the asynchronous write operation.</returns>
/// <remarks>The `WriteAsync` method enables you to perform resource-intensive I/O operations without blocking the main thread. This performance consideration is particularly important in a Windows 8.x Store app or desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. The async methods are used in conjunction with the <see langword="async" /> and <see langword="await" /> keywords in Visual Basic and C#.
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
/// <remarks>The `WriteAsync` method enables you to perform resource-intensive I/O operations without blocking the main thread. This performance consideration is particularly important in a Windows 8.x Store app or desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. The async methods are used in conjunction with the <see langword="async" /> and <see langword="await" /> keywords in Visual Basic and C#.
/// <remarks>The <see cref="System.IO.Compression.DeflateStream.WriteAsync(System.Byte[],System.Int32,System.Int32,System.Threading.CancellationToken)" /> method enables you to perform resource-intensive I/O operations without blocking the main thread. This performance consideration is particularly important in a Windows 8.x Store app or desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. The asynchronous methods are used in conjunction with the <see langword="async" /> and <see langword="await" /> keywords in Visual Basic and C#.

/// <param name="buffer">The region of memory to write data from.</param>
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="System.Threading.CancellationToken.None" />.</param>
/// <returns>A task that represents the asynchronous write operation.</returns>
/// <remarks>The `WriteAsync` method enables you to perform resource-intensive I/O operations without blocking the main thread. This performance consideration is particularly important in a Windows 8.x Store app or desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. The async methods are used in conjunction with the <see langword="async" /> and <see langword="await" /> keywords in Visual Basic and C#.
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
/// <remarks>The `WriteAsync` method enables you to perform resource-intensive I/O operations without blocking the main thread. This performance consideration is particularly important in a Windows 8.x Store app or desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. The async methods are used in conjunction with the <see langword="async" /> and <see langword="await" /> keywords in Visual Basic and C#.
/// <remarks>The <see cref="System.IO.Compression.DeflateStream.WriteAsync(System.ReadOnlyMemory<System.Byte>,System.Threading.CancellationToken)" /> method enables you to perform resource-intensive I/O operations without blocking the main thread. This performance consideration is particularly important in a Windows 8.x Store app or desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. The asynchronous methods are used in conjunction with the <see langword="async" /> and <see langword="await" /> keywords in Visual Basic and C#.

/// <param name="bufferSize">The size, in bytes, of the buffer. This value must be greater than zero. The default size is 81920.</param>
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="System.Threading.CancellationToken.None" />.</param>
/// <returns>A task that represents the asynchronous copy operation.</returns>
/// <remarks>The `CopyToAsync` method enables you to perform resource-intensive I/O operations without blocking the main thread. This performance consideration is particularly important in a Windows 8.x Store app or desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. The async methods are used in conjunction with the <see langword="async" /> and <see langword="await" /> keywords in Visual Basic and C#.
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
/// <remarks>The `CopyToAsync` method enables you to perform resource-intensive I/O operations without blocking the main thread. This performance consideration is particularly important in a Windows 8.x Store app or desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. The async methods are used in conjunction with the <see langword="async" /> and <see langword="await" /> keywords in Visual Basic and C#.
/// <remarks>The <see cref="System.IO.Compression.DeflateStream.CopyToAsync(System.IO.Stream,System.Int32,System.Threading.CancellationToken)" /> method enables you to perform resource-intensive I/O operations without blocking the main thread. This performance consideration is particularly important in a Windows 8.x Store app or desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. The asynchronous methods are used in conjunction with the <see langword="async" /> and <see langword="await" /> keywords in Visual Basic and C#.

Base automatically changed from master to main March 1, 2021 09:08
// There may or may not be any correspondence with the a possible implementation-specific level-parameter of the deflater.
/// <summary>Specifies values that indicate whether a compression operation emphasizes speed or compression size.</summary>
/// <remarks><format type="text/markdown"><![CDATA[
/// [!INCLUDE[remarks](~/includes/remarks/System.IO.Compression/CompressionLevel/CompressionLevel.md)]
Copy link
Member

@jozkee jozkee Mar 2, 2021

Choose a reason for hiding this comment

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

This link can't be followed from runtime's source... is there a value on porting it? Perhaps you could ignore it and keep the source of truth in dotnet-api-docs.

Copy link
Member

Choose a reason for hiding this comment

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

My understanding from the docs is that we do want to port these links over.

Comment on lines -14 to +12
/// <summary>
/// The compression operation should balance compression speed and output size.
/// </summary>
/// <summary>The compression operation should be optimally compressed, even if the operation takes a longer time to complete.</summary>
Copy link
Member

Choose a reason for hiding this comment

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

Old and new sentences are describing completely different behaviors, do you know if the new one is actually true?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, it seems it should be written as:

/// <summary>The compression operation should be optimally compressed, balancing compression speed and output size.</summary>

/// <remarks>This enumeration is used with the <see cref="System.IO.Compression.GZipStream" /> and <see cref="System.IO.Compression.DeflateStream" /> classes.</remarks>
/// <example>The following code example uses the <see cref="System.IO.Compression.CompressionMode" /> enumeration with the <see cref="System.IO.Compression.GZipStream" /> class to compress and decompress a file.
/// <format type="text/markdown"><![CDATA[
/// [!code-csharp[IO.Compression.GZip1#1](~/samples/snippets/csharp/VS_Snippets_CLR/IO.Compression.GZip1/CS/gziptest.cs#1)]
Copy link
Member

Choose a reason for hiding this comment

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

Same comment as #48841 (comment).

/// The underlying stream does not support reading.</exception>
/// <exception cref="System.ArgumentOutOfRangeException"><paramref name="offset" /> or <paramref name="count" /> is less than zero.
/// -or-
/// <paramref name="buffer" /> length minus the index starting point is less than <paramref name="count" />.</exception>
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like it was renamed in October with 0acbafe#diff-a076647d6d5119e4e3b482835f098318b585fc7fd9cb16116c45395721c61c3d.

What release is that in? And do we need to document it as a breaking change?

Copy link
Member

Choose a reason for hiding this comment

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

@gewarren right, it is a breaking change that is going to ship with 6.0; it seems that the introducing PR #43834 is already tagged with the breaking-change and the needs-breaking-change-doc-created labels.

public GZipStream(Stream stream, CompressionMode mode, bool leaveOpen)
{
_deflateStream = new DeflateStream(stream, mode, leaveOpen, ZLibNative.GZip_DefaultWindowBits);
}

// Implies mode = Compress
Copy link
Member

Choose a reason for hiding this comment

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

Another double-slash comment lost.

public GZipStream(Stream stream, CompressionLevel compressionLevel) : this(stream, compressionLevel, leaveOpen: false)
{
}

// Implies mode = Compress
Copy link
Member

Choose a reason for hiding this comment

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

ditto

/// <summary>Waits for the pending asynchronous read to complete. (Consider using the <see cref="System.IO.Stream.ReadAsync(byte[],int,int)" /> method instead.)</summary>
/// <param name="asyncResult">The reference to the pending asynchronous request to finish.</param>
/// <returns>The number of bytes read from the stream, between 0 (zero) and the number of bytes you requested. <see cref="System.IO.Compression.GZipStream" /> returns 0 only at the end of the stream; otherwise, it blocks until at least one byte is available.</returns>
/// <remarks>Starting with the .NET Framework 4.5, you can perform asynchronous read operations by using the <see cref="O:System.IO.Stream.ReadAsync" /> method. The <see cref="System.IO.Compression.GZipStream.EndRead" /> method is still available in .NET Framework 4.5 to support legacy code; however, you can implement asynchronous I/O operations more easily by using the new async methods. For more information, see <a href="https://docs.microsoft.com/en-us/dotnet/standard/io/asynchronous-file-i-o">Asynchronous File I/O</a>.
Copy link
Member

@jozkee jozkee Mar 2, 2021

Choose a reason for hiding this comment

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

What does the O: in <see cref="O:System.IO.Stream.ReadAsync" /> mean?

Copy link
Member

Choose a reason for hiding this comment

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

It is for referencing an overloaded method. Notes here.

public override void CopyTo(Stream destination, int bufferSize)
{
CheckDeflateStream();
_deflateStream.CopyTo(destination, bufferSize);
}

/// <summary>Releases the unmanaged resources used by the <see cref="System.IO.Compression.GZipStream" /> and optionally releases the managed resources.</summary>
/// <param name="disposing"><see langword="true" /> to release both managed and unmanaged resources; <see langword="false" /> to release only unmanaged resources.</param>
/// <remarks>This method is called by the public <see langword="System.ComponentModel.Component.Dispose" /> method and the <see cref="object.Finalize" /> method. <see langword="System.ComponentModel.Component.Dispose" /> invokes the protected <see cref="System.IO.Compression.GZipStream.Dispose" /> method with the <paramref name="disposing" /> parameter set to <see langword="true" />. <see cref="object.Finalize" /> invokes <see cref="System.IO.Compression.GZipStream.Dispose" /> with <paramref name="disposing" /> set to <see langword="false" />.
Copy link
Member

@jozkee jozkee Mar 2, 2021

Choose a reason for hiding this comment

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

Shouldn't it be <see cref="...Dispose" /> instead of <see langword="...Dispose" />?

Copy link
Member

Choose a reason for hiding this comment

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

You're correct; good catch @jozkee!

Suggested change
/// <remarks>This method is called by the public <see langword="System.ComponentModel.Component.Dispose" /> method and the <see cref="object.Finalize" /> method. <see langword="System.ComponentModel.Component.Dispose" /> invokes the protected <see cref="System.IO.Compression.GZipStream.Dispose" /> method with the <paramref name="disposing" /> parameter set to <see langword="true" />. <see cref="object.Finalize" /> invokes <see cref="System.IO.Compression.GZipStream.Dispose" /> with <paramref name="disposing" /> set to <see langword="false" />.
/// <remarks>This method is called by the public <see cref="System.ComponentModel.Component.Dispose" /> method and the <see cref="object.Finalize" /> method. <see cref="System.ComponentModel.Component.Dispose" /> invokes the protected <see cref="System.IO.Compression.GZipStream.Dispose" /> method with the <paramref name="disposing" /> parameter set to <see langword="true" />. <see cref="object.Finalize" /> invokes <see cref="System.IO.Compression.GZipStream.Dispose" /> with <paramref name="disposing" /> set to <see langword="false" />.

/// <param name="buffer">The region of memory to write the data into.</param>
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="System.Threading.CancellationToken.None" />.</param>
/// <returns>A task that represents the asynchronous read operation, which wraps the total number of bytes read into the buffer. The result value can be less than the number of bytes allocated in the buffer if that many bytes are not currently available, or it can be 0 (zero) if the end of the GZip stream has been reached.</returns>
/// <remarks>The `ReadAsync` method enables you to perform resource-intensive I/O operations without blocking the main thread. This performance consideration is particularly important in a Windows 8.x Store app or desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. The async methods are used in conjunction with the <see langword="async" /> and <see langword="await" /> keywords in Visual Basic and C#.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// <remarks>The `ReadAsync` method enables you to perform resource-intensive I/O operations without blocking the main thread. This performance consideration is particularly important in a Windows 8.x Store app or desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. The async methods are used in conjunction with the <see langword="async" /> and <see langword="await" /> keywords in Visual Basic and C#.
/// <remarks>The <see cref="System.IO.Compression.GZipStream.ReadAsync" /> method enables you to perform resource-intensive I/O operations without blocking the main thread. This performance consideration is particularly important in a Windows 8.x Store app or desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. The async methods are used in conjunction with the <see langword="async" /> and <see langword="await" /> keywords in Visual Basic and C#.

/// <param name="count">The maximum number of bytes to write.</param>
/// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="System.Threading.CancellationToken.None" />.</param>
/// <returns>A task that represents the asynchronous write operation.</returns>
/// <remarks>The `WriteAsync` method enables you to perform resource-intensive I/O operations without blocking the main thread. This performance consideration is particularly important in a Windows 8.x Store app or desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. The async methods are used in conjunction with the <see langword="async" /> and <see langword="await" /> keywords in Visual Basic and C#.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// <remarks>The `WriteAsync` method enables you to perform resource-intensive I/O operations without blocking the main thread. This performance consideration is particularly important in a Windows 8.x Store app or desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. The async methods are used in conjunction with the <see langword="async" /> and <see langword="await" /> keywords in Visual Basic and C#.
/// <remarks>The <see cref="System.IO.Compression.GZipStream.WriteAsync" /> method enables you to perform resource-intensive I/O operations without blocking the main thread. This performance consideration is particularly important in a Windows 8.x Store app or desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. The async methods are used in conjunction with the <see langword="async" /> and <see langword="await" /> keywords in Visual Basic and C#.

Comment on lines -33 to -35
#if DEBUG_FORCE_ZIP64
public bool _forceZip64;
#endif
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't look like something that should be removed in this PR.

Copy link
Member

Choose a reason for hiding this comment

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

Good catch. I've been working on dotnet/api-docs-sync#65, but we'll have to manually fix it here.

/// <param name="stream">The input or output stream.</param>
/// <param name="mode">See the description of the ZipArchiveMode enum. Read requires the stream to support reading, Create requires the stream to support writing, and Update requires the stream to support reading, writing, and seeking.</param>
/// <param name="leaveOpen">true to leave the stream open upon disposing the ZipArchive, otherwise false.</param>
/// <param name="entryNameEncoding">The encoding to use when reading or writing entry names in this ZipArchive.
Copy link
Member

Choose a reason for hiding this comment

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

@@ -211,12 +184,17 @@ public ZipArchive(Stream stream, ZipArchiveMode mode, bool leaveOpen, Encoding?
}
}

/// <summary>
/// The collection of entries that are currently in the ZipArchive. This may not accurately represent the actual entries that are present in the underlying file or stream.
Copy link
Member

Choose a reason for hiding this comment

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

This may not accurately represent the actual entries that are present in the underlying file or stream.

This is not captured anywhere in the documentation page https://docs.microsoft.com/en-us/dotnet/api/system.io.compression.ziparchive.entries?view=net-5.0

@@ -278,13 +297,23 @@ public void Delete()
UnloadStreams();
}

/// <summary>
/// Opens the entry. If the archive that the entry belongs to was opened in Read mode, the returned stream will be readable, and it may or may not be seekable. If Create mode, the returned stream will be writable and not seekable. If Update mode, the returned stream will be readable, writable, seekable, and support SetLength.
Copy link
Member

Choose a reason for hiding this comment

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

If the archive that the entry belongs to was opened in Read mode, the returned stream will be readable, and it may or may not be seekable. If Create mode, the returned stream will be writable and not seekable. If Update mode, the returned stream will be readable, writable, seekable, and support SetLength.

Consider adding this to https://docs.microsoft.com/en-us/dotnet/api/system.io.compression.ziparchiveentry.open?view=net-5.0.

Copy link
Member

@jozkee jozkee left a comment

Choose a reason for hiding this comment

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

Otherwise; LGTM.

@@ -3,9 +3,18 @@

namespace System.IO.Compression
{
/// <summary>Specifies whether to compress or decompress the underlying stream.</summary>
/// <remarks>This enumeration is used with the <see cref="System.IO.Compression.GZipStream" /> and <see cref="System.IO.Compression.DeflateStream" /> classes.</remarks>
Copy link
Member

Choose a reason for hiding this comment

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

We should fix the formatting of these tags before running the automation on everything.

Suggested change
/// <remarks>This enumeration is used with the <see cref="System.IO.Compression.GZipStream" /> and <see cref="System.IO.Compression.DeflateStream" /> classes.</remarks>
/// <remarks>This enumeration is used with the <see cref="System.IO.Compression.GZipStream"/> and <see cref="System.IO.Compression.DeflateStream"/> classes.</remarks>

Copy link
Contributor

Choose a reason for hiding this comment

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

We've always had the space character in there in dotnet-api-docs.

Copy link
Member

Choose a reason for hiding this comment

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

VS does not insert the trailing space before the slash. I've wondered if it would be better to be consistent with what VS is going to do. I've opened dotnet/api-docs-sync#73 for that, but we don't need to block this PR on that issue; we can run a revision run to reformat.

Comment on lines +308 to +315
/// <exception cref="System.IO.IOException">The entry is already currently open for writing.
/// -or-
/// The entry has been deleted from the archive.
/// -or-
/// The archive for this entry was opened with the <see cref="System.IO.Compression.ZipArchiveMode.Create" /> mode, and this entry has already been written to.</exception>
/// <exception cref="System.IO.InvalidDataException">The entry is either missing from the archive or is corrupt and cannot be read.
/// -or-
/// The entry has been compressed by using a compression method that is not supported.</exception>
Copy link
Member

Choose a reason for hiding this comment

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

All the required <para> elements are missing

Suggested change
/// <exception cref="System.IO.IOException">The entry is already currently open for writing.
/// -or-
/// The entry has been deleted from the archive.
/// -or-
/// The archive for this entry was opened with the <see cref="System.IO.Compression.ZipArchiveMode.Create" /> mode, and this entry has already been written to.</exception>
/// <exception cref="System.IO.InvalidDataException">The entry is either missing from the archive or is corrupt and cannot be read.
/// -or-
/// The entry has been compressed by using a compression method that is not supported.</exception>
/// <exception cref="System.IO.IOException"><para>The entry is already currently open for writing.</para>
/// <para>-or-</para>
/// <para>The entry has been deleted from the archive.</para>
/// <para>-or-</para>
/// <para>The archive for this entry was opened with the <see cref="System.IO.Compression.ZipArchiveMode.Create" /> mode, and this entry has already been written to.</para></exception>
/// <exception cref="System.IO.InvalidDataException"><para>The entry is either missing from the archive or is corrupt and cannot be read.</para>
/// <para>-or-</para>
/// <para>The entry has been compressed by using a compression method that is not supported.</para></exception>

public override long Position
{
get { throw new NotSupportedException(SR.NotSupported); }
set { throw new NotSupportedException(SR.NotSupported); }
}

/// <summary>The current implementation of this method has no functionality.</summary>
Copy link
Contributor

Choose a reason for hiding this comment

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

The summary doesn't seem correct.

// There may or may not be any correspondence with the a possible implementation-specific level-parameter of the deflater.
/// <summary>Specifies values that indicate whether a compression operation emphasizes speed or compression size.</summary>
/// <remarks><format type="text/markdown"><![CDATA[
/// [!INCLUDE[remarks](~/includes/remarks/System.IO.Compression/CompressionLevel/CompressionLevel.md)]
Copy link
Member

Choose a reason for hiding this comment

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

My understanding from the docs is that we do want to port these links over.

Comment on lines -14 to +12
/// <summary>
/// The compression operation should balance compression speed and output size.
/// </summary>
/// <summary>The compression operation should be optimally compressed, even if the operation takes a longer time to complete.</summary>
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, it seems it should be written as:

/// <summary>The compression operation should be optimally compressed, balancing compression speed and output size.</summary>

@@ -3,9 +3,18 @@

namespace System.IO.Compression
{
/// <summary>Specifies whether to compress or decompress the underlying stream.</summary>
/// <remarks>This enumeration is used with the <see cref="System.IO.Compression.GZipStream" /> and <see cref="System.IO.Compression.DeflateStream" /> classes.</remarks>
Copy link
Member

Choose a reason for hiding this comment

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

VS does not insert the trailing space before the slash. I've wondered if it would be better to be consistent with what VS is going to do. I've opened dotnet/api-docs-sync#73 for that, but we don't need to block this PR on that issue; we can run a revision run to reformat.

/// [!code-vb[System.IO.Compression.GZipStream#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.io.compression.gzipstream/vb/program1.vb#1)]
/// ]]></format></example>
/// <exception cref="System.ArgumentNullException"><paramref name="stream" /> is <see langword="null" />.</exception>
/// <exception cref="System.ArgumentException">The stream does not support write operations such as compression. (The <see cref="System.IO.Stream.CanWrite" /> property on the stream object is <see langword="false" />.)</exception>
public GZipStream(Stream stream, CompressionLevel compressionLevel) : this(stream, compressionLevel, leaveOpen: false)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public GZipStream(Stream stream, CompressionLevel compressionLevel) : this(stream, compressionLevel, leaveOpen: false)
// Implies mode = Compress
public GZipStream(Stream stream, CompressionLevel compressionLevel) : this(stream, compressionLevel, leaveOpen: false)

/// [!code-vb[System.IO.Compression.GZipStream#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.io.compression.gzipstream/vb/program2.vb#2)]
/// ]]></format></example>
/// <exception cref="System.ArgumentNullException"><paramref name="stream" /> is <see langword="null" />.</exception>
/// <exception cref="System.ArgumentException">The stream does not support write operations such as compression. (The <see cref="System.IO.Stream.CanWrite" /> property on the stream object is <see langword="false" />.)</exception>
public GZipStream(Stream stream, CompressionLevel compressionLevel, bool leaveOpen)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public GZipStream(Stream stream, CompressionLevel compressionLevel, bool leaveOpen)
// Implies mode = Compress
public GZipStream(Stream stream, CompressionLevel compressionLevel, bool leaveOpen)

/// <summary>Waits for the pending asynchronous read to complete. (Consider using the <see cref="System.IO.Stream.ReadAsync(byte[],int,int)" /> method instead.)</summary>
/// <param name="asyncResult">The reference to the pending asynchronous request to finish.</param>
/// <returns>The number of bytes read from the stream, between 0 (zero) and the number of bytes you requested. <see cref="System.IO.Compression.GZipStream" /> returns 0 only at the end of the stream; otherwise, it blocks until at least one byte is available.</returns>
/// <remarks>Starting with the .NET Framework 4.5, you can perform asynchronous read operations by using the <see cref="O:System.IO.Stream.ReadAsync" /> method. The <see cref="System.IO.Compression.GZipStream.EndRead" /> method is still available in .NET Framework 4.5 to support legacy code; however, you can implement asynchronous I/O operations more easily by using the new async methods. For more information, see <a href="https://docs.microsoft.com/en-us/dotnet/standard/io/asynchronous-file-i-o">Asynchronous File I/O</a>.
Copy link
Member

Choose a reason for hiding this comment

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

It is for referencing an overloaded method. Notes here.

public override void CopyTo(Stream destination, int bufferSize)
{
CheckDeflateStream();
_deflateStream.CopyTo(destination, bufferSize);
}

/// <summary>Releases the unmanaged resources used by the <see cref="System.IO.Compression.GZipStream" /> and optionally releases the managed resources.</summary>
/// <param name="disposing"><see langword="true" /> to release both managed and unmanaged resources; <see langword="false" /> to release only unmanaged resources.</param>
/// <remarks>This method is called by the public <see langword="System.ComponentModel.Component.Dispose" /> method and the <see cref="object.Finalize" /> method. <see langword="System.ComponentModel.Component.Dispose" /> invokes the protected <see cref="System.IO.Compression.GZipStream.Dispose" /> method with the <paramref name="disposing" /> parameter set to <see langword="true" />. <see cref="object.Finalize" /> invokes <see cref="System.IO.Compression.GZipStream.Dispose" /> with <paramref name="disposing" /> set to <see langword="false" />.
Copy link
Member

Choose a reason for hiding this comment

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

You're correct; good catch @jozkee!

Suggested change
/// <remarks>This method is called by the public <see langword="System.ComponentModel.Component.Dispose" /> method and the <see cref="object.Finalize" /> method. <see langword="System.ComponentModel.Component.Dispose" /> invokes the protected <see cref="System.IO.Compression.GZipStream.Dispose" /> method with the <paramref name="disposing" /> parameter set to <see langword="true" />. <see cref="object.Finalize" /> invokes <see cref="System.IO.Compression.GZipStream.Dispose" /> with <paramref name="disposing" /> set to <see langword="false" />.
/// <remarks>This method is called by the public <see cref="System.ComponentModel.Component.Dispose" /> method and the <see cref="object.Finalize" /> method. <see cref="System.ComponentModel.Component.Dispose" /> invokes the protected <see cref="System.IO.Compression.GZipStream.Dispose" /> method with the <paramref name="disposing" /> parameter set to <see langword="true" />. <see cref="object.Finalize" /> invokes <see cref="System.IO.Compression.GZipStream.Dispose" /> with <paramref name="disposing" /> set to <see langword="false" />.

Comment on lines -33 to -35
#if DEBUG_FORCE_ZIP64
public bool _forceZip64;
#endif
Copy link
Member

Choose a reason for hiding this comment

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

Good catch. I've been working on dotnet/api-docs-sync#65, but we'll have to manually fix it here.

/// <exception cref="ArgumentNullException">The stream is null.</exception>
/// <exception cref="InvalidDataException">The contents of the stream could not be interpreted as a Zip archive.</exception>
/// <param name="stream">The stream containing the archive to be read.</param>
/// <summary>Initializes a new instance of the <see cref="System.IO.Compression.ZipArchive" /> class from the specified stream.</summary>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// <summary>Initializes a new instance of the <see cref="System.IO.Compression.ZipArchive" /> class from the specified stream.</summary>
#if DEBUG_FORCE_ZIP64
public bool _forceZip64;
#endif
/// <summary>Initializes a new instance of the <see cref="System.IO.Compression.ZipArchive" /> class from the specified stream.</summary>

@jeffhandley jeffhandley marked this pull request as draft April 18, 2021 06:36
@ghost ghost closed this May 18, 2021
@ghost
Copy link

ghost commented May 18, 2021

Draft Pull Request was automatically closed for inactivity. Please let us know if you'd like to reopen it.

@ghost ghost locked as resolved and limited conversation to collaborators Jun 17, 2021
@carlossanlop carlossanlop deleted the BackportCompression branch February 7, 2024 06:42
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.IO.Compression documentation Documentation bug or enhancement, does not impact product or test code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

System.IO.Compression: Backport MS Docs documentation to triple slash
5 participants