Skip to content

Commit 6153a91

Browse files
carlossanlopRon Petrusha
andcommitted
Manually document System.IO.BufferedStream (#2770)
* Manually document System.IO.BufferedStream * suggestions by rpetrusha Co-Authored-By: Ron Petrusha <[email protected]>
1 parent e5fe7e6 commit 6153a91

File tree

1 file changed

+137
-38
lines changed

1 file changed

+137
-38
lines changed

xml/System.IO/BufferedStream.xml

Lines changed: 137 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@
355355
<ReturnType>System.Int32</ReturnType>
356356
</ReturnValue>
357357
<Docs>
358-
<summary>To be added.</summary>
359-
<value>To be added.</value>
358+
<summary>Gets the buffer size in bytes for this buffered stream.</summary>
359+
<value>An integer representing the buffer size in bytes.</value>
360360
<remarks>To be added.</remarks>
361361
</Docs>
362362
</Member>
@@ -647,10 +647,19 @@ bufStream->Close();
647647
<Parameter Name="bufferSize" Type="System.Int32" Index="1" FrameworkAlternate="netcore-3.0" />
648648
</Parameters>
649649
<Docs>
650-
<param name="destination">To be added.</param>
651-
<param name="bufferSize">To be added.</param>
652-
<summary>To be added.</summary>
650+
<param name="destination">The stream to which the contents of the current buffered stream will be copied.</param>
651+
<param name="bufferSize">The size of the buffer. This value must be greater than zero. The default size is 81920.</param>
652+
<summary>Reads the bytes from the current buffered stream and writes them to another stream.</summary>
653653
<remarks>To be added.</remarks>
654+
<exception cref="T:System.ArgumentNullException"><paramref name="destination" /> is <see langword="null" />.</exception>
655+
<exception cref="T:System.ArgumentOutOfRangeException"><paramref name="bufferSize" /> is negative or zero.</exception>
656+
<exception cref="T:System.NotSupportedException">The current stream does not support reading.
657+
658+
-or-
659+
660+
<paramref name="destination" /> does not support writing.</exception>
661+
<exception cref="T:System.ObjectDisposedException">Either the current stream or <paramref name="destination" /> was closed before the <see cref="M:System.IO.Stream.CopyTo(System.IO.Stream)" /> method was called.</exception>
662+
<exception cref="T:System.IO.IOException">An I/O error occurred.</exception>
654663
</Docs>
655664
</Member>
656665
<Member MemberName="CopyToAsync">
@@ -682,12 +691,24 @@ bufStream->Close();
682691
<Parameter Name="cancellationToken" Type="System.Threading.CancellationToken" Index="2" FrameworkAlternate="netcore-3.0" />
683692
</Parameters>
684693
<Docs>
685-
<param name="destination">To be added.</param>
686-
<param name="bufferSize">To be added.</param>
687-
<param name="cancellationToken">To be added.</param>
688-
<summary>To be added.</summary>
689-
<returns>To be added.</returns>
690-
<remarks>To be added.</remarks>
694+
<param name="destination">The stream to which the contents of the current buffered stream will be copied.</param>
695+
<param name="bufferSize">The size, in bytes, of the buffer. This value must be greater than zero. The default sizer is 81920.</param>
696+
<param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None" />.</param>
697+
<summary>Asynchronously reads the bytes from the current buffered stream and writes them to another stream, using a specified buffer size and cancellation token.</summary>
698+
<returns>A task that represents the asynchronous copy operation.</returns>
699+
<remarks>
700+
<format type="text/markdown"><![CDATA[
701+
702+
## Remarks
703+
704+
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 [!INCLUDE[win8_appname_long](~/includes/win8-appname-long-md.md)] app or [!INCLUDE[desktop_appname](~/includes/desktop-appname-md.md)] 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 `async` and `await` keywords in Visual Basic and C#.
705+
706+
If the operation is canceled before it completes, the returned task contains the <xref:System.Threading.Tasks.TaskStatus.Canceled> value for the <xref:System.Threading.Tasks.Task.Status%2A> property.
707+
708+
Copying begins at the current position in the current stream.
709+
710+
]]></format>
711+
</remarks>
691712
</Docs>
692713
</Member>
693714
<Member MemberName="Dispose">
@@ -725,9 +746,21 @@ bufStream->Close();
725746
<Parameter Name="disposing" Type="System.Boolean" Index="0" FrameworkAlternate="netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netstandard-1.5;netstandard-1.6;netstandard-2.0;netstandard-2.1;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0" />
726747
</Parameters>
727748
<Docs>
728-
<param name="disposing">To be added.</param>
729-
<summary>To be added.</summary>
730-
<remarks>To be added.</remarks>
749+
<param name="disposing"><see langword="true" /> to release both managed and unmanaged resources; <see langword="false" /> to release only unmanaged resources.</param>
750+
<summary>Releases the unmanaged resources used by the buffered stream and optionally releases the managed resources.</summary>
751+
<remarks>
752+
<format type="text/markdown"><![CDATA[
753+
754+
## Remarks
755+
756+
You should release all resources by specifying `true` for `disposing`. When `disposing` is `true`, the stream can also ensure data is flushed to the underlying buffer, and access other finalizable objects. This may not be possible when called from a finalizer due a lack of ordering among finalizers.
757+
758+
If your stream is using an operating system handle to communicate with its source, consider using a subclass of <xref:System.Runtime.InteropServices.SafeHandle> for this purpose.
759+
760+
This method is called by the public <xref:System.ComponentModel.Component.Dispose> method and the <xref:System.Object.Finalize%2A> method. <xref:System.ComponentModel.Component.Dispose> invokes the protected `Dispose(Boolean)` method with the `disposing` parameter set to `true`. <xref:System.Object.Finalize%2A> invokes `Dispose(Boolean)` with `disposing` set to `false`.
761+
762+
]]></format>
763+
</remarks>
731764
</Docs>
732765
</Member>
733766
<Member MemberName="DisposeAsync">
@@ -757,9 +790,21 @@ bufStream->Close();
757790
</ReturnValue>
758791
<Parameters />
759792
<Docs>
760-
<summary>To be added.</summary>
761-
<returns>To be added.</returns>
762-
<remarks>To be added.</remarks>
793+
<summary>Asynchronously releases the unmanaged resources used by the buffered stream.</summary>
794+
<returns>A task that represents the asynchronous dispose operation.</returns>
795+
<remarks>
796+
<format type="text/markdown"><![CDATA[
797+
798+
## Remarks
799+
800+
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 [!INCLUDE[win8_appname_long](~/includes/win8-appname-long-md.md)] app or [!INCLUDE[desktop_appname](~/includes/desktop-appname-md.md)] 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 `async` and `await` keywords in Visual Basic and C#.
801+
802+
This method disposes the stream by writing any changes to the backing store and closing the stream to release resources.
803+
804+
Calling `DisposeAsync` allows the resources used by the <xref:System.IO.BufferedStream> to be reallocated for other purposes. For more information, see [Cleaning Up Unmanaged Resources](~/docs/standard/garbage-collection/unmanaged.md).
805+
806+
]]></format>
807+
</remarks>
763808
</Docs>
764809
</Member>
765810
<Member MemberName="EndRead">
@@ -1097,10 +1142,22 @@ bufStream->Close();
10971142
<Parameter Name="destination" Type="System.Span&lt;System.Byte&gt;" Index="0" FrameworkAlternate="netcore-3.0" />
10981143
</Parameters>
10991144
<Docs>
1100-
<param name="destination">To be added.</param>
1101-
<summary>To be added.</summary>
1102-
<returns>To be added.</returns>
1103-
<remarks>To be added.</remarks>
1145+
<param name="destination">A region of memory. When this method returns, the contents of this region are replaced by the bytes read from the current source.</param>
1146+
<summary>Copies bytes from the current buffered stream to a byte span and advances the position within the buffered stream by the number of bytes read.</summary>
1147+
<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>
1148+
<remarks>
1149+
<format type="text/markdown"><![CDATA[
1150+
1151+
## Remarks
1152+
1153+
Use the <xref:System.IO.BufferedStream.CanRead%2A> property to determine whether the current instance supports reading. Use the <xref:System.IO.BufferedStream.ReadAsync%2A> method to read asynchronously from the current stream.
1154+
1155+
Implementations of this method read a maximum of `buffer.Length` bytes from the current stream and store them in `buffer`. The current position within the stream is advanced by the number of bytes read; however, if an exception occurs, the current position within the stream remains unchanged. Implementations return the number of bytes read. The implementation 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). An implementation is free to return fewer bytes than requested even if the end of the stream has not been reached.
1156+
1157+
Use <xref:System.IO.BinaryReader> for reading primitive data types.
1158+
1159+
]]></format>
1160+
</remarks>
11041161
</Docs>
11051162
</Member>
11061163
<Member MemberName="Read">
@@ -1213,11 +1270,23 @@ bufStream->Close();
12131270
<Parameter Name="cancellationToken" Type="System.Threading.CancellationToken" Index="1" FrameworkAlternate="netcore-3.0" />
12141271
</Parameters>
12151272
<Docs>
1216-
<param name="buffer">To be added.</param>
1217-
<param name="cancellationToken">To be added.</param>
1218-
<summary>To be added.</summary>
1219-
<returns>To be added.</returns>
1220-
<remarks>To be added.</remarks>
1273+
<param name="buffer">The region of memory to write the data into.</param>
1274+
<param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None" />.</param>
1275+
<summary>Asynchronously reads a sequence of bytes from the current buffered stream and advances the position within the buffered stream by the number of bytes read.</summary>
1276+
<returns>A task that represents the asynchronous read operation. The value of its <see cref="P:System.Threading.Tasks.ValueTask`1.Result" /> property contains 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 stream has been reached.</returns>
1277+
<remarks>
1278+
<format type="text/markdown"><![CDATA[
1279+
1280+
## Remarks
1281+
1282+
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 [!INCLUDE[win8_appname_long](~/includes/win8-appname-long-md.md)] app or [!INCLUDE[desktop_appname](~/includes/desktop-appname-md.md)] 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 `async` and `await` keywords in Visual Basic and C#.
1283+
1284+
Use the <xref:System.IO.BufferedStream.CanRead%2A> property to determine whether the current instance supports reading.
1285+
1286+
If the operation is canceled before it completes, the returned task contains the <xref:System.Threading.Tasks.TaskStatus.Canceled?displayProperty=nameWithType> value for the <xref:System.Threading.Tasks.Task.Status> property.
1287+
1288+
]]></format>
1289+
</remarks>
12211290
</Docs>
12221291
</Member>
12231292
<Member MemberName="ReadAsync">
@@ -1483,8 +1552,8 @@ bufStream->Close();
14831552
<ReturnType>System.IO.Stream</ReturnType>
14841553
</ReturnValue>
14851554
<Docs>
1486-
<summary>To be added.</summary>
1487-
<value>To be added.</value>
1555+
<summary>Gets the underlying <see cref="T:System.IO.Stream" /> instance for this buffered stream.</summary>
1556+
<value>The underlying stream instance.</value>
14881557
<remarks>To be added.</remarks>
14891558
</Docs>
14901559
</Member>
@@ -1516,9 +1585,19 @@ bufStream->Close();
15161585
<Parameter Name="buffer" Type="System.ReadOnlySpan&lt;System.Byte&gt;" Index="0" FrameworkAlternate="netcore-3.0" />
15171586
</Parameters>
15181587
<Docs>
1519-
<param name="buffer">To be added.</param>
1520-
<summary>To be added.</summary>
1521-
<remarks>To be added.</remarks>
1588+
<param name="buffer">A region of memory. This method copies the contents of this region to the current buffered stream.</param>
1589+
<summary>Writes a sequence of bytes to the current buffered stream and advances the current position within this buffered stream by the number of bytes written.</summary>
1590+
<remarks>
1591+
<format type="text/markdown"><![CDATA[
1592+
1593+
## Remarks
1594+
1595+
Use the <xref:System.IO.BufferedStream.CanWrite%2A> property to determine whether the current instance supports writing. Use the <xref:System.IO.BufferedStream.WriteAsync%2A> method to write asynchronously to the current buffered stream.
1596+
1597+
If the write operation is successful, the position within the buffered stream advances by the number of bytes written. If an exception occurs, the position within the buffered stream remains unchanged.
1598+
1599+
]]></format>
1600+
</remarks>
15221601
</Docs>
15231602
</Member>
15241603
<Member MemberName="Write">
@@ -1622,11 +1701,23 @@ bufStream->Close();
16221701
<Parameter Name="cancellationToken" Type="System.Threading.CancellationToken" Index="1" FrameworkAlternate="netcore-3.0" />
16231702
</Parameters>
16241703
<Docs>
1625-
<param name="buffer">To be added.</param>
1626-
<param name="cancellationToken">To be added.</param>
1627-
<summary>To be added.</summary>
1628-
<returns>To be added.</returns>
1629-
<remarks>To be added.</remarks>
1704+
<param name="buffer">The region of memory to write data from.</param>
1705+
<param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None" />.</param>
1706+
<summary>Asynchronously writes a sequence of bytes to the current buffered stream, advances the current position within this buffered stream by the number of bytes written, and monitors cancellation requests.</summary>
1707+
<returns>A task that represents the asynchronous write operation.</returns>
1708+
<remarks>
1709+
<format type="text/markdown"><![CDATA[
1710+
1711+
## Remarks
1712+
1713+
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 [!INCLUDE[win8_appname_long](~/includes/win8-appname-long-md.md)] app or [!INCLUDE[desktop_appname](~/includes/desktop-appname-md.md)] 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 `async` and `await` keywords in Visual Basic and C#.
1714+
1715+
Use the <xref:System.IO.BufferedStream.CanWrite%2A> property to determine whether the current instance supports writing.
1716+
1717+
If the operation is canceled before it completes, the returned task contains the <xref:System.Threading.Tasks.TaskStatus.Canceled?displayProperty=nameWithType> value for the <xref:System.Threading.Tasks.Task.Status%2A?displayProperty=nameWithType> property.
1718+
1719+
]]></format>
1720+
</remarks>
16301721
</Docs>
16311722
</Member>
16321723
<Member MemberName="WriteAsync">
@@ -1727,7 +1818,15 @@ bufStream->Close();
17271818
<Docs>
17281819
<param name="value">A byte to write to the stream.</param>
17291820
<summary>Writes a byte to the current position in the buffered stream.</summary>
1730-
<remarks>To be added.</remarks>
1821+
<remarks>
1822+
<format type="text/markdown"><![CDATA[
1823+
1824+
## Remarks
1825+
1826+
Use the <xref:System.IO.BufferedStream.CanWrite%2A> property to determine whether the current instance supports writing.
1827+
1828+
]]></format>
1829+
</remarks>
17311830
<exception cref="T:System.NotSupportedException">The stream does not support writing.</exception>
17321831
<exception cref="T:System.ArgumentNullException">
17331832
<paramref name="value" /> is <see langword="null" />.</exception>
@@ -1738,4 +1837,4 @@ bufStream->Close();
17381837
</Docs>
17391838
</Member>
17401839
</Members>
1741-
</Type>
1840+
</Type>

0 commit comments

Comments
 (0)