Modernize C# code snippets - System/B* - #12946
Open
gewarren wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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.WriteLinecalls from composite formatting to interpolated strings. - Performs small API-call modernizations (e.g.,
Byte.Parse→byte.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. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.