Skip to content

Commit fc57f7f

Browse files
authored
.NET Interactive: Enable_try_dotnet_to_batch_14a (#4487)
* enable_try_dotnet_to_batch_14a * remove_interactive_dotnet
1 parent 4ab3a43 commit fc57f7f

File tree

7 files changed

+37
-37
lines changed

7 files changed

+37
-37
lines changed

xml/System.Collections.Specialized/NameValueCollection.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@
6666
6767
6868
## Examples
69-
[!code-cpp[System.Collections.Specialized.NameValueCollection2#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameValueCollection2/CPP/nvc.cpp#1)]
70-
[!code-csharp[System.Collections.Specialized.NameValueCollection2#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Specialized.NameValueCollection2/CS/nvc.cs#1)]
71-
[!code-vb[System.Collections.Specialized.NameValueCollection2#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.NameValueCollection2/VB/nvc.vb#1)]
69+
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameValueCollection2/CPP/nvc.cpp" id="Snippet1":::
70+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Specialized.NameValueCollection2/CS/nvc.cs" interactive="try-dotnet" id="Snippet1":::
71+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.NameValueCollection2/VB/nvc.vb" id="Snippet1":::
7272
7373
]]></format>
7474
</remarks>

xml/System.Linq/Queryable.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8335,8 +8335,8 @@ If `count` is not a positive number, this method returns an empty queryable sequ
83358335
## Examples
83368336
The following code example demonstrates how to use <xref:System.Linq.Queryable.Union%60%601%28System.Linq.IQueryable%7B%60%600%7D%2CSystem.Collections.Generic.IEnumerable%7B%60%600%7D%29> to obtain the set union of two sequences.
83378337

8338-
[!code-csharp[System.Linq.Queryable#109](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.Queryable/CS/queryable.cs#109)]
8339-
[!code-vb[System.Linq.Queryable#109](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.Queryable/VB/queryable.vb#109)]
8338+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Linq.Queryable/CS/queryable.cs" interactive="try-dotnet-method" id="Snippet109":::
8339+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Linq.Queryable/VB/queryable.vb" id="Snippet109":::
83408340

83418341
]]></format>
83428342
</remarks>

xml/System.Text/Encoder.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@
7373
## Examples
7474
The following example demonstrates how to convert an array of Unicode characters into blocks of bytes using a specified encoding. For comparison, the array of characters is first encoded using <xref:System.Text.UTF7Encoding>. Next, the array of characters is encoded using an <xref:System.Text.Encoder>.
7575
76-
[!code-cpp[System.Text.Encoder Example#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder Example/CPP/snippet.cpp#1)]
77-
[!code-csharp[System.Text.Encoder Example#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.Encoder Example/CS/snippet.cs#1)]
78-
[!code-vb[System.Text.Encoder Example#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoder Example/VB/snippet.vb#1)]
76+
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder Example/CPP/snippet.cpp" id="Snippet1":::
77+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.Encoder Example/CS/snippet.cs" interactive="try-dotnet" id="Snippet1":::
78+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoder Example/VB/snippet.vb" id="Snippet1":::
7979
8080
]]></format>
8181
</remarks>

xml/System.Text/UTF8Encoding.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1936,14 +1936,14 @@
19361936
## Examples
19371937
The following example uses the <xref:System.Text.UTF8Encoding.GetPreamble%2A> method to return the Unicode byte order mark encoded in UTF-8 format. Notice that the parameterless constructor for <xref:System.Text.UTF8Encoding> does not provide a preamble.
19381938
1939-
[!code-cpp[System.Text.UTF8Encoding.GetPreamble Example#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetPreamble Example/CPP/getpreamble-.cpp#1)]
1940-
[!code-csharp[System.Text.UTF8Encoding.GetPreamble Example#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetPreamble Example/CS/getpreamble-.cs#1)]
1941-
[!code-vb[System.Text.UTF8Encoding.GetPreamble Example#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetPreamble Example/VB/getpreamble-.vb#1)]
1939+
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetPreamble Example/CPP/getpreamble-.cpp" id="Snippet1":::
1940+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetPreamble Example/CS/getpreamble-.cs" interactive="try-dotnet" id="Snippet1":::
1941+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetPreamble Example/VB/getpreamble-.vb" id="Snippet1":::
19421942
19431943
The following example instantiates two <xref:System.Text.UTF8Encoding> objects, the first by calling the parameterless <xref:System.Text.UTF8Encoding.%23ctor> constructor, which does not provide a BOM, and the second by calling the <xref:System.Text.UTF8Encoding.%23ctor%28System.Boolean%29> constructor with its `encoderShouldEmitUTF8Identifier` argument set to `true`. It then calls the <xref:System.Text.UTF8Encoding.GetPreamble%2A> method to write the BOM to a file before writing a UF8-encoded string. As the console output from the example shows, the file that saves the bytes from the second encoder has three more bytes than the first.
19441944
1945-
[!code-csharp[System.Text.UTF8Encoding.GetPreamble#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.text.utf8encoding.getpreamble/cs/getpreamble1.cs#1)]
1946-
[!code-vb[System.Text.UTF8Encoding.GetPreamble#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.text.utf8encoding.getpreamble/vb/getpreamble1.vb#1)]
1945+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.text.utf8encoding.getpreamble/cs/getpreamble1.cs" interactive="try-dotnet" id="Snippet1":::
1946+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.text.utf8encoding.getpreamble/vb/getpreamble1.vb" id="Snippet1":::
19471947
19481948
You can also compare the files by using the `fc` command in a console window, or you can inspect the files in a text editor that includes a Hex View mode. Note that when the file is opened in an editor that supports UTF-8, the BOM is not displayed.
19491949

xml/System/ArgumentOutOfRangeException.xml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ The conditions in which an <xref:System.ArgumentOutOfRangeException> exception i
7878
7979
1. The collection has no members, and your code assumes that it does. The following example attempts to retrieve the first element of a collection that has no elements:
8080
81-
[!code-csharp[System.ArgumentOutOfRangeException#4](~/samples/snippets/csharp/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/cs/NoElements.cs#4)]
82-
[!code-vb[System.ArgumentOutOfRangeException#4](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/vb/NoElements.vb#4)]
81+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/cs/NoElements.cs" interactive="try-dotnet" id="Snippet4":::
82+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/vb/NoElements.vb" id="Snippet4":::
8383
8484
To prevent the exception, check whether the collection's `Count` property is greater than zero before attempting to retrieve any members, as the following code fragment does.
8585
@@ -98,8 +98,8 @@ The conditions in which an <xref:System.ArgumentOutOfRangeException> exception i
9898
9999
3. You're attempting to retrieve an item whose index is negative. This usually occurs because you've searched a collection for the index of a particular element and have erroneously assumed that the search is successful. In the following example, the call to the <xref:System.Collections.Generic.List%601.FindIndex%28System.Predicate%7B%600%7D%29?displayProperty=nameWithType> method fails to find a string equal to "Z" and so returns -1. However, this is an invalid index value.
100100
101-
[!code-csharp[System.ArgumentOutOfRangeException#6](~/samples/snippets/csharp/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/cs/BadSearch.cs#6)]
102-
[!code-vb[System.ArgumentOutOfRangeException#6](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/vb/BadSearch.vb#6)]
101+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/cs/BadSearch.cs" interactive="try-dotnet" id="Snippet6":::
102+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/vb/BadSearch.vb" id="Snippet6":::
103103
104104
To prevent the exception, check that the search is successful by making sure that the returned index is greater than or equal to zero before attempting to retrieve the item from the collection, as the following code fragment does.
105105
@@ -108,8 +108,8 @@ The conditions in which an <xref:System.ArgumentOutOfRangeException> exception i
108108
109109
4. You're attempting to retrieve an element whose index is equal to the value of the collection's `Count` property, as the following example illustrates.
110110
111-
[!code-csharp[System.ArgumentOutOfRangeException#8](~/samples/snippets/csharp/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/cs/OOR2.cs#8)]
112-
[!code-vb[System.ArgumentOutOfRangeException#8](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/vb/OOR2.vb#8)]
111+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/cs/OOR2.cs" interactive="try-dotnet" id="Snippet8":::
112+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/vb/OOR2.vb" id="Snippet8":::
113113
114114
Because collections in .NET use zero-based indexing, the first element of the collection is at index 0, and the last element is at index `Count` - 1. You can eliminate the error by ensuring that you access the last element at index `Count` - 1, as the following code does.
115115
@@ -141,8 +141,8 @@ The conditions in which an <xref:System.ArgumentOutOfRangeException> exception i
141141
142142
To eliminate the exception, validate the value returned by the string search method before calling the string manipulation method.
143143
144-
[!code-csharp[System.ArgumentOutOfRangeException#18](~/samples/snippets/csharp/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/cs/NoFind2.cs#18)]
145-
[!code-vb[System.ArgumentOutOfRangeException#18](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/vb/NoFind2.vb#18)]
144+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/cs/NoFind2.cs" interactive="try-dotnet" id="Snippet18":::
145+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/vb/NoFind2.vb" id="Snippet18":::
146146
147147
3. You've attempted to extract a substring that is outside the range of the current string.
148148
@@ -164,8 +164,8 @@ The conditions in which an <xref:System.ArgumentOutOfRangeException> exception i
164164
165165
The following example defines a `FindWords` method that uses the <xref:System.String.IndexOfAny%28System.Char%5B%5D%2CSystem.Int32%29?displayProperty=nameWithType> method to identify space characters and punctuation marks in a string and returns an array that contains the words found in the string.
166166
167-
[!code-csharp[System.ArgumentOutOfRangeException#19](~/samples/snippets/csharp/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/cs/FindWords1.cs#19)]
168-
[!code-vb[System.ArgumentOutOfRangeException#19](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/vb/FindWords1.vb#19)]
167+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/cs/FindWords1.cs" interactive="try-dotnet" id="Snippet19":::
168+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.ArgumentOutOfRangeException/vb/FindWords1.vb" id="Snippet19":::
169169
170170
- You have passed a negative number to a method with an argument that requires only positive numbers and zero, or you have passed either a negative number or zero to a method with an argument that requires only positive numbers.
171171
@@ -216,8 +216,8 @@ For a list of initial property values for an instance of <xref:System.ArgumentOu
216216
217217
The following example defines a class to contain information about an invited guest. If the guest is younger than 21, an <xref:System.ArgumentOutOfRangeException> exception is thrown.
218218
219-
[!code-csharp[ArgumentOutOfRangeException#1](~/samples/snippets/csharp/VS_Snippets_CLR/ArgumentOutOfRangeException/CS/program.cs#1)]
220-
[!code-vb[ArgumentOutOfRangeException#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/ArgumentOutOfRangeException/VB/program.vb#1)]
219+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/ArgumentOutOfRangeException/CS/program.cs" interactive="try-dotnet" id="Snippet1":::
220+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/ArgumentOutOfRangeException/VB/program.vb" id="Snippet1":::
221221
222222
]]></format>
223223
</remarks>

xml/System/IndexOutOfRangeException.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@
6868
6969
To correct the error, you can use code like the following.
7070
71-
[!code-csharp[System.IndexOutOfRangeException#4](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.indexoutofrangeexception/cs/length2.cs#4)]
72-
[!code-vb[System.IndexOutOfRangeException#4](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.indexoutofrangeexception/vb/length2.vb#4)]
71+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.indexoutofrangeexception/cs/length2.cs" interactive="try-dotnet" id="Snippet4":::
72+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.indexoutofrangeexception/vb/length2.vb" id="Snippet4":::
7373
7474
Alternately, instead of iterating all the elements in the array by their index, you can use the `foreach` statement (in C#) or the `For Each` statement (in Visual Basic).
7575
@@ -118,8 +118,8 @@
118118
119119
To correct the error, as the following example does, you can call the <xref:System.Array.GetLowerBound%2A> method instead of making assumptions about the starting index of an array.
120120
121-
[!code-csharp[System.IndexOutOfRangeException#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.indexoutofrangeexception/cs/nonzero2.cs#2)]
122-
[!code-vb[System.IndexOutOfRangeException#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.indexoutofrangeexception/vb/nonzero2.vb#2)]
121+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.indexoutofrangeexception/cs/nonzero2.cs" interactive="try-dotnet" id="Snippet2":::
122+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.indexoutofrangeexception/vb/nonzero2.vb" id="Snippet2":::
123123
124124
Note that when you call the <xref:System.Array.GetLowerBound%2A> method to get the starting index of an array, you should also call the <xref:System.Array.GetUpperBound%28System.Int32%29?displayProperty=nameWithType> method to get its ending index.
125125
@@ -130,8 +130,8 @@
130130
131131
The iteration construct returns each value in an array or collection, not its index. To eliminate the exception, use this code.
132132
133-
[!code-csharp[System.IndexOutOfRangeException#8](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.indexoutofrangeexception/cs/foreach2.cs#8)]
134-
[!code-vb[System.IndexOutOfRangeException#8](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.indexoutofrangeexception/vb/foreach2.vb#8)]
133+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.indexoutofrangeexception/cs/foreach2.cs" interactive="try-dotnet" id="Snippet8":::
134+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.indexoutofrangeexception/vb/foreach2.vb" id="Snippet8":::
135135
136136
- Providing an invalid column name to the <xref:System.Data.DataView.Sort%2A?displayProperty=nameWithType> property.
137137

xml/System/Type.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11866,9 +11866,9 @@ Byref-like structures are declared using `ref struct` keyword in C#. An instance
1186611866

1186711867
The following code example and table illustrate some of these terms and invariants. The `Derived` class is of particular interest because its base type is a constructed type that has a mixture of types and type parameters in its type argument list.
1186811868

11869-
[!code-cpp[System.Type.IsGenericType#2](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Type.IsGenericType/cpp/remarks.cpp#2)]
11870-
[!code-csharp[System.Type.IsGenericType#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Type.IsGenericType/cs/remarks.cs#2)]
11871-
[!code-vb[System.Type.IsGenericType#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Type.IsGenericType/vb/remarks.vb#2)]
11869+
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Type.IsGenericType/cpp/remarks.cpp" id="Snippet2":::
11870+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Type.IsGenericType/cs/remarks.cs" id="Snippet2":::
11871+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Type.IsGenericType/vb/remarks.vb" id="Snippet2":::
1187211872

1187311873
The following table shows examples that use and build on the classes `Base`, `Derived`, and `G`. When the C++ and C# code is the same, only one entry is shown.
1187411874

@@ -11886,9 +11886,9 @@ Byref-like structures are declared using `ref struct` keyword in C#. An instance
1188611886
## Examples
1188711887
The following code example displays the value of the <xref:System.Type.IsGenericType%2A>, <xref:System.Type.IsGenericTypeDefinition%2A>, <xref:System.Type.IsGenericParameter%2A>, and <xref:System.Type.ContainsGenericParameters%2A> properties for the types described in the Remarks section. For explanations of the property values, see the accompanying table in Remarks.
1188811888

11889-
[!code-cpp[System.Type.IsGenericType#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Type.IsGenericType/cpp/source.cpp#1)]
11890-
[!code-csharp[System.Type.IsGenericType#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Type.IsGenericType/cs/source.cs#1)]
11891-
[!code-vb[System.Type.IsGenericType#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Type.IsGenericType/vb/source.vb#1)]
11889+
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Type.IsGenericType/cpp/source.cpp" id="Snippet1":::
11890+
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Type.IsGenericType/cs/source.cs" interactive="try-dotnet" id="Snippet1":::
11891+
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Type.IsGenericType/vb/source.vb" id="Snippet1":::
1189211892

1189311893
]]></format>
1189411894
</remarks>

0 commit comments

Comments
 (0)