Skip to content

Modernize C# code snippets - System/B* - #12946

Open
gewarren wants to merge 2 commits into
dotnet:mainfrom
gewarren:modernize-code-system-b
Open

Modernize C# code snippets - System/B*#12946
gewarren wants to merge 2 commits into
dotnet:mainfrom
gewarren:modernize-code-system-b

Conversation

@gewarren

@gewarren gewarren commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Contributes to #12713.


Internal previews

Toggle expand/collapse
File Preview link
snippets/csharp/System/BadImageFormatException/Overview/condition1.cs Preview published page
snippets/csharp/System/BadImageFormatException/Overview/stringlib.cs Preview published page
snippets/csharp/System/BadImageFormatException/Overview/targetplatform1.cs Preview published page
snippets/csharp/System/Base64FormattingOptions/Overview/ToBase64String.cs Preview published page
snippets/csharp/System/Base64FormattingOptions/Overview/ToBase64String2.cs Preview published page
snippets/csharp/System/Base64FormattingOptions/Overview/ToBase64String3.cs Preview published page
snippets/csharp/System/BitConverter/DoubleToInt64Bits/bitstodbl.cs Preview published page
snippets/csharp/System/BitConverter/DoubleToInt64Bits/dbltobits.cs Preview published page
snippets/csharp/System/BitConverter/GetBytes/bytesbool.cs Preview published page
snippets/csharp/System/BitConverter/GetBytes/byteschar.cs Preview published page
snippets/csharp/System/BitConverter/GetBytes/bytesdouble.cs Preview published page
snippets/csharp/System/BitConverter/GetBytes/bytesint16.cs Preview published page
snippets/csharp/System/BitConverter/GetBytes/bytesint32.cs Preview published page
snippets/csharp/System/BitConverter/GetBytes/bytesint64.cs Preview published page
snippets/csharp/System/BitConverter/GetBytes/bytessingle.cs Preview published page
snippets/csharp/System/BitConverter/GetBytes/bytesuint16.cs Preview published page
snippets/csharp/System/BitConverter/GetBytes/bytesuint32.cs Preview published page
snippets/csharp/System/BitConverter/GetBytes/bytesuint64.cs Preview published page
snippets/csharp/System/BitConverter/Overview/bitconv.cs Preview published page
snippets/csharp/System/BitConverter/Overview/example1.cs Preview published page
snippets/csharp/System/BitConverter/Overview/littleend.cs Preview published page
snippets/csharp/System/BitConverter/Overview/networkorder1.cs Preview published page
snippets/csharp/System/BitConverter/ToBoolean/batobool.cs Preview published page
snippets/csharp/System/BitConverter/ToBoolean/batochar.cs Preview published page
snippets/csharp/System/BitConverter/ToBoolean/batodouble.cs Preview published page
snippets/csharp/System/BitConverter/ToBoolean/batosingle.cs Preview published page
snippets/csharp/System/BitConverter/ToInt16/batoint16.cs Preview published page
snippets/csharp/System/BitConverter/ToInt16/batoint64.cs Preview published page
snippets/csharp/System/BitConverter/ToInt32/toint32.cs Preview published page
snippets/csharp/System/BitConverter/ToString/batostring.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 review requested due to automatic review settings August 6, 2026 19:45
@gewarren
gewarren requested a review from a team as a code owner August 6, 2026 19:45

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 large set of C# API documentation snippets under snippets/csharp (primarily System/Byte*, System/Buffer*, System/Boolean*, System/BitConverter*, System/Base64FormattingOptions*, and System/BadImageFormatException*) as part of issue #12713.

Changes:

  • Updates snippets to use modern C# syntax and formatting (built-in type aliases, target-typed new, interpolated strings, normalized spacing/indentation).
  • Refactors many Console.WriteLine calls from composite formatting to interpolated strings.
  • Performs small API-call modernizations (e.g., Byte.Parsebyte.Parse) while keeping the same APIs being demonstrated.

Reviewed changes

