Skip to content

Commit a189f83

Browse files
authored
Updates to Copilot highlights per revised guidance (#46937)
* Update how-to.md Modify per updated copilot highlights guidance * Update migrate-from-newtonsoft.md * Update how-to.md * Update deserialization.md * Update customize-properties.md * Update how-to-convert-a-string-to-a-number.md * Update how-to-initialize-a-dictionary-with-a-collection-initializer.md * Update concatenate-multiple-strings.md * Update parse-strings-using-split.md * Update concatenate-multiple-strings.md * Update how-to-initialize-a-dictionary-with-a-collection-initializer.md * Update how-to-convert-a-string-to-a-number.md * Update customize-properties.md * Update deserialization.md * Update migrate-from-newtonsoft.md * Update how-to.md * Update concatenate-multiple-strings.md * Update parse-strings-using-split.md * Update how-to-initialize-a-dictionary-with-a-collection-initializer.md * Update how-to-convert-a-string-to-a-number.md * Update customize-properties.md * Update deserialization.md * Update how-to.md * Update migrate-from-newtonsoft.md * Update how-to.md * Apply suggestion * Apply suggestion * Apply suggestion * Apply suggestion * Apply suggestion * Apply suggestion * Apply suggestion * Apply suggestion
1 parent ae9374d commit a189f83

File tree

8 files changed

+47
-38
lines changed

8 files changed

+47
-38
lines changed

docs/csharp/how-to/concatenate-multiple-strings.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ms.custom: copilot-scenario-highlight
1515
[!INCLUDE[interactive-note](~/includes/csharp-interactive-note.md)]
1616

1717
> [!TIP]
18-
> You can use AI assistance to [concatenate strings with GitHub Copilot](#use-github-copilot-to-concatenate-strings).
18+
> You can use AI assistance to [concatenate strings](#use-ai-to-concatenate-strings).
1919
2020
## String literals
2121

@@ -70,9 +70,9 @@ combines an array of words, adding a space between each word in the array:
7070

7171
This option can cause more allocations than other methods for concatenating collections, as it creates an intermediate string for each iteration. If optimizing performance is critical, consider the [`StringBuilder`](#stringbuilder) class or the [`String.Concat` or `String.Join`](#stringconcat-or-stringjoin) method to concatenate a collection, instead of `Enumerable.Aggregate`.
7272

73-
## Use GitHub Copilot to concatenate strings
73+
## Use AI to concatenate strings
7474

75-
You can use GitHub Copilot in your IDE to generate C# code to concatenate multiple strings. You can customize the prompt to specify strings and the method to use per your requirements.
75+
You can use AI tools, such as GitHub Copilot, to generate C# code to concatenate multiple strings. You can customize the prompt to specify strings and the method to use per your requirements.
7676

7777
The following text shows an example prompt for Copilot Chat:
7878

@@ -82,10 +82,10 @@ Generate C# code to use String.Format to build an output string "Hi x, today's d
8282

8383
GitHub Copilot is powered by AI, so surprises and mistakes are possible. For more information, see [Copilot FAQs](https://aka.ms/copilot-general-use-faqs).
8484

85-
Learn more about [GitHub Copilot in Visual Studio](/visualstudio/ide/visual-studio-github-copilot-install-and-states) and [GitHub Copilot in VS Code](https://code.visualstudio.com/docs/copilot/overview).
86-
8785
## See also
8886

8987
- <xref:System.String>
9088
- <xref:System.Text.StringBuilder>
9189
- [Strings](../programming-guide/strings/index.md)
90+
- [GitHub Copilot in Visual Studio](/visualstudio/ide/visual-studio-github-copilot-install-and-states)
91+
- [GitHub Copilot in VS Code](https://code.visualstudio.com/docs/copilot/overview)

docs/csharp/how-to/parse-strings-using-split.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The <xref:System.String.Split%2A?displayProperty=nameWithType> method creates an
1616
[!INCLUDE[interactive-note](~/includes/csharp-interactive-note.md)]
1717

1818
> [!TIP]
19-
> You can use AI assistance to [split a string with GitHub Copilot](#use-github-copilot-to-split-a-string).
19+
> You can use AI assistance to [split a string](#use-ai-to-split-a-string).
2020
2121
## Split a string into words
2222

@@ -76,9 +76,9 @@ The following example shows the effect of trimming entries:
7676

7777
The untrimmed entries have extra whitespace before the numerals.
7878

79-
## Use GitHub Copilot to split a string
79+
## Use AI to split a string
8080

81-
You can use GitHub Copilot in your IDE to generate code to split strings using `String.Split` in C#. You can customize the prompt to use strings and delimiters per your requirements.
81+
You can use AI tools, such as GitHub Copilot, to generate code to split strings using `String.Split` in C#. You can customize the prompt to use strings and delimiters per your requirements.
8282

8383
The following text shows an example prompt for Copilot Chat:
8484

@@ -90,10 +90,10 @@ Provide example output.
9090

9191
GitHub Copilot is powered by AI, so surprises and mistakes are possible. For more information, see [Copilot FAQs](https://aka.ms/copilot-general-use-faqs).
9292

93-
Learn more about [GitHub Copilot in Visual Studio](/visualstudio/ide/visual-studio-github-copilot-install-and-states) and [GitHub Copilot in VS Code](https://code.visualstudio.com/docs/copilot/overview).
94-
9593
## See also
9694

9795
- [Extract elements from a string](../../standard/base-types/divide-up-strings.md)
9896
- [Strings](../programming-guide/strings/index.md)
9997
- [.NET regular expressions](../../standard/base-types/regular-expressions.md)
98+
- [GitHub Copilot in Visual Studio](/visualstudio/ide/visual-studio-github-copilot-install-and-states)
99+
- [GitHub Copilot in VS Code](https://code.visualstudio.com/docs/copilot/overview)

docs/csharp/programming-guide/classes-and-structs/how-to-initialize-a-dictionary-with-a-collection-initializer.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ A <xref:System.Collections.Generic.Dictionary%602> contains a collection of key/
2424
> while the second part of example, the public read / write indexer method, quietly overwrites the already existing entry with the same key.
2525
2626
> [!TIP]
27-
> You can use AI assistance to [initialize a dictionary with GitHub Copilot](#use-github-copilot-to-initialize-a-dictionary).
27+
> You can use AI assistance to [initialize a dictionary](#use-ai-to-initialize-a-dictionary).
2828
2929
## Example
3030
@@ -34,9 +34,9 @@ In the following code example, a <xref:System.Collections.Generic.Dictionary%602
3434
3535
Note the two pairs of braces in each element of the collection in the first declaration. The innermost braces enclose the object initializer for the `StudentName`, and the outermost braces enclose the initializer for the key/value pair to be added to the `students` <xref:System.Collections.Generic.Dictionary%602>. Finally, the whole collection initializer for the dictionary is enclosed in braces. In the second initialization, the left side of the assignment is the key and the right side is the value, using an object initializer for `StudentName`.
3636
37-
## Use GitHub Copilot to initialize a dictionary
37+
## Use AI to initialize a dictionary
3838
39-
You can use GitHub Copilot in your IDE to generate C# code to initialize a dictionary with a collection initializer. You can customize the prompt to add specifics per your requirements.
39+
You can use AI tools, such as GitHub Copilot, to generate C# code to initialize a dictionary with a collection initializer. You can customize the prompt to add specifics per your requirements.
4040
4141
The following text shows an example prompt for Copilot Chat:
4242
@@ -46,8 +46,8 @@ Generate C# code to initialize Dictionary<int, Employee> using key-value pairs w
4646
4747
GitHub Copilot is powered by AI, so surprises and mistakes are possible. For more information, see [Copilot FAQs](https://aka.ms/copilot-general-use-faqs).
4848
49-
Learn more about [GitHub Copilot in Visual Studio](/visualstudio/ide/visual-studio-github-copilot-install-and-states) and [GitHub Copilot in VS Code](https://code.visualstudio.com/docs/copilot/overview).
50-
5149
## See also
5250
5351
- [Object and Collection Initializers](./object-and-collection-initializers.md)
52+
- [GitHub Copilot in Visual Studio](/visualstudio/ide/visual-studio-github-copilot-install-and-states)
53+
- [GitHub Copilot in VS Code](https://code.visualstudio.com/docs/copilot/overview)

docs/csharp/programming-guide/types/how-to-convert-a-string-to-a-number.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ It's slightly more efficient and straightforward to call a `TryParse` method (fo
2121
You use `Parse` or `TryParse` methods on the numeric type you expect the string contains, such as the <xref:System.Int32?displayProperty=nameWithType> type. The <xref:System.Convert.ToInt32%2A?displayProperty=nameWithType> method uses <xref:System.Int32.Parse%2A> internally. The `Parse` method returns the converted number; the `TryParse` method returns a boolean value that indicates whether the conversion succeeded, and returns the converted number in an `out` parameter. If the string isn't in a valid format, `Parse` throws an exception, but `TryParse` returns `false`. When calling a `Parse` method, you should always use exception handling to catch a <xref:System.FormatException> when the parse operation fails.
2222

2323
> [!TIP]
24-
> You can use AI assistance to [convert a string to a number with GitHub Copilot](#use-github-copilot-to-convert-a-string-to-a-number).
24+
> You can use AI assistance to [convert a string to a number](#use-ai-to-convert-a-string-to-a-number).
2525
2626
## Call Parse or TryParse methods
2727

@@ -55,9 +55,9 @@ The following example calls the <xref:System.Convert.ToInt32%28System.String%29?
5555

5656
[!code-csharp[Parsing with Convert methods](~/samples/snippets/csharp/programming-guide/string-to-number/convert/program.cs)]
5757

58-
## Use GitHub Copilot to convert a string to a number
58+
## Use AI to convert a string to a number
5959

60-
You can use GitHub Copilot in your IDE to generate C# code to convert a string to a number. You can customize the prompt to use a string per your requirements.
60+
You can use AI tools, such as GitHub Copilot, to generate C# code to convert a string to a number. You can customize the prompt to use a string per your requirements.
6161

6262
The following text shows an example prompt for Copilot Chat:
6363

@@ -67,4 +67,7 @@ Show me how to parse a string as a number, but don't throw an exception if the i
6767

6868
GitHub Copilot is powered by AI, so surprises and mistakes are possible. For more information, see [Copilot FAQs](https://aka.ms/copilot-general-use-faqs).
6969

70-
Learn more about [GitHub Copilot in Visual Studio](/visualstudio/ide/visual-studio-github-copilot-install-and-states) and [GitHub Copilot in VS Code](https://code.visualstudio.com/docs/copilot/overview).
70+
## See also
71+
72+
- [GitHub Copilot in Visual Studio](/visualstudio/ide/visual-studio-github-copilot-install-and-states)
73+
- [GitHub Copilot in VS Code](https://code.visualstudio.com/docs/copilot/overview)

docs/standard/serialization/system-text-json/customize-properties.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ By default, property names and dictionary keys are unchanged in the JSON output,
2929
> The [web default](configure-options.md#web-defaults-for-jsonserializeroptions) naming policy is camel case.
3030
3131
> [!TIP]
32-
> You can use AI assistance to [create an object with custom serialization properties with GitHub Copilot](#use-github-copilot-to-customize-how-property-names-are-serialized).
32+
> You can use AI assistance to [create an object with custom serialization properties](#use-ai-to-customize-how-property-names-are-serialized).
3333
3434
For other scenarios that require special handling of JSON property names and values, you can [implement custom converters](converters-how-to.md).
3535

@@ -243,9 +243,9 @@ By default, properties are serialized in the order in which they're defined in t
243243

244244
:::code language="csharp" source="snippets/how-to-6-0/csharp/PropertyOrder.cs":::
245245

246-
## Use GitHub Copilot to customize how property names are serialized
246+
## Use AI to customize how property names are serialized
247247

248-
You can prompt GitHub Copilot to apply patterns of changes to how your code serializes.
248+
You can use AI tools, such as GitHub Copilot, to apply patterns of changes to how your code serializes.
249249

250250
Suppose your class declaration has properties that follow `PascalCasing`, and the JSON standard for your project is `snake_casing`. You can use AI to add the necessary [[JsonPropertyName]](xref:System.Text.Json.Serialization.JsonPropertyNameAttribute) attributes to every property in your class. You can use Copilot to make these changes with a chat prompt like this:
251251

@@ -275,9 +275,9 @@ Use built-in serialization attributes.
275275

276276
GitHub Copilot is powered by AI, so surprises and mistakes are possible. For more information, see [Copilot FAQs](https://aka.ms/copilot-general-use-faqs).
277277

278-
Learn more about [GitHub Copilot in Visual Studio](/visualstudio/ide/visual-studio-github-copilot-install-and-states) and [GitHub Copilot in VS Code](https://code.visualstudio.com/docs/copilot/overview).
279-
280278
## See also
281279

282280
- [System.Text.Json overview](overview.md)
283281
- [How to serialize and deserialize JSON](how-to.md)
282+
- [GitHub Copilot in Visual Studio](/visualstudio/ide/visual-studio-github-copilot-install-and-states)
283+
- [GitHub Copilot in VS Code](https://code.visualstudio.com/docs/copilot/overview)

docs/standard/serialization/system-text-json/deserialization.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ This article shows how to use the <xref:System.Text.Json?displayProperty=fullNam
2222
A common way to deserialize JSON is to have (or create) a .NET class with properties and fields that represent one or more of the JSON properties. Then, to deserialize from a string or a file, call the <xref:System.Text.Json.JsonSerializer.Deserialize%2A?displayProperty=nameWithType> method. For the generic overloads, the generic type parameter is the .NET class. For the non-generic overloads, you pass the type of the class as a method parameter. You can deserialize either synchronously or asynchronously.
2323

2424
> [!TIP]
25-
> You can use AI assistance to [deserialize a JSON string with GitHub Copilot](#use-github-copilot-to-deserialize-json).
25+
> You can use AI assistance to [deserialize a JSON string](#use-ai-to-deserialize-json).
2626
2727
Any JSON properties that aren't represented in your class are ignored [by default](missing-members.md). Also, if any properties on the type are [required](required-properties.md) but not present in the JSON payload, deserialization will fail.
2828

@@ -87,9 +87,9 @@ To deserialize from UTF-8, call a <xref:System.Text.Json.JsonSerializer.Deserial
8787
:::code language="csharp" source="snippets/how-to/csharp/RoundtripToUtf8.cs" id="Deserialize2":::
8888
:::code language="vb" source="snippets/how-to/vb/RoundtripToUtf8.vb" id="Deserialize2":::
8989

90-
## Use GitHub Copilot to deserialize JSON
90+
## Use AI to deserialize JSON
9191

92-
You can use GitHub Copilot in your IDE to generate code that uses `System.Text.Json` to deserialize from JSON. You can customize the prompt to use a JSON string with property names and values that suit your requirements.
92+
You can use AI tools, such as GitHub Copilot, to generate code that uses `System.Text.Json` to deserialize from JSON. You can customize the prompt to use a JSON string with property names and values that suit your requirements.
9393

9494
The following text shows an example prompt for Copilot Chat:
9595

@@ -101,4 +101,7 @@ Provide example output.
101101

102102
GitHub Copilot is powered by AI, so surprises and mistakes are possible. For more information, see [Copilot FAQs](https://aka.ms/copilot-general-use-faqs).
103103

104-
Learn more about [GitHub Copilot in Visual Studio](/visualstudio/ide/visual-studio-github-copilot-install-and-states) and [GitHub Copilot in VS Code](https://code.visualstudio.com/docs/copilot/overview).
104+
## See also
105+
106+
- [GitHub Copilot in Visual Studio](/visualstudio/ide/visual-studio-github-copilot-install-and-states)
107+
- [GitHub Copilot in VS Code](https://code.visualstudio.com/docs/copilot/overview)

docs/standard/serialization/system-text-json/how-to.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ adobe-target: true
2121
This article shows how to use the <xref:System.Text.Json?displayProperty=fullName> namespace to serialize to JavaScript Object Notation (JSON). If you're porting existing code from `Newtonsoft.Json`, see [How to migrate to `System.Text.Json`](migrate-from-newtonsoft.md).
2222

2323
> [!TIP]
24-
> You can use AI assistance to [serialize to JSON with GitHub Copilot](#use-github-copilot-to-serialize-to-json).
24+
> You can use AI assistance to [serialize to JSON](#use-ai-to-serialize-to-json).
2525
2626
To write JSON to a string or to a file, call the <xref:System.Text.Json.JsonSerializer.Serialize%2A?displayProperty=nameWithType> method.
2727

@@ -49,7 +49,7 @@ The preceding examples use type inference for the type being serialized. An over
4949
:::code language="csharp" source="snippets/how-to/csharp/SerializeWithGenericParameter.cs" highlight="23":::
5050
:::code language="vb" source="snippets/how-to/vb/RoundtripToString.vb" id="SerializeWithGenericParameter":::
5151

52-
You can also use GitHub Copilot to generate serialization code for you. For instructions, see the [Use GitHub Copilot](#use-github-copilot-to-serialize-to-json) section in this article.
52+
You can also use AI to generate serialization code for you. For instructions, see the [Use AI](#use-ai-to-serialize-to-json) section in this article.
5353

5454
## Serialization behavior
5555

@@ -108,9 +108,9 @@ Starting in .NET 9, you can also customize the indent character and size using <
108108
> [!TIP]
109109
> If you use `JsonSerializerOptions` repeatedly with the same options, don't create a new `JsonSerializerOptions` instance each time you use it. Reuse the same instance for every call. For more information, see [Reuse JsonSerializerOptions instances](configure-options.md#reuse-jsonserializeroptions-instances).
110110
111-
## Use GitHub Copilot to serialize to JSON
111+
## Use AI to serialize to JSON
112112

113-
You can use GitHub Copilot in your IDE to generate code that uses `System.Text.Json` to serialize to JSON. You can customize the prompt to use object fields that suit your requirements.
113+
You can use AI tools, such as GitHub Copilot, to generate code that uses `System.Text.Json` to serialize to JSON. You can customize the prompt to use object fields that suit your requirements.
114114

115115
The following text shows an example prompt for Copilot Chat:
116116

@@ -122,4 +122,7 @@ Provide example output.
122122

123123
GitHub Copilot is powered by AI, so surprises and mistakes are possible. For more information, see [Copilot FAQs](https://aka.ms/copilot-general-use-faqs).
124124

125-
Learn more about [GitHub Copilot in Visual Studio](/visualstudio/ide/visual-studio-github-copilot-install-and-states) and [GitHub Copilot in VS Code](https://code.visualstudio.com/docs/copilot/overview).
125+
## See also
126+
127+
- [GitHub Copilot in Visual Studio](/visualstudio/ide/visual-studio-github-copilot-install-and-states)
128+
- [GitHub Copilot in VS Code](https://code.visualstudio.com/docs/copilot/overview)

docs/standard/serialization/system-text-json/migrate-from-newtonsoft.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The `System.Text.Json` namespace provides functionality for serializing to and d
2424
* .NET Core 2.0, 2.1, and 2.2
2525

2626
> [!TIP]
27-
> You can use AI assistance to [migrate from `Newtonsoft.Json`](#use-github-copilot-to-migrate).
27+
> You can use AI assistance to [migrate from `Newtonsoft.Json`](#use-ai-to-migrate).
2828
2929
`System.Text.Json` focuses primarily on performance, security, and standards compliance. It has some key differences in default behavior and doesn't aim to have feature parity with `Newtonsoft.Json`. For some scenarios, `System.Text.Json` currently has no built-in functionality, but there are recommended workarounds. For other scenarios, workarounds are impractical.
3030

@@ -630,9 +630,9 @@ System.Text.Json sets limits that can't be changed for some values, such as the
630630

631631
Newtonsoft parses `NaN`, `Infinity`, and `-Infinity` JSON string tokens. With System.Text.Json, use <xref:System.Text.Json.Serialization.JsonNumberHandling.AllowNamedFloatingPointLiterals?displayProperty=nameWithType>. For information about how to use this setting, see [Allow or write numbers in quotes](invalid-json.md#allow-or-write-numbers-in-quotes).
632632

633-
## Use GitHub Copilot to migrate
633+
## Use AI to migrate
634634

635-
You can get coding help from GitHub Copilot to migrate your code from `Newtonsoft.Json` to `System.Text.Json` within your IDE. You can customize the prompt per your requirements.
635+
You can use AI tools, such as GitHub Copilot, to migrate your code from `Newtonsoft.Json` to `System.Text.Json` within your IDE. You can customize the prompt per your requirements.
636636

637637
**Example prompt for Copilot Chat**
638638

@@ -651,9 +651,9 @@ Console.WriteLine(output);
651651

652652
GitHub Copilot is powered by AI, so surprises and mistakes are possible. For more information, see [Copilot FAQs](https://aka.ms/copilot-general-use-faqs).
653653

654-
Learn more about [GitHub Copilot in Visual Studio](/visualstudio/ide/visual-studio-github-copilot-install-and-states) and [GitHub Copilot in VS Code](https://code.visualstudio.com/docs/copilot/overview).
655-
656654
## Additional resources
657655

658656
* [System.Text.Json overview](overview.md)
659657
* [How to serialize and deserialize JSON](how-to.md)
658+
* [GitHub Copilot in Visual Studio](/visualstudio/ide/visual-studio-github-copilot-install-and-states)
659+
* [GitHub Copilot in VS Code](https://code.visualstudio.com/docs/copilot/overview)

0 commit comments

Comments
 (0)