Skip to content

Commit 19f8c08

Browse files
bartonjsRon Petrusha
andcommitted
Copy Stream docs to CryptoStream overrides (#2869)
* Copy Stream docs to CryptoStream overrides All content came from System.IO.Stream, with references to members updated to be CryptoStream members instead of Stream members -- with the exception of Stream.CopyTo, which CryptoStream does not override. * Apply suggestions from code review Co-Authored-By: Ron Petrusha <[email protected]>
1 parent 9f0a9dc commit 19f8c08

File tree

1 file changed

+151
-33
lines changed

1 file changed

+151
-33
lines changed

xml/System.Security.Cryptography/CryptoStream.xml

Lines changed: 151 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,35 @@
178178
<Parameter Name="state" Type="System.Object" Index="4" FrameworkAlternate="netcore-2.1;netcore-2.2;netcore-3.0;netstandard-2.1" />
179179
</Parameters>
180180
<Docs>
181-
<param name="buffer">To be added.</param>
182-
<param name="offset">To be added.</param>
183-
<param name="count">To be added.</param>
184-
<param name="callback">To be added.</param>
185-
<param name="state">To be added.</param>
186-
<summary>To be added.</summary>
187-
<returns>To be added.</returns>
188-
<remarks>To be added.</remarks>
181+
<param name="buffer">The buffer to read the data into.</param>
182+
<param name="offset">The byte offset in <paramref name="buffer" /> at which to begin writing data read from the stream.</param>
183+
<param name="count">The maximum number of bytes to read.</param>
184+
<param name="callback">An optional asynchronous callback, to be called when the read is complete.</param>
185+
<param name="state">A user-provided object that distinguishes this particular asynchronous read request from other requests.</param>
186+
<summary>Begins an asynchronous read operation. (Consider using <see cref="Overload:System.Security.Cryptography.CryptoStream.ReadAsync" /> instead.)</summary>
187+
<returns>An <see cref="T:System.IAsyncResult" /> that represents the asynchronous read, which could still be pending.</returns>
188+
<remarks>
189+
<format type="text/markdown"><![CDATA[
190+
191+
## Remarks
192+
In the .NET Framework 4 and earlier versions, you have to use methods such as <xref:System.IO.Stream.BeginRead%2A> and <xref:System.IO.Stream.EndRead%2A> to implement asynchronous I/O operations. These methods are still available in .NET to support legacy code; however, the new async methods, such as <xref:System.Security.Cryptography.CryptoStream.ReadAsync%2A>, <xref:System.Security.Cryptography.CryptoStream.WriteAsync%2A>, <xref:System.IO.Stream.CopyToAsync%2A>, and <xref:System.Security.Cryptography.CryptoStream.FlushAsync%2A>, help you implement asynchronous I/O operations more easily.
193+
194+
Pass the `IAsyncResult` return value to the <xref:System.Security.Cryptography.CryptoStream.EndRead%2A> method of the stream to determine how many bytes were read and to release operating system resources used for reading. <xref:System.Security.Cryptography.CryptoStream.EndRead%2A> must be called once for every call to <xref:System.Security.Cryptography.CryptoStream.BeginRead%2A>. You can do this either by using the same code that called `BeginRead` or in a callback passed to `BeginRead`.
195+
196+
The current position in the stream is updated when the asynchronous read or write is issued, not when the I/O operation completes.
197+
198+
Multiple simultaneous asynchronous requests render the request completion order uncertain.
199+
200+
Use the <xref:System.Security.Cryptography.CryptoStream.CanRead%2A> property to determine whether the current instance supports reading.
201+
202+
If a stream is closed or you pass an invalid argument, exceptions are thrown immediately from `BeginRead`. Errors that occur during an asynchronous read request, such as a disk failure during the I/O request, occur on the thread pool thread and throw exceptions when calling `EndRead`.
203+
204+
]]></format>
205+
</remarks>
206+
<exception cref="T:System.IO.IOException">Attempted an asynchronous read past the end of the stream, or a disk error occurred.</exception>
207+
<exception cref="T:System.ArgumentException">One or more of the arguments is invalid.</exception>
208+
<exception cref="T:System.ObjectDisposedException">Methods were called after the stream was closed.</exception>
209+
<exception cref="T:System.NotSupportedException">The current <see langword="Stream" /> implementation does not support the read operation.</exception>
189210
</Docs>
190211
</Member>
191212
<Member MemberName="BeginWrite">
@@ -218,14 +239,35 @@
218239
<Parameter Name="state" Type="System.Object" Index="4" FrameworkAlternate="netcore-2.1;netcore-2.2;netcore-3.0;netstandard-2.1" />
219240
</Parameters>
220241
<Docs>
221-
<param name="buffer">To be added.</param>
222-
<param name="offset">To be added.</param>
223-
<param name="count">To be added.</param>
224-
<param name="callback">To be added.</param>
225-
<param name="state">To be added.</param>
226-
<summary>To be added.</summary>
227-
<returns>To be added.</returns>
228-
<remarks>To be added.</remarks>
242+
<param name="buffer">The buffer to write data from.</param>
243+
<param name="offset">The byte offset in <paramref name="buffer" /> from which to begin writing.</param>
244+
<param name="count">The maximum number of bytes to write.</param>
245+
<param name="callback">An optional asynchronous callback, to be called when the write is complete.</param>
246+
<param name="state">A user-provided object that distinguishes this particular asynchronous write request from other requests.</param>
247+
<summary>Begins an asynchronous write operation. (Consider using <see cref="Overload:System.Security.Cryptography.CryptoStream.WriteAsync" /> instead.)</summary>
248+
<returns>An <see langword="IAsyncResult" /> that represents the asynchronous write, which could still be pending.</returns>
249+
<remarks>
250+
<format type="text/markdown"><![CDATA[
251+
252+
## Remarks
253+
In the .NET Framework 4 and earlier versions, you have to use methods such as <xref:System.Security.Cryptography.CryptoStream.BeginWrite%2A> and <xref:System.Security.Cryptography.CryptoStream.EndWrite%2A> to implement asynchronous I/O operations. These methods are still available in .NET to support legacy code; however, the new async methods, such as <xref:System.Security.Cryptography.CryptoStream.ReadAsync%2A>, <xref:System.Security.Cryptography.CryptoStream.WriteAsync%2A>, <xref:System.IO.Stream.CopyToAsync%2A>, and <xref:System.Security.Cryptography.CryptoStream.FlushAsync%2A>, help you implement asynchronous I/O operations more easily.
254+
255+
Pass the `IAsyncResult` returned by the current method to <xref:System.Security.Cryptography.CryptoStream.EndWrite%2A> to ensure that the write completes and frees resources appropriately. <xref:System.Security.Cryptography.CryptoStream.EndWrite%2A> must be called once for every call to <xref:System.Security.Cryptography.CryptoStream.BeginWrite%2A>. You can do this either by using the same code that called `BeginWrite` or in a callback passed to `BeginWrite`. If an error occurs during an asynchronous write, an exception will not be thrown until `EndWrite` is called with the `IAsyncResult` returned by this method.
256+
257+
If a stream is writable, writing at the end of the stream expands the stream.
258+
259+
The current position in the stream is updated when you issue the asynchronous read or write, not when the I/O operation completes. Multiple simultaneous asynchronous requests render the request completion order uncertain.
260+
261+
Use the <xref:System.Security.Cryptography.CryptoStream.CanWrite%2A> property to determine whether the current instance supports writing.
262+
263+
If a stream is closed or you pass an invalid argument, exceptions are thrown immediately from `BeginWrite`. Errors that occur during an asynchronous write request, such as a disk failure during the I/O request, occur on the thread pool thread and throw exceptions when calling `EndWrite`.
264+
265+
]]></format>
266+
</remarks>
267+
<exception cref="T:System.IO.IOException">Attempted an asynchronous write past the end of the stream, or a disk error occurred.</exception>
268+
<exception cref="T:System.ArgumentException">One or more of the arguments is invalid.</exception>
269+
<exception cref="T:System.ObjectDisposedException">Methods were called after the stream was closed.</exception>
270+
<exception cref="T:System.NotSupportedException">The current <see langword="Stream" /> implementation does not support the write operation.</exception>
229271
</Docs>
230272
</Member>
231273
<Member MemberName="CanRead">
@@ -495,9 +537,20 @@
495537
</ReturnValue>
496538
<Parameters />
497539
<Docs>
498-
<summary>To be added.</summary>
499-
<returns>To be added.</returns>
500-
<remarks>To be added.</remarks>
540+
<summary>Asynchronously releases the unmanaged resources used by the <see cref="T:System.Security.Cryptography.CryptoStream" />.</summary>
541+
<returns>A task that represents the asynchronous dispose operation.</returns>
542+
<remarks>
543+
<format type="text/markdown"><![CDATA[
544+
545+
## Remarks
546+
The <xref:System.Security.Cryptography.CryptoStream.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#.
547+
548+
This method disposes the stream by writing any changes to the backing store and closing the stream to release resources.
549+
550+
Calling `DisposeAsync` allows the resources used by the <xref:System.Security.Cryptography.CryptoStream> to be reallocated for other purposes. For more information, see [Cleaning Up Unmanaged Resources](~/docs/standard/garbage-collection/unmanaged.md).
551+
552+
]]></format>
553+
</remarks>
501554
</Docs>
502555
</Member>
503556
<Member MemberName="EndRead">
@@ -526,10 +579,33 @@
526579
<Parameter Name="asyncResult" Type="System.IAsyncResult" Index="0" FrameworkAlternate="netcore-2.1;netcore-2.2;netcore-3.0;netstandard-2.1" />
527580
</Parameters>
528581
<Docs>
529-
<param name="asyncResult">To be added.</param>
530-
<summary>To be added.</summary>
531-
<returns>To be added.</returns>
532-
<remarks>To be added.</remarks>
582+
<param name="asyncResult">The reference to the pending asynchronous request to finish.</param>
583+
<summary>Waits for the pending asynchronous read to complete. (Consider using <see cref="Overload:System.Security.Cryptography.CryptoStream.ReadAsync" /> instead.)</summary>
584+
<returns>The number of bytes read from the stream, between zero (0) and the number of bytes you requested. Streams return zero (0) only at the end of the stream, otherwise, they should block until at least one byte is available.</returns>
585+
<remarks>
586+
<format type="text/markdown"><![CDATA[
587+
588+
## Remarks
589+
In the .NET Framework 4 and earlier versions, you have to use methods such as <xref:System.Security.Cryptography.CryptoStream.BeginRead%2A> and <xref:System.Security.Cryptography.CryptoStream.EndRead%2A> to implement asynchronous I/O operations. These methods are still available in .NET to support legacy code; however, the new async methods, such as <xref:System.Security.Cryptography.CryptoStream.ReadAsync%2A>, <xref:System.Security.Cryptography.CryptoStream.WriteAsync%2A>, <xref:System.IO.Stream.CopyToAsync%2A>, and <xref:System.Security.Cryptography.CryptoStream.FlushAsync%2A>, help you implement asynchronous I/O operations more easily.
590+
591+
Call `EndRead` to determine how many bytes were read from the stream.
592+
593+
`EndRead` can be called once on every <xref:System.IAsyncResult> from <xref:System.Security.Cryptography.CryptoStream.BeginRead%2A>.
594+
595+
This method blocks until the I/O operation has completed.
596+
597+
]]></format>
598+
</remarks>
599+
<exception cref="T:System.ArgumentNullException">
600+
<paramref name="asyncResult" /> is <see langword="null" />.</exception>
601+
<exception cref="T:System.ArgumentException">A handle to the pending read operation is not available.
602+
603+
-or-
604+
605+
The pending operation does not support reading.</exception>
606+
<exception cref="T:System.InvalidOperationException">
607+
<paramref name="asyncResult" /> did not originate from a <see cref="M:System.Security.Cryptography.CryptoStream.BeginRead(System.Byte[],System.Int32,System.Int32,System.AsyncCallback,System.Object)" /> method on the current stream.</exception>
608+
<exception cref="T:System.IO.IOException">The stream is closed or an internal error has occurred.</exception>
533609
</Docs>
534610
</Member>
535611
<Member MemberName="EndWrite">
@@ -558,9 +634,30 @@
558634
<Parameter Name="asyncResult" Type="System.IAsyncResult" Index="0" FrameworkAlternate="netcore-2.1;netcore-2.2;netcore-3.0;netstandard-2.1" />
559635
</Parameters>
560636
<Docs>
561-
<param name="asyncResult">To be added.</param>
562-
<summary>To be added.</summary>
563-
<remarks>To be added.</remarks>
637+
<param name="asyncResult">A reference to the outstanding asynchronous I/O request.</param>
638+
<summary>Ends an asynchronous write operation. (Consider using <see cref="Overload:System.Security.Cryptography.CryptoStream.WriteAsync" /> instead.)</summary>
639+
<remarks>
640+
<format type="text/markdown"><![CDATA[
641+
642+
## Remarks
643+
In the .NET Framework 4 and earlier versions, you have to use methods such as <xref:System.Security.Cryptography.CryptoStream.BeginWrite%2A> and <xref:System.Security.Cryptography.CryptoStream.EndWrite%2A> to implement asynchronous I/O operations. These methods are still available in .NET to support legacy code; however, the new async methods, such as <xref:System.Security.Cryptography.CryptoStream.ReadAsync%2A>, <xref:System.Security.Cryptography.CryptoStream.WriteAsync%2A>, <xref:System.IO.Stream.CopyToAsync%2A>, and <xref:System.Security.Cryptography.CryptoStream.FlushAsync%2A>, help you implement asynchronous I/O operations more easily.
644+
645+
`EndWrite` must be called exactly once on every <xref:System.IAsyncResult> from <xref:System.Security.Cryptography.CryptoStream.BeginWrite%2A>.
646+
647+
This method blocks until the I/O operation has completed. Errors that occur during an asynchronous write request, such as a disk failure during the I/O request, occur on the thread pool thread and become visible upon a call to `EndWrite`. Exceptions thrown by the thread pool thread will not be visible when calling `EndWrite`.
648+
649+
]]></format>
650+
</remarks>
651+
<exception cref="T:System.ArgumentNullException">
652+
<paramref name="asyncResult" /> is <see langword="null" />.</exception>
653+
<exception cref="T:System.ArgumentException">A handle to the pending write operation is not available.
654+
655+
-or-
656+
657+
The pending operation does not support writing.</exception>
658+
<exception cref="T:System.InvalidOperationException">
659+
<paramref name="asyncResult" /> did not originate from a <see cref="M:System.IO.Stream.BeginWrite(System.Byte[],System.Int32,System.Int32,System.AsyncCallback,System.Object)" /> method on the current stream.</exception>
660+
<exception cref="T:System.IO.IOException">The stream is closed or an internal error has occurred.</exception>
564661
</Docs>
565662
</Member>
566663
<Member MemberName="Finalize">
@@ -1001,9 +1098,20 @@
10011098
</ReturnValue>
10021099
<Parameters />
10031100
<Docs>
1004-
<summary>To be added.</summary>
1005-
<returns>To be added.</returns>
1006-
<remarks>To be added.</remarks>
1101+
<summary>Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.</summary>
1102+
<returns>The unsigned byte cast to an <see langword="Int32" />, or -1 if at the end of the stream.</returns>
1103+
<remarks>
1104+
<format type="text/markdown"><![CDATA[
1105+
1106+
## Remarks
1107+
Use the <xref:System.Security.Cryptography.CryptoStream.CanRead%2A> property to determine whether the current instance supports reading.
1108+
1109+
Attempts to manipulate the stream after the stream has been closed could throw an <xref:System.ObjectDisposedException>.
1110+
1111+
]]></format>
1112+
</remarks>
1113+
<exception cref="T:System.NotSupportedException">The stream does not support reading.</exception>
1114+
<exception cref="T:System.ObjectDisposedException">Methods were called after the stream was closed.</exception>
10071115
</Docs>
10081116
</Member>
10091117
<Member MemberName="Seek">
@@ -1275,10 +1383,20 @@
12751383
<Parameter Name="value" Type="System.Byte" Index="0" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netstandard-2.1" />
12761384
</Parameters>
12771385
<Docs>
1278-
<param name="value">To be added.</param>
1279-
<summary>To be added.</summary>
1280-
<remarks>To be added.</remarks>
1386+
<param name="value">The byte to write to the stream.</param>
1387+
<summary>Writes a byte to the current position in the stream and advances the position within the stream by one byte.</summary>
1388+
<remarks>
1389+
<format type="text/markdown"><![CDATA[
1390+
1391+
## Remarks
1392+
Use the <xref:System.Security.Cryptography.CryptoStream.CanWrite%2A> property to determine whether the current instance supports writing.
1393+
1394+
]]></format>
1395+
</remarks>
1396+
<exception cref="T:System.IO.IOException">An I/O error occurs.</exception>
1397+
<exception cref="T:System.NotSupportedException">The stream does not support writing, or the stream is already closed.</exception>
1398+
<exception cref="T:System.ObjectDisposedException">Methods were called after the stream was closed.</exception>
12811399
</Docs>
12821400
</Member>
12831401
</Members>
1284-
</Type>
1402+
</Type>

0 commit comments

Comments
 (0)