Skip to content

Modernize C# code snippets - System/F* - #12966

Merged
gewarren merged 6 commits into
dotnet:mainfrom
gewarren:modernize-code-system-f
Aug 11, 2026
Merged

Modernize C# code snippets - System/F*#12966
gewarren merged 6 commits into
dotnet:mainfrom
gewarren:modernize-code-system-f

Conversation

@gewarren

@gewarren gewarren commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Contributes to #12713.


Internal previews

Toggle expand/collapse
File Preview link
snippets/csharp/System/FlagsAttribute/Overview/flags.cs Preview published page
snippets/csharp/System/FlagsAttribute/Overview/flags1.cs Preview published page
snippets/csharp/System/FormatException/Overview/example1.cs Preview published page
snippets/csharp/System/FormatException/Overview/example2.cs Preview published page
snippets/csharp/System/FormatException/Overview/example3.cs Preview published page
snippets/csharp/System/FormatException/Overview/format_paramarray1.cs Preview published page
snippets/csharp/System/FormatException/Overview/format4.cs Preview published page
snippets/csharp/System/FormatException/Overview/format5.cs Preview published page
snippets/csharp/System/FormatException/Overview/format7.cs Preview published page
snippets/csharp/System/FormatException/Overview/FormatExample2.cs Preview published page
snippets/csharp/System/FormatException/Overview/formatexample4.cs Preview published page
snippets/csharp/System/FormatException/Overview/formatoverload1.cs Preview published page
snippets/csharp/System/FormatException/Overview/formatoverload2.cs Preview published page
snippets/csharp/System/FormatException/Overview/formatsyntax1.cs Preview published page
snippets/csharp/System/FormatException/Overview/iformattable1.cs Preview published page
snippets/csharp/System/FormatException/Overview/iformattable2.cs Preview published page
snippets/csharp/System/FormatException/Overview/iformattable3.cs Preview published page
snippets/csharp/System/FormatException/Overview/iformattable4.cs Preview published page
snippets/csharp/System/FormatException/Overview/interceptor2.cs Preview published page
snippets/csharp/System/FormatException/Overview/qa-interpolated1.cs Preview published page
snippets/csharp/System/FormatException/Overview/qa1.cs Preview published page
snippets/csharp/System/FormatException/Overview/qa11.cs Preview published page
snippets/csharp/System/FormatException/Overview/qa2.cs Preview published page
snippets/csharp/System/FormatException/Overview/qa21.cs Preview published page
snippets/csharp/System/FormatException/Overview/qa26.cs Preview published page
snippets/csharp/System/FormatException/Overview/qa27.cs Preview published page
snippets/csharp/System/FormatException/Overview/qa28.cs Preview published page
snippets/csharp/System/FormatException/Overview/qa29.cs Preview published page
snippets/csharp/System/FormatException/Overview/qa3.cs Preview published page
snippets/csharp/System/FormatException/Overview/starting1.cs Preview published page

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.

Copilot AI lite review requested due to automatic review settings August 10, 2026 23:07
@gewarren
gewarren requested a review from a team as a code owner August 10, 2026 23:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and string/decimal aliases).
  • Replaces many String.Format(...) usages with interpolated strings and updates formatting/indentation for readability.
  • Simplifies some collection initializations and removes unused using directives.

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.

Comment thread snippets/csharp/System/FormatException/Overview/FormatExample2.cs Outdated
Comment thread snippets/csharp/System/FormatException/Overview/interceptor2.cs Outdated
Comment thread snippets/csharp/System/FormatException/Overview/example1.cs
Comment thread snippets/csharp/System/FormatException/Overview/qa3.cs Outdated
Comment thread snippets/csharp/System/FuncTResult/Overview/Delegate.cs
Comment thread snippets/csharp/System/FuncTResult/Overview/Lambda.cs
Comment thread snippets/csharp/System/FuncTResult/Overview/Func1.cs
Comment thread snippets/csharp/System/FuncTResult/Overview/Anon.cs
gewarren and others added 4 commits August 10, 2026 16:30
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment thread snippets/csharp/System/FormatException/Overview/FormatExample2.cs Outdated

@wadepickett wadepickett left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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 wadepickett left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gewarren, approved.

@gewarren
gewarren enabled auto-merge (squash) August 11, 2026 20:47
@gewarren
gewarren merged commit c154531 into dotnet:main Aug 11, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants