Skip to content

Modernize C# code snippets - System/P*, System/R* - #12969

Open
gewarren wants to merge 4 commits into
dotnet:mainfrom
gewarren:modernize-code-system-r
Open

Modernize C# code snippets - System/P*, System/R*#12969
gewarren wants to merge 4 commits into
dotnet:mainfrom
gewarren:modernize-code-system-r

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/ParamArrayAttribute/Overview/Example.cs Preview published page
snippets/csharp/System/PlatformID/Overview/pid.cs Preview published page
snippets/csharp/System/PredicateT/Overview/predicate1.cs Preview published page
snippets/csharp/System/PredicateT/Overview/predicateex1.cs Preview published page
snippets/csharp/System/PredicateT/Overview/predicateex2.cs Preview published page
snippets/csharp/System/Random/.ctor/ctor.cs Preview published page
snippets/csharp/System/Random/Next/sample.cs Preview published page
snippets/csharp/System/Random/NextBytes/source.cs Preview published page
snippets/csharp/System/Random/NextDouble/nextdouble1.cs Preview published page
snippets/csharp/System/Random/Overview/booleans1.cs Preview published page
snippets/csharp/System/Random/Overview/booleans2.cs Preview published page
snippets/csharp/System/Random/Overview/doublerange1.cs Preview published page
snippets/csharp/System/Random/Overview/doublerange3.cs Preview published page
snippets/csharp/System/Random/Overview/long1.cs Preview published page
snippets/csharp/System/Random/Overview/next.cs Preview published page
snippets/csharp/System/Random/Overview/Next2.cs Preview published page
snippets/csharp/System/Random/Overview/Random2.cs Preview published page
snippets/csharp/System/Random/Overview/threadsafeex1.cs Preview published page
snippets/csharp/System/Random/Overview/threadsafeex2.cs Preview published page
snippets/csharp/System/Random/Overview/unique.cs Preview published page
snippets/csharp/System/Random/Overview/uniquearray1.cs Preview published page
snippets/csharp/System/ReadOnlySpanT/GetPinnableReference/getpinnablereference1.cs Preview published page
snippets/csharp/System/RuntimeTypeHandle/Overview/type_gettypehandle.cs Preview published page

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

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 a set of C# snippet sources under System/P*, System/R* to align with the ongoing repo effort to update samples for current C#/.NET style (Issue #12713).

Changes:

  • Replaced legacy formatting patterns (string.Format, composite formatting) with string interpolation and simplified output formatting.
  • Adopted modern C# syntax (target-typed new(), expression-bodied members, simplified array declarations, whitespace cleanup).
  • Normalized indentation and minor code-style cleanups across affected snippet files.

Reviewed changes

Copilot reviewed 23 out of 25 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
snippets/csharp/System/RuntimeTypeHandle/Overview/type_gettypehandle.cs Removes unused using and modernizes members/printing with target-typed new() and interpolation.
snippets/csharp/System/ReadOnlySpanT/GetPinnableReference/getpinnablereference1.cs Simplifies helper method to an expression-bodied member; preserves unsafe sample intent.
snippets/csharp/System/Random/Overview/uniquearray1.cs Updates ToString() and output formatting to interpolation; target-typed new().
snippets/csharp/System/Random/Overview/unique.cs Updates Console.WriteLine to interpolation for generated values.
snippets/csharp/System/Random/Overview/threadsafeex2.cs Uses target-typed new() and interpolated output strings in async/threading sample.
snippets/csharp/System/Random/Overview/threadsafeex1.cs Uses target-typed new() in constructor initialization.
snippets/csharp/System/Random/Overview/Random2.cs Converts composite format writes (with alignment) to interpolated writes.
snippets/csharp/System/Random/Overview/Next2.cs Reindents and converts aligned writes to interpolated writes.
snippets/csharp/System/Random/Overview/next.cs Cleans up whitespace/indentation in sample entrypoint.
snippets/csharp/System/Random/Overview/long1.cs Converts header/row composite formatting to interpolated strings with alignment.
snippets/csharp/System/Random/Overview/doublerange3.cs Converts composite formatting to a single interpolated output line.
snippets/csharp/System/Random/Overview/doublerange1.cs Converts header/row composite formatting to interpolated strings with alignment.
snippets/csharp/System/Random/Overview/booleans2.cs Consolidates output formatting and converts local function to expression-bodied.
snippets/csharp/System/Random/Overview/booleans1.cs Consolidates output formatting; modernizes ctor and boolean generator method bodies.
snippets/csharp/System/Random/NextDouble/nextdouble1.cs Reindents and partially modernizes declarations/spacing while keeping sample structure.
snippets/csharp/System/Random/NextBytes/source.cs Uses built-in aliases (byte) and target-typed new(); converts output to interpolation.
snippets/csharp/System/Random/Next/sample.cs Converts overrides and output formatting to expression-bodied members/interpolation; cleans up array declarations.
snippets/csharp/System/Random/.ctor/ctor4.cs Reindents and modernizes Random initialization and output formatting in ctor sample.
snippets/csharp/System/Random/.ctor/ctor1.cs Reindents and modernizes Random initialization and output formatting in ctor sample.
snippets/csharp/System/Random/.ctor/ctor.cs Modernizes loops, initialization, and some output formatting while preserving sample narrative.
snippets/csharp/System/PredicateT/Overview/predicateex2.cs Converts predicate method to expression-bodied and output to interpolation; reindents.
snippets/csharp/System/PredicateT/Overview/predicateex1.cs Converts output to interpolation and reindents sample.
snippets/csharp/System/PredicateT/Overview/predicate1.cs Modernizes properties to expression-bodied, target-typed new(), and interpolated output.
snippets/csharp/System/PlatformID/Overview/pid.cs Reindents switch sample and normalizes snippet marker formatting.
snippets/csharp/System/ParamArrayAttribute/Overview/Example.cs Modernizes members and exception formatting; updates string.IsNullOrEmpty usage and general style.

💡 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/ParamArrayAttribute/Overview/Example.cs Outdated
gewarren and others added 2 commits August 10, 2026 16:38
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@BillWagner BillWagner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Once again, this looks great, with a couple optional comments.

Comment thread snippets/csharp/System/ParamArrayAttribute/Overview/Example.cs Outdated
Co-authored-by: Bill Wagner <wiwagn@microsoft.com>
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