Copilot reviewed 49 out of 70 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
snippets/csharp/System/Byte/TryParse/TryParse2.cs Modernizes formatting, uses built-in aliases, and updates output formatting.
snippets/csharp/System/Byte/TryParse/TryParse.cs Modernizes iteration and output formatting with interpolated strings.
snippets/csharp/System/Byte/ToString/tostring.cs Updates formatting/output code and uses target-typed new.
snippets/csharp/System/Byte/ToString/NewByteMembers.cs Modernizes formatting and string output for Byte.ToString examples.
snippets/csharp/System/Byte/Parse/parse.cs Modernizes parsing examples with aliases and interpolated output.
snippets/csharp/System/Byte/Overview/ToByte5.cs Modernizes flow/formatting and uses interpolated strings.
snippets/csharp/System/Byte/Overview/tobyte4.cs Updates formatting, target-typed new, and output strings.
snippets/csharp/System/Byte/Overview/tobyte3.cs Modernizes IConvertible implementation style and initialization.
snippets/csharp/System/Byte/Overview/tobyte2.cs Modernizes loop structure and exception output formatting.
snippets/csharp/System/Byte/Overview/tobyte1.cs Modernizes many conversion examples with interpolated strings and aliases.
snippets/csharp/System/Byte/Overview/formatting1.cs Updates formatting output, interpolated strings, and minor spacing.
snippets/csharp/System/Byte/Overview/byteinstantiation1.cs Updates parsing calls to built-in aliases.
snippets/csharp/System/Byte/Overview/bitwise2.cs Uses built-in aliases and target-typed new for temporary objects.
snippets/csharp/System/Byte/Overview/bitwise1.cs Modernizes formatting/aliases and normalizes indentation.
snippets/csharp/System/Byte/Equals/eq.cs Normalizes indentation and updates output formatting.
snippets/csharp/System/Byte/CompareTo/systembyte.cs Modernizes a larger sample with aliases, target-typed new, and interpolated output.
snippets/csharp/System/Buffer/Overview/overlap1.cs Modernizes formatting and output printing.
snippets/csharp/System/Buffer/Overview/buffer.cs Updates array formatting/output and modernizes method signatures.
snippets/csharp/System/Buffer/Overview/bcopy.cs Modernizes formatting, string building, and output rendering.
snippets/csharp/System/Buffer/ByteLength/setbyte.cs Modernizes formatting and uses interpolated string construction for format strings.
snippets/csharp/System/Buffer/ByteLength/getbyte.cs Modernizes formatting, output, and method signatures.
snippets/csharp/System/Buffer/ByteLength/bytelength.cs Modernizes array declarations and output formatting.
snippets/csharp/System/Boolean/TryParse/tryparseex.cs Modernizes aliases and output formatting for parsing results.
snippets/csharp/System/Boolean/Parse/booleanmembers.cs Normalizes formatting and converts composite formatting to interpolation.
snippets/csharp/System/Boolean/Overview/tostring1.cs Normalizes indentation and keeps interpolated output.
snippets/csharp/System/Boolean/Overview/size1.cs Modernizes unsafe block formatting and uses target-typed new.
snippets/csharp/System/Boolean/Overview/parse3.cs Uses built-in aliases and normalizes loop/branch formatting.
snippets/csharp/System/Boolean/Overview/parse2.cs Uses built-in aliases and normalizes try/catch formatting.
snippets/csharp/System/Boolean/Overview/operations2.cs Uses built-in aliases and normalizes formatting.
snippets/csharp/System/Boolean/Overview/operations1.cs Modernizes argument handling and output formatting; preserves snippet markers.
snippets/csharp/System/Boolean/Overview/format3.cs Modernizes implementation of a custom formatter sample.
snippets/csharp/System/Boolean/Overview/conversion3.cs Normalizes indentation and formatting for numeric conversions.
snippets/csharp/System/Boolean/Overview/conversion1.cs Uses built-in aliases and normalizes formatting.
snippets/csharp/System/Boolean/Overview/binary1.cs Uses built-in aliases and modernizes array conversions.
snippets/csharp/System/Boolean/CompareTo/cat.cs Modernizes type aliases, target-typed new, and string output.
snippets/csharp/System/BitConverter/ToUInt16/batouint64.cs Normalizes formatting and output rendering.
snippets/csharp/System/BitConverter/ToUInt16/batouint32.cs Normalizes formatting and output rendering.
snippets/csharp/System/BitConverter/ToUInt16/batouint16.cs Normalizes formatting and output rendering.
snippets/csharp/System/BitConverter/ToString/batostringii.cs Normalizes formatting and method signatures.
snippets/csharp/System/BitConverter/ToString/batostring.cs Normalizes formatting and method signatures.
snippets/csharp/System/BitConverter/ToInt32/toint32.cs Uses built-in aliases and modernizes byte array formatting helper.
snippets/csharp/System/BitConverter/ToInt16/batoint64.cs Normalizes formatting and output rendering.
snippets/csharp/System/BitConverter/ToInt16/batoint32.cs Normalizes formatting and output rendering.
snippets/csharp/System/BitConverter/ToInt16/batoint16.cs Normalizes formatting and output rendering.
snippets/csharp/System/BitConverter/ToBoolean/batosingle.cs Normalizes formatting and output rendering.
snippets/csharp/System/BitConverter/ToBoolean/batodouble.cs Normalizes formatting and output rendering.
snippets/csharp/System/BitConverter/ToBoolean/batochar.cs Normalizes formatting and output rendering.
snippets/csharp/System/BitConverter/ToBoolean/batobool.cs Normalizes formatting and output rendering.
snippets/csharp/System/BitConverter/Overview/networkorder1.cs Normalizes formatting and uses interpolated output.
snippets/csharp/System/BitConverter/Overview/littleend.cs Normalizes formatting and uses interpolated output.
snippets/csharp/System/BitConverter/Overview/example1.cs Uses built-in aliases and interpolated strings for output.
snippets/csharp/System/BitConverter/Overview/bitconv.cs Normalizes formatting and output rendering.
snippets/csharp/System/BitConverter/GetBytes/bytesuint64.cs Normalizes formatting and method signatures.
snippets/csharp/System/BitConverter/GetBytes/bytesuint32.cs Normalizes formatting and method signatures.
snippets/csharp/System/BitConverter/GetBytes/bytesuint16.cs Normalizes formatting and method signatures.
snippets/csharp/System/BitConverter/GetBytes/bytessingle.cs Normalizes formatting and method signatures.
snippets/csharp/System/BitConverter/GetBytes/bytesint64.cs Converts table header/rows to interpolated formatting.
snippets/csharp/System/BitConverter/GetBytes/bytesint32.cs Converts table header/rows to interpolated formatting.
snippets/csharp/System/BitConverter/GetBytes/bytesint16.cs Normalizes formatting and method signatures.
snippets/csharp/System/BitConverter/GetBytes/bytesdouble.cs Normalizes formatting and method signatures.
snippets/csharp/System/BitConverter/GetBytes/byteschar.cs Normalizes formatting and method signatures.
snippets/csharp/System/BitConverter/GetBytes/bytesbool.cs Converts output to interpolated alignment formatting.
snippets/csharp/System/BitConverter/DoubleToInt64Bits/dbltobits.cs Normalizes formatting and method signatures.
snippets/csharp/System/BitConverter/DoubleToInt64Bits/bitstodbl.cs Normalizes formatting and method signatures.
snippets/csharp/System/Base64FormattingOptions/Overview/ToBase64String3.cs Modernizes output formatting for Base64 line-break example.
snippets/csharp/System/Base64FormattingOptions/Overview/ToBase64String2.cs Modernizes output formatting for round-tripping Base64.
snippets/csharp/System/Base64FormattingOptions/Overview/ToBase64String.cs Modernizes formatting while preserving Base64 encode/decode logic.
snippets/csharp/System/BadImageFormatException/Overview/targetplatform1.cs Modernizes argument handling/output formatting.
snippets/csharp/System/BadImageFormatException/Overview/stringlib.cs Normalizes formatting and indentation.
snippets/csharp/System/BadImageFormatException/Overview/condition1.cs Modernizes flow and output formatting for exception handling sample.

Comment thread snippets/csharp/System/Boolean/Overview/format3.cs
Comment thread snippets/csharp/System/Base64FormattingOptions/Overview/ToBase64String3.cs Outdated
Comment thread snippets/csharp/System/Base64FormattingOptions/Overview/ToBase64String.cs Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.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.

2 participants