Skip to content

Commit dfe8776

Browse files
Merge pull request #12227 from dotnet/main
Merge main into live
2 parents 8d4f732 + 72ea69b commit dfe8776

1 file changed

Lines changed: 38 additions & 30 deletions

File tree

xml/System.IO/MemoryStream.xml

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,6 @@
312312
313313
This constructor exposes the underlying stream that <xref:System.IO.MemoryStream.GetBuffer%2A> returns.
314314
315-
316-
317315
## Examples
318316
This code example is part of a larger example provided for the <xref:System.IO.MemoryStream> class.
319317
@@ -452,7 +450,7 @@
452450
<format type="text/markdown"><![CDATA[
453451
454452
## Remarks
455-
The <xref:System.IO.MemoryStream.CanRead%2A>, <xref:System.IO.MemoryStream.CanSeek%2A>, and <xref:System.IO.MemoryStream.CanWrite%2A> properties are all set to `true`, but the capacity cannot be changed. <xref:System.IO.MemoryStream.Capacity%2A> is set to `count`.
453+
The <xref:System.IO.MemoryStream.CanRead>, <xref:System.IO.MemoryStream.CanSeek>, and <xref:System.IO.MemoryStream.CanWrite> properties are all set to `true`, but the capacity cannot be changed. <xref:System.IO.MemoryStream.Capacity%2A> is set to `count`.
456454
457455
The length of the stream cannot be set to a value greater than the initial length of the specified byte array; however, the stream can be truncated (see <xref:System.IO.MemoryStream.SetLength%2A>).
458456
@@ -527,7 +525,7 @@
527525
<format type="text/markdown"><![CDATA[
528526
529527
## Remarks
530-
The <xref:System.IO.MemoryStream.CanRead%2A> and <xref:System.IO.MemoryStream.CanSeek%2A> properties are both set to `true`. <xref:System.IO.MemoryStream.Capacity%2A> is set to `count`.
528+
The <xref:System.IO.MemoryStream.CanRead> and <xref:System.IO.MemoryStream.CanSeek> properties are both set to `true`. <xref:System.IO.MemoryStream.Capacity> is set to `count`.
531529
532530
The length of the stream cannot be set to a value greater than the initial length of the specified byte array; however, the stream can be truncated (see <xref:System.IO.MemoryStream.SetLength%2A>).
533531
@@ -604,7 +602,7 @@
604602
<format type="text/markdown"><![CDATA[
605603
606604
## Remarks
607-
The <xref:System.IO.MemoryStream.CanRead%2A> and <xref:System.IO.MemoryStream.CanSeek%2A> properties are both set to `true`. <xref:System.IO.MemoryStream.Capacity%2A> is set to `count`.
605+
The <xref:System.IO.MemoryStream.CanRead> and <xref:System.IO.MemoryStream.CanSeek> properties are both set to `true`. <xref:System.IO.MemoryStream.Capacity> is set to `count`.
608606
609607
The new stream instance can be written to, but the <xref:System.IO.MemoryStream.Capacity%2A> of the underlying byte array cannot be changed. The length of the stream cannot be set to a value greater than the initial length of the specified byte array; however, the stream can be truncated (see <xref:System.IO.MemoryStream.SetLength%2A>).
610608
@@ -1029,20 +1027,23 @@ Refer to the <xref:System.IO.Stream.BeginWrite%2A> remarks for additional usage
10291027
<remarks>
10301028
<format type="text/markdown"><![CDATA[
10311029
1032-
## Remarks
1033-
`Capacity` is the buffer length for system-provided byte arrays. `Capacity` cannot be set to a value less than the current length of the stream.
1034-
1035-
1030+
`Capacity` is the buffer length for system-provided byte arrays. `Capacity` cannot be set to a value less than the current length of the stream.
10361031
10371032
## Examples
1038-
This code example is part of a larger example provided for the <xref:System.IO.MemoryStream> class.
10391033
1040-
:::code language="csharp" source="~/snippets/csharp/System.IO/MemoryStream/Overview/memstream.cs" id="Snippet5":::
1041-
:::code language="vb" source="~/snippets/visualbasic/System.IO/MemoryStream/Overview/memstream.vb" id="Snippet5":::
1034+
This code example is part of a larger example provided for the <xref:System.IO.MemoryStream> class.
1035+
1036+
:::code language="csharp" source="~/snippets/csharp/System.IO/MemoryStream/Overview/memstream.cs" id="Snippet5":::
1037+
:::code language="vb" source="~/snippets/visualbasic/System.IO/MemoryStream/Overview/memstream.vb" id="Snippet5":::
10421038
10431039
]]></format>
10441040
</remarks>
1045-
<exception cref="T:System.ArgumentOutOfRangeException">A capacity is set that is negative or less than the current length of the stream.</exception>
1041+
<exception cref="T:System.ArgumentOutOfRangeException">A capacity is set that is negative or less than the current length of the stream.
1042+
1043+
-or-
1044+
1045+
In .NET 11 and later versions, the value being set is greater than 0x7FFFFFC7 bytes.
1046+
</exception>
10461047
<exception cref="T:System.ObjectDisposedException">The current stream is closed.</exception>
10471048
<exception cref="T:System.NotSupportedException">
10481049
<see langword="set" /> is invoked on a stream whose capacity cannot be modified.</exception>
@@ -1546,9 +1547,9 @@ The pending operation does not support writing.</exception>
15461547
## Remarks
15471548
Because any data written to a <xref:System.IO.MemoryStream> object is written into RAM, this method is redundant.
15481549
1549-
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.
1550+
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> property.
15501551
1551-
You can create a cancellation token by creating an instance of the <xref:System.Threading.CancellationTokenSource> class and passing the <xref:System.Threading.CancellationTokenSource.Token%2A> property as the `cancellationToken` parameter.
1552+
You can create a cancellation token by creating an instance of the <xref:System.Threading.CancellationTokenSource> class and passing the <xref:System.Threading.CancellationTokenSource.Token> property as the `cancellationToken` parameter.
15521553
15531554
This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as <xref:System.ArgumentException>, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by <xref:System.IO.MemoryStream.Flush>.
15541555
@@ -2077,9 +2078,9 @@ The pending operation does not support writing.</exception>
20772078
<format type="text/markdown"><![CDATA[
20782079
20792080
## Remarks
2080-
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.
2081+
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> property.
20812082
2082-
You can create a cancellation token by creating an instance of the <xref:System.Threading.CancellationTokenSource> class and passing the <xref:System.Threading.CancellationTokenSource.Token%2A> property as the `cancellationToken` parameter.
2083+
You can create a cancellation token by creating an instance of the <xref:System.Threading.CancellationTokenSource> class and passing the <xref:System.Threading.CancellationTokenSource.Token> property as the `cancellationToken` parameter.
20832084
20842085
This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as <xref:System.ArgumentException>, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by <xref:System.IO.MemoryStream.Read(System.Byte[],System.Int32,System.Int32)>.
20852086
@@ -2229,7 +2230,7 @@ The pending operation does not support writing.</exception>
22292230
22302231
Seeking to any location beyond the length of the stream is supported.
22312232
2232-
Do not use the <xref:System.IO.MemoryStream.Seek%2A> method to determine the new position in the stream if the <xref:System.IO.MemoryStream> was initialized with a non-zero offset. If you do, <xref:System.IO.MemoryStream.Seek%2A> will return an inaccurate value. Instead, use the <xref:System.IO.MemoryStream.Position%2A> property to get the new position of the stream.
2233+
Do not use the <xref:System.IO.MemoryStream.Seek%2A> method to determine the new position in the stream if the <xref:System.IO.MemoryStream> was initialized with a non-zero offset. If you do, <xref:System.IO.MemoryStream.Seek%2A> will return an inaccurate value. Instead, use the <xref:System.IO.MemoryStream.Position> property to get the new position of the stream.
22332234
22342235
22352236
@@ -2303,28 +2304,35 @@ The pending operation does not support writing.</exception>
23032304
<Parameter Name="value" Type="System.Int64" />
23042305
</Parameters>
23052306
<Docs>
2306-
<param name="value">The value at which to set the length.</param>
2307+
<param name="value">The length to set.</param>
23072308
<summary>Sets the length of the current stream to the specified value.</summary>
23082309
<remarks>
23092310
<format type="text/markdown"><![CDATA[
23102311
2311-
## Remarks
2312-
This method overrides <xref:System.IO.Stream.SetLength%2A>.
2312+
This method overrides <xref:System.IO.Stream.SetLength%2A>.
23132313
2314-
If the specified value is less than the current length of the stream, the stream is truncated. If after the truncation the current position within the stream is past the end of the stream, the <xref:System.IO.MemoryStream.ReadByte%2A> method returns -1, the <xref:System.IO.MemoryStream.Read%2A> method reads zero bytes into the provided byte array, and <xref:System.IO.MemoryStream.Write%2A> and <xref:System.IO.MemoryStream.WriteByte%2A> methods append specified bytes at the end of the stream, increasing its length. If the specified value is larger than the current capacity and the stream is resizable, the capacity is increased, and the current position within the stream is unchanged. If the length is increased, the contents of the stream between the old and the new length are initialized to zeros.
2314+
If the specified value is less than the current length of the stream, the stream is truncated. If after the truncation the current position within the stream is past the end of the stream, the <xref:System.IO.MemoryStream.ReadByte%2A> method returns -1, the <xref:System.IO.MemoryStream.Read%2A> method reads zero bytes into the provided byte array, and <xref:System.IO.MemoryStream.Write%2A> and <xref:System.IO.MemoryStream.WriteByte%2A> methods append specified bytes at the end of the stream, increasing its length. If the specified value is larger than the current capacity and the stream is resizable, the capacity is increased, and the current position within the stream is unchanged. If the length is increased, the contents of the stream between the old and the new length are initialized to zeros.
23152315
23162316
> [!NOTE]
2317-
> A <xref:System.IO.MemoryStream> instance must support writing for this method to work. Use the <xref:System.IO.MemoryStream.CanWrite%2A> property to determine whether the current instance supports writing. For additional information, see <xref:System.IO.Stream.CanWrite%2A>.
2317+
> A <xref:System.IO.MemoryStream> instance must support writing for this method to work. Use the <xref:System.IO.MemoryStream.CanWrite> property to determine whether the current instance supports writing. For additional information, see <xref:System.IO.Stream.CanWrite>.
23182318
23192319
]]></format>
23202320
</remarks>
23212321
<exception cref="T:System.NotSupportedException">The current stream is not resizable and <paramref name="value" /> is larger than the current capacity.
23222322

2323-
-or-
2323+
-or-
23242324

2325-
The current stream does not support writing.</exception>
2325+
The current stream does not support writing.</exception>
23262326
<exception cref="T:System.ArgumentOutOfRangeException">
2327-
<paramref name="value" /> is negative or is greater than the maximum length of the <see cref="T:System.IO.MemoryStream" />, where the maximum length is (<see cref="F:System.Int32.MaxValue">Int32.MaxValue</see> - <code>origin</code>), and <code>origin</code> is the index into the underlying buffer at which the stream starts.</exception>
2327+
<paramref name="value" /> is negative
2328+
2329+
-or-
2330+
2331+
In .NET 11 and later versions, <paramref name="value" /> is greater than 0x7FFFFFC7 bytes.
2332+
2333+
-or-
2334+
2335+
In .NET 10 and earlier versions, <paramref name="value" /> is greater than the maximum length of the <see cref="T:System.IO.MemoryStream" />, where the maximum length is (<see cref="F:System.Int32.MaxValue">Int32.MaxValue</see> - <code>origin</code>), and <code>origin</code> is the index into the underlying buffer at which the stream starts.</exception>
23282336
<related type="Article" href="/dotnet/standard/io/">File and Stream I/O</related>
23292337
<related type="Article" href="/dotnet/standard/io/how-to-read-text-from-a-file">How to: Read Text from a File</related>
23302338
<related type="Article" href="/dotnet/standard/io/how-to-write-text-to-a-file">How to: Write Text to a File</related>
@@ -2390,10 +2398,10 @@ The pending operation does not support writing.</exception>
23902398
## Remarks
23912399
This method omits unused bytes in <xref:System.IO.MemoryStream> from the array. To get the entire buffer, use the <xref:System.IO.MemoryStream.GetBuffer%2A> method.
23922400
2393-
This method returns a copy of the contents of the <xref:System.IO.MemoryStream> as a byte array. If the current instance was constructed on a provided byte array, a copy of the section of the array to which this instance has access is returned. See the <xref:System.IO.MemoryStream.%23ctor%2A> constructor for details.
2401+
This method returns a copy of the contents of the <xref:System.IO.MemoryStream> as a byte array. If the current instance was constructed on a provided byte array, a copy of the section of the array to which this instance has access is returned. See the <xref:System.IO.MemoryStream.%23ctor*> constructor for details.
23942402
23952403
> [!NOTE]
2396-
> This method works when the <xref:System.IO.MemoryStream> is closed.
2404+
> This method works when the <xref:System.IO.MemoryStream> is closed.
23972405
23982406
]]></format>
23992407
</remarks>
@@ -2741,9 +2749,9 @@ The underlying buffer will not be exposed if the current `MemoryStream` instance
27412749
<format type="text/markdown"><![CDATA[
27422750
27432751
## Remarks
2744-
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.
2752+
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> property.
27452753
2746-
You can create a cancellation token by creating an instance of the <xref:System.Threading.CancellationTokenSource> class and passing the <xref:System.Threading.CancellationTokenSource.Token%2A> property as the `cancellationToken` parameter.
2754+
You can create a cancellation token by creating an instance of the <xref:System.Threading.CancellationTokenSource> class and passing the <xref:System.Threading.CancellationTokenSource.Token> property as the `cancellationToken` parameter.
27472755
27482756
This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as <xref:System.ArgumentException>, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by <xref:System.IO.MemoryStream.Write(System.Byte[],System.Int32,System.Int32)>.
27492757

0 commit comments

Comments
 (0)