Modernize C# code snippets - System/F* - #12966
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR modernizes several C# documentation snippets under snippets/csharp/System/* (notably Func*, FormatException, FormattableString, and FlagsAttribute) as part of the broader effort in dotnet-api-docs issue #12713.
Changes:
- Updates snippets to use modern C# features (target-typed
new(), expression-bodied members, andstring/decimalaliases). - Replaces many
String.Format(...)usages with interpolated strings and updates formatting/indentation for readability. - Simplifies some collection initializations and removes unused
usingdirectives.
Reviewed changes
Copilot reviewed 44 out of 56 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| snippets/csharp/System/FuncTResult/Overview/Lambda.cs | Modernizes object creation and formatting. |
| snippets/csharp/System/FuncTResult/Overview/Func1.cs | Modernizes object creation and formatting. |
| snippets/csharp/System/FuncTResult/Overview/Example.cs | Uses target-typed new and reindents. |
| snippets/csharp/System/FuncTResult/Overview/Delegate.cs | Modernizes object creation and formatting. |
| snippets/csharp/System/FuncTResult/Overview/Anon.cs | Modernizes delegate snippet formatting. |
| snippets/csharp/System/FuncT1,T2,TResult/Overview/Lambda.cs | Reindents and normalizes literals. |
| snippets/csharp/System/FuncT1,T2,TResult/Overview/Func3.cs | Reindents and normalizes literals. |
| snippets/csharp/System/FuncT1,T2,TResult/Overview/Example.cs | Uses string aliases and reindents. |
| snippets/csharp/System/FuncT1,T2,TResult/Overview/Delegate.cs | Reindents and normalizes literals. |
| snippets/csharp/System/FuncT1,T2,TResult/Overview/Anon.cs | Reindents anonymous method snippet. |
| snippets/csharp/System/FuncT1,T2,T3,TResult/Overview/Lambda.cs | Reindents parsing lambda snippet. |
| snippets/csharp/System/FuncT1,T2,T3,TResult/Overview/Func4.cs | Reindents parse delegate snippet. |
| snippets/csharp/System/FuncT1,T2,T3,TResult/Overview/Delegate.cs | Reindents custom delegate snippet. |
| snippets/csharp/System/FuncT1,T2,T3,TResult/Overview/Anon.cs | Reindents anonymous parse snippet. |
| snippets/csharp/System/FuncT1,T2,T3,T4,TResult/Overview/Lambda.cs | Updates output formatting to interpolation. |
| snippets/csharp/System/FuncT1,T2,T3,T4,TResult/Overview/Func5.cs | Updates output formatting to interpolation. |
| snippets/csharp/System/FuncT1,T2,T3,T4,TResult/Overview/Delegate.cs | Updates output formatting to interpolation. |
| snippets/csharp/System/FuncT1,T2,T3,T4,TResult/Overview/Anon.cs | Updates output formatting to interpolation. |
| snippets/csharp/System/FuncT,TResult/Overview/Lambda.cs | Reindents and modernizes lambda snippet. |
| snippets/csharp/System/FuncT,TResult/Overview/Func2_1.cs | Uses local function expression-body. |
| snippets/csharp/System/FuncT,TResult/Overview/Example.cs | Uses string aliases and removes unused using. |
| snippets/csharp/System/FuncT,TResult/Overview/Delegate.cs | Uses expression-bodied method and reindents. |
| snippets/csharp/System/FuncT,TResult/Overview/Anon.cs | Reindents anonymous method snippet. |
| snippets/csharp/System/FormattableString/Format/Composite1.cs | Converts several composites to interpolation. |
| snippets/csharp/System/FormatException/Overview/starting3.cs | Converts header/row formatting to interpolation. |
| snippets/csharp/System/FormatException/Overview/starting2.cs | Converts composite formatting to interpolation. |
| snippets/csharp/System/FormatException/Overview/starting1.cs | Converts some composites to interpolation. |
| snippets/csharp/System/FormatException/Overview/qa3.cs | Updates formatting examples and reindents. |
| snippets/csharp/System/FormatException/Overview/qa29.cs | Normalizes String.Format casing. |
| snippets/csharp/System/FormatException/Overview/qa28.cs | Normalizes String.Format casing. |
| snippets/csharp/System/FormatException/Overview/qa27.cs | Normalizes String.Format casing. |
| snippets/csharp/System/FormatException/Overview/qa26.cs | Normalizes foreach typing and format calls. |
| snippets/csharp/System/FormatException/Overview/qa21.cs | Modernizes Random construction and usings. |
| snippets/csharp/System/FormatException/Overview/qa2.cs | Modernizes Random construction and braces. |
| snippets/csharp/System/FormatException/Overview/qa11.cs | Modernizes Random construction and usings. |
| snippets/csharp/System/FormatException/Overview/qa1.cs | Modernizes Random construction and braces. |
| snippets/csharp/System/FormatException/Overview/qa-interpolated1.cs | Normalizes String.Format casing. |
| snippets/csharp/System/FormatException/Overview/interceptor2.cs | Modernizes formatter/provider sample. |
| snippets/csharp/System/FormatException/Overview/iformattable4.cs | Reindents parsing snippet. |
| snippets/csharp/System/FormatException/Overview/iformattable3.cs | Reindents parsing snippet. |
| snippets/csharp/System/FormatException/Overview/iformattable2.cs | Converts composite to interpolation. |
| snippets/csharp/System/FormatException/Overview/iformattable1.cs | Converts composite to interpolation. |
| snippets/csharp/System/FormatException/Overview/formatsyntax1.cs | Converts composite to interpolation. |
| snippets/csharp/System/FormatException/Overview/formatoverload2.cs | Updates output construction/formatting. |
| snippets/csharp/System/FormatException/Overview/formatoverload1.cs | Converts composite to interpolation. |
| snippets/csharp/System/FormatException/Overview/formatexample4.cs | Modernizes dictionary initialization. |
| snippets/csharp/System/FormatException/Overview/FormatExample2.cs | Modernizes custom formatter sample. |
| snippets/csharp/System/FormatException/Overview/format7.cs | Converts composite to interpolation. |
| snippets/csharp/System/FormatException/Overview/format5.cs | Converts composite to interpolation. |
| snippets/csharp/System/FormatException/Overview/format4.cs | Reindents and normalizes formatting. |
| snippets/csharp/System/FormatException/Overview/format_paramarray1.cs | Uses aliases/target-typed new. |
| snippets/csharp/System/FormatException/Overview/example3.cs | Converts one composite to interpolation. |
| snippets/csharp/System/FormatException/Overview/example2.cs | Normalizes type aliases and casing. |
| snippets/csharp/System/FormatException/Overview/example1.cs | Normalizes type aliases and casing. |
| snippets/csharp/System/FlagsAttribute/Overview/flags1.cs | Converts output to interpolation and reindents. |
| snippets/csharp/System/FlagsAttribute/Overview/flags.cs | Converts output to interpolation and reindents. |
Suppressed comments (1)
snippets/csharp/System/FormatException/Overview/FormatExample2.cs:15
- This line no longer uses CustomerFormatter. The sample expects the custom formatter to throw for the X specifier; with interpolation it will use the built-in numeric formatter instead.
Console.WriteLine($"{acctNumber:X}");
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…api-docs into modernize-code-system-f
wadepickett
reviewed
Aug 11, 2026
wadepickett
reviewed
Aug 11, 2026
Contributor
There was a problem hiding this comment.
@gewarren: Only spotted one issue in addition to what the copilot review already noted. See inline.
Co-authored-by: Wade Pickett <wpickett@microsoft.com>
wadepickett
approved these changes
Aug 11, 2026
wadepickett
left a comment
Contributor
There was a problem hiding this comment.
@gewarren, approved.
gewarren
enabled auto-merge (squash)
August 11, 2026 20:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contributes to #12713.
Internal previews
Toggle expand/collapse
Note
This table shows the first 30 preview links (sorted alphabetically by file path) found in the OPS build report. For the full list, select OpenPublishing.Build Details within checks.