Skip to content

Commit b3195ef

Browse files
MSDN-WhiteKnightRon Petrusha
authored andcommitted
Improve System.IO.Stream documentation (#2524)
* Update Stream.xml Add missing method details for System.IO.Stream. * Apply suggestions from code review Co-Authored-By: Ron Petrusha <[email protected]> * Fixed bad xref.
1 parent 2a60907 commit b3195ef

File tree

1 file changed

+94
-26
lines changed

1 file changed

+94
-26
lines changed

xml/System.IO/Stream.xml

Lines changed: 94 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -895,11 +895,22 @@
895895
<Parameter Name="cancellationToken" Type="System.Threading.CancellationToken" Index="1" FrameworkAlternate="netcore-2.1;netcore-2.2;netcore-3.0;netstandard-2.1" />
896896
</Parameters>
897897
<Docs>
898-
<param name="destination">To be added.</param>
899-
<param name="cancellationToken">To be added.</param>
900-
<summary>To be added.</summary>
901-
<returns>To be added.</returns>
902-
<remarks>To be added.</remarks>
898+
<param name="destination">The stream to which the contents of the current stream will be copied.</param>
899+
<param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None" />.</param>
900+
<summary>Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified cancellation token.</summary>
901+
<returns>A task that represents the asynchronous copy operation.</returns>
902+
<remarks><format type="text/markdown"><![CDATA[
903+
904+
## Remarks
905+
The <xref:System.IO.Stream.CopyToAsync%2A> 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#.
906+
907+
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.
908+
909+
Copying begins at the current position in the current stream.
910+
911+
For an example of copying between two streams, see the <xref:System.IO.Stream.CopyToAsync%28System.IO.Stream%29> overload.
912+
913+
]]></format></remarks>
903914
</Docs>
904915
</Member>
905916
<Member MemberName="CopyToAsync">
@@ -1184,9 +1195,20 @@
11841195
</ReturnValue>
11851196
<Parameters />
11861197
<Docs>
1187-
<summary>To be added.</summary>
1188-
<returns>To be added.</returns>
1189-
<remarks>To be added.</remarks>
1198+
<summary>Asynchronously releases the unmanaged resources used by the <see cref="T:System.IO.Stream" />.</summary>
1199+
<returns>A task that represents the asynchronous dispose operation.</returns>
1200+
<remarks>
1201+
<format type="text/markdown"><![CDATA[
1202+
1203+
## Remarks
1204+
The <xref:System.IO.Stream.DisposeAsync%2A> 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#.
1205+
1206+
This method disposes the stream by writing any changes to the backing store and closing the stream to release resources.
1207+
1208+
Calling `DisposeAsync` allows the resources used by the <xref:System.IO.Stream> to be reallocated for other purposes. For more information, see [Cleaning Up Unmanaged Resources](~/docs/standard/garbage-collection/unmanaged.md).
1209+
1210+
]]></format>
1211+
</remarks>
11901212
</Docs>
11911213
</Member>
11921214
<Member MemberName="EndRead">
@@ -1717,10 +1739,21 @@
17171739
<Parameter Name="buffer" Type="System.Span&lt;System.Byte&gt;" Index="0" FrameworkAlternate="netcore-2.1;netcore-2.2;netcore-3.0;netstandard-2.1" />
17181740
</Parameters>
17191741
<Docs>
1720-
<param name="buffer">To be added.</param>
1721-
<summary>To be added.</summary>
1722-
<returns>To be added.</returns>
1723-
<remarks>To be added.</remarks>
1742+
<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>
1743+
<summary>When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.</summary>
1744+
<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>
1745+
<remarks>
1746+
<format type="text/markdown"><![CDATA[
1747+
1748+
## Remarks
1749+
Use the <xref:System.IO.Stream.CanRead%2A> property to determine whether the current instance supports reading. Use the <xref:System.IO.Stream.ReadAsync%2A> method to read asynchronously from the current stream.
1750+
1751+
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. <xref:System.IO.Stream.Read%2A> 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.
1752+
1753+
Use <xref:System.IO.BinaryReader> for reading primitive data types.
1754+
1755+
]]></format>
1756+
</remarks>
17241757
</Docs>
17251758
</Member>
17261759
<Member MemberName="Read">
@@ -1841,11 +1874,24 @@
18411874
<Parameter Name="cancellationToken" Type="System.Threading.CancellationToken" Index="1" FrameworkAlternate="netcore-2.1;netcore-2.2;netcore-3.0;netstandard-2.1" />
18421875
</Parameters>
18431876
<Docs>
1844-
<param name="buffer">To be added.</param>
1845-
<param name="cancellationToken">To be added.</param>
1846-
<summary>To be added.</summary>
1847-
<returns>To be added.</returns>
1848-
<remarks>To be added.</remarks>
1877+
<param name="buffer">The region of memory to write the data into.</param>
1878+
<param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None" />.</param>
1879+
<summary>Asynchronously reads a sequence of bytes from the current stream, advances the position within the stream by the number of bytes read, and monitors cancellation requests.</summary>
1880+
<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>
1881+
<remarks>
1882+
<format type="text/markdown"><![CDATA[
1883+
1884+
## Remarks
1885+
The <xref:System.IO.Stream.ReadAsync%2A> 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#.
1886+
1887+
Use the <xref:System.IO.Stream.CanRead%2A> property to determine whether the current instance supports reading.
1888+
1889+
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.
1890+
1891+
For an example, see the <xref:System.IO.Stream.ReadAsync%28System.Byte%5B%5D%2CSystem.Int32%2CSystem.Int32%29> overload.
1892+
1893+
]]></format>
1894+
</remarks>
18491895
</Docs>
18501896
</Member>
18511897
<Member MemberName="ReadAsync">
@@ -2350,9 +2396,18 @@ This member is an explicit interface member implementation. It can be used only
23502396
<Parameter Name="buffer" Type="System.ReadOnlySpan&lt;System.Byte&gt;" Index="0" FrameworkAlternate="netcore-2.1;netcore-2.2;netcore-3.0;netstandard-2.1" />
23512397
</Parameters>
23522398
<Docs>
2353-
<param name="buffer">To be added.</param>
2354-
<summary>To be added.</summary>
2355-
<remarks>To be added.</remarks>
2399+
<param name="buffer">A region of memory. This method copies the contents of this region to the current stream.</param>
2400+
<summary>When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.</summary>
2401+
<remarks>
2402+
<format type="text/markdown"><![CDATA[
2403+
2404+
## Remarks
2405+
Use the <xref:System.IO.Stream.CanWrite%2A> property to determine whether the current instance supports writing. Use the <xref:System.IO.Stream.WriteAsync%2A> method to write asynchronously to the current stream.
2406+
2407+
If the write operation is successful, the position within the stream advances by the number of bytes written. If an exception occurs, the position within the stream remains unchanged.
2408+
2409+
]]></format>
2410+
</remarks>
23562411
</Docs>
23572412
</Member>
23582413
<Member MemberName="Write">
@@ -2462,11 +2517,24 @@ This member is an explicit interface member implementation. It can be used only
24622517
<Parameter Name="cancellationToken" Type="System.Threading.CancellationToken" Index="1" FrameworkAlternate="netcore-2.1;netcore-2.2;netcore-3.0;netstandard-2.1" />
24632518
</Parameters>
24642519
<Docs>
2465-
<param name="buffer">To be added.</param>
2466-
<param name="cancellationToken">To be added.</param>
2467-
<summary>To be added.</summary>
2468-
<returns>To be added.</returns>
2469-
<remarks>To be added.</remarks>
2520+
<param name="buffer">The region of memory to write data from.</param>
2521+
<param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None" />.</param>
2522+
<summary>Asynchronously writes a sequence of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.</summary>
2523+
<returns>A task that represents the asynchronous write operation.</returns>
2524+
<remarks>
2525+
<format type="text/markdown"><![CDATA[
2526+
2527+
## Remarks
2528+
The <xref:System.IO.Stream.WriteAsync%2A> 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#.
2529+
2530+
Use the <xref:System.IO.Stream.CanWrite%2A> property to determine whether the current instance supports writing.
2531+
2532+
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.
2533+
2534+
For an example, see the <xref:System.IO.Stream.WriteAsync%28System.Byte%5B%5D%2CSystem.Int32%2CSystem.Int32%29> overload.
2535+
2536+
]]></format>
2537+
</remarks>
24702538
</Docs>
24712539
</Member>
24722540
<Member MemberName="WriteAsync">
@@ -2727,4 +2795,4 @@ This member is an explicit interface member implementation. It can be used only
27272795
</Docs>
27282796
</Member>
27292797
</Members>
2730-
</Type>
2798+
</Type>

0 commit comments

Comments
 (0)