Modernize C# snippets - Comparison{T}, System/L-O* - #12968
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR contributes to #12713 by modernizing a large set of C# snippet sources (primarily formatting plus newer C# idioms) across System.* API documentation snippet folders.
Changes:
- Modernized many snippets to use current C# style (target-typed
new, interpolated strings, expression-bodied members, and consistent brace/indent formatting). - Updated numerous snippets to prefer C# keyword aliases (
string,object,int, etc.) and simplified casts/constructors. - Refreshed assorted console output formatting patterns to be more idiomatic.
Reviewed changes
Copilot reviewed 102 out of 111 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| snippets/csharp/System/OverflowException/Overview/arithmetic1.cs | Modernize checked/try-catch snippet formatting and string output. |
| snippets/csharp/System/OutOfMemoryException/Overview/sb_example1.cs | Use target-typed new and interpolated output. |
| snippets/csharp/System/OutOfMemoryException/Overview/failfast1.cs | Modernize try/catch formatting and FailFast message construction. |
| snippets/csharp/System/OutOfMemoryException/Overview/data2.cs | Modernize numeric/loop code and output formatting. |
| snippets/csharp/System/OutOfMemoryException/Overview/data1.cs | Modernize collection usage and interpolated output. |
| snippets/csharp/System/OperatingSystem/VersionString/osvs.cs | Modernize indentation and interpolated output. |
| snippets/csharp/System/OperatingSystem/ToString/ctor_tostr.cs | Modernize construction calls and output formatting. |
| snippets/csharp/System/OperatingSystem/ServicePack/sp.cs | Use keyword aliases and interpolated output. |
| snippets/csharp/System/OperatingSystem/Platform/plat_ver.cs | Modernize object creation and output formatting. |
| snippets/csharp/System/OperatingSystem/Overview/osinfo1.cs | Convert formatted output to interpolated strings. |
| snippets/csharp/System/OperatingSystem/Clone/clone.cs | Modernize construction and output formatting. |
| snippets/csharp/System/ObsoleteAttribute/Overview/obsoleteattributeex1.cs | Simplify members to expression-bodied forms. |
| snippets/csharp/System/ObsoleteAttribute/IsError/obsoleteattribute_message.cs | Modernize reflection loop formatting and output. |
| snippets/csharp/System/ObjectDisposedException/Overview/objdispexc.cs | Use target-typed new and interpolated output. |
| snippets/csharp/System/ObjectDisposedException/Overview/dispose1.cs | Modernize timer snippet formatting and output. |
| snippets/csharp/System/Object/ToString/tostringoverload2.cs | Modernize locals/foreach and formatting. |
| snippets/csharp/System/Object/ToString/tostringoverload1.cs | Modernize properties and string formatting in ToString overloads. |
| snippets/csharp/System/Object/ToString/tostring3.cs | Use target-typed new and expression-bodied members. |
| snippets/csharp/System/Object/ToString/tostring2.cs | Formatting-only modernization. |
| snippets/csharp/System/Object/ToString/tostring1.cs | Use keyword aliases and target-typed new. |
| snippets/csharp/System/Object/ToString/customize2.cs | Modernize string formatting logic inside extension methods. |
| snippets/csharp/System/Object/ToString/customize1.cs | Modernize string building and initialization style. |
| snippets/csharp/System/Object/ToString/array1.cs | Use target-typed new for List<T> construction. |
| snippets/csharp/System/Object/ReferenceEquals/referenceequalsa.cs | Use keyword aliases and interpolated output. |
| snippets/csharp/System/Object/ReferenceEquals/referenceequals4.cs | Use keyword aliases and modern formatting. |
| snippets/csharp/System/Object/ReferenceEquals/referenceequals.cs | Formatting-only modernization. |
| snippets/csharp/System/Object/Overview/ObjectX.cs | Modernize style, expression-bodied members, and keyword aliases. |
| snippets/csharp/System/Object/MemberwiseClone/memberwiseclone1.cs | Use expression-bodied members and target-typed new. |
| snippets/csharp/System/Object/GetType/GetTypeEx2.cs | Modernize foreach typing and output formatting. |
| snippets/csharp/System/Object/GetType/gettype1.cs | Use interpolated output and keyword aliases. |
| snippets/csharp/System/Object/GetType/gettype.cs | Modernize class formatting and output. |
| snippets/csharp/System/Object/GetHashCode/xor2.cs | Modernize type keywords and expression-bodied members. |
| snippets/csharp/System/Object/GetHashCode/xor1.cs | Modernize type keywords and expression-bodied members. |
| snippets/csharp/System/Object/GetHashCode/shift1.cs | Modernize GetHashCode formatting and object creation. |
| snippets/csharp/System/Object/GetHashCode/direct1.cs | Modernize struct members and output formatting. |
| snippets/csharp/System/Object/Finalize/finalize1.cs | Use expression-bodied members and interpolated output. |
| snippets/csharp/System/Object/Finalize/finalize_safe.cs | Modernize SafeHandle construction and error message formatting. |
| snippets/csharp/System/Object/Equals/equalssb1.cs | Modernize object creation/casts and output formatting. |
| snippets/csharp/System/Object/Equals/equalsoverride.cs | Modernize constructors, overrides, and output formatting. |
| snippets/csharp/System/Object/Equals/equals4.cs | Modernize operators/overrides and output formatting. |
| snippets/csharp/System/Object/Equals/equals3.cs | Modernize constructors/overrides and ToString formatting. |
| snippets/csharp/System/Object/Equals/equals2.cs | Modernize overrides and formatting. |
| snippets/csharp/System/Object/Equals/equals_val2.cs | Modernize constructors/overrides and casts. |
| snippets/csharp/System/Object/Equals/equals_val1.cs | Modernize output formatting and indentation. |
| snippets/csharp/System/Object/Equals/equals_static2.cs | Modernize object creation and output formatting. |
| snippets/csharp/System/Object/Equals/equals_ref.cs | Modernize constructors, casts, and output formatting. |
| snippets/csharp/System/NullReferenceException/Overview/nullreturn2.cs | Use target-typed new and expression-bodied ctor. |
| snippets/csharp/System/NullReferenceException/Overview/example3.cs | Use expression-bodied member and explicit typing. |
| snippets/csharp/System/NullReferenceException/Overview/example2.cs | Use expression-bodied member for GetData. |
| snippets/csharp/System/NullReferenceException/Overview/Chain2.cs | Expression-bodied property getter. |
| snippets/csharp/System/NullReferenceException/Overview/Chain1.cs | Expression-bodied property getter. |
| snippets/csharp/System/NullReferenceException/Overview/Array2.cs | Modernize array initialization and output formatting. |
| snippets/csharp/System/NullReferenceException/Overview/Array1.cs | Modernize array initialization and output formatting. |
| snippets/csharp/System/NullableT/ToString/ts.cs | Modernize indentation, keyword aliases, and output formatting. |
| snippets/csharp/System/NullableT/Overview/tarow.cs | Modernize formatting and output strings. |
| snippets/csharp/System/NullableT/op_Explicit/explicit1.cs | Formatting-only modernization. |
| snippets/csharp/System/NullableT/HasValue/hasvalue2.cs | Modernize output strings and braces. |
| snippets/csharp/System/NullableT/GetValueOrDefault/gvod.cs | Modernize indentation and output formatting. |
| snippets/csharp/System/NullableT/Equals/eq.cs | Modernize indentation and comment formatting. |
| snippets/csharp/System/Nullable/GetUnderlyingType/gut.cs | Modernize comment indentation and output formatting. |
| snippets/csharp/System/NotSupportedException/Overview/TestProp2.cs | Use keyword aliases and interpolated output; modernize local typing. |
| snippets/csharp/System/NotSupportedException/Overview/TestProp1.cs | Use keyword aliases and interpolated output; modernize local typing. |
| snippets/csharp/System/NotSupportedException/Overview/BadState1.cs | Use keyword aliases, target-typed new, and modern array typing. |
| snippets/csharp/System/NotImplementedException/Overview/program.cs | Reformat and modernize try/catch layout. |
| snippets/csharp/System/MulticastDelegate/Overview/delegatestring.cs | Modernize generics usage, formatting, and output strings. |
| snippets/csharp/System/MissingFieldException/Overview/MissingMethodException.cs | Convert formatted output to interpolated strings and keyword aliases. |
| snippets/csharp/System/Math/Truncate/Truncate1.cs | Formatting-only modernization. |
| snippets/csharp/System/Math/Tanh/tanh.cs | Modernize output formatting with interpolation. |
| snippets/csharp/System/Math/Sqrt/sqrt1.cs | Modernize formatted output (alignment) using interpolation. |
| snippets/csharp/System/Math/Sign/sign.cs | Use keyword aliases and normalize alignment/spacing. |
| snippets/csharp/System/Math/Round/source1.cs | Reformat sample and keep snippet markers aligned. |
| snippets/csharp/System/Math/Round/source.cs | Reindent snippet markers and code layout. |
| snippets/csharp/System/Math/Round/rounddecimal1.cs | Modernize loop spacing and interpolated output. |
| snippets/csharp/System/Math/Round/round5.cs | Modernize loop formatting and output string building. |
| snippets/csharp/System/Math/Round/round4.cs | Modernize output strings to interpolation. |
| snippets/csharp/System/Math/Round/round3.cs | Modernize output strings to interpolation. |
| snippets/csharp/System/Math/Round/round2.cs | Modernize output strings to interpolation. |
| snippets/csharp/System/Math/Pow/pow1.cs | Modernize output formatting and indentation. |
| snippets/csharp/System/Math/Overview/mathsample.cs | Normalize indentation and modernize object creation. |
| snippets/csharp/System/Math/Min/min.cs | Normalize numeric declarations and spacing. |
| snippets/csharp/System/Math/Max/max.cs | Normalize numeric declarations and spacing. |
| snippets/csharp/System/Math/LogMethod/loggen.cs | Modernize output formatting and line breaks. |
| snippets/csharp/System/Math/LogMethod/log1.cs | Modernize output formatting to interpolation. |
| snippets/csharp/System/Math/Log10/log10.cs | Modernize double.MaxValue usage and output formatting. |
| snippets/csharp/System/Math/IEEERemainder/ieeeremainder1.cs | Modernize locals and output formatting. |
| snippets/csharp/System/Math/Exp/exp.cs | Modernize output formatting and line breaks. |
| snippets/csharp/System/Math/E/efield.cs | Modernize spacing and line breaks. |
| snippets/csharp/System/Math/DivRem/divrem2.cs | Modernize numeric constants and output formatting. |
| snippets/csharp/System/Math/DivRem/divrem1.cs | Modernize numeric constants and output formatting. |
| snippets/csharp/System/Math/Cosh/sinhcosh.cs | Modernize output formatting and line breaks. |
| snippets/csharp/System/Math/Cos/sincos.cs | Modernize output formatting and spacing; retain identity text. |
| snippets/csharp/System/Math/Ceiling/Ceiling1.cs | Modernize output formatting and array initializers. |
| snippets/csharp/System/Math/BigMul/bigmul.cs | Use keyword aliases and interpolated output. |
| snippets/csharp/System/Math/Atan/atan.cs | Use keyword aliases and interpolated output. |
| snippets/csharp/System/Math/Abs/abs7.cs | Use keyword aliases and normalized formatting. |
| snippets/csharp/System/Math/Abs/abs6.cs | Modernize try/catch formatting and output strings. |
| snippets/csharp/System/Math/Abs/abs5.cs | Modernize try/catch formatting and output strings. |
| snippets/csharp/System/Math/Abs/abs4.cs | Modernize try/catch formatting and output strings. |
| snippets/csharp/System/Math/Abs/abs3.cs | Modernize try/catch formatting and output strings. |
| snippets/csharp/System/Math/Abs/abs2.cs | Use keyword aliases and normalized formatting. |
| snippets/csharp/System/Math/Abs/Abs1.cs | Use keyword aliases and normalized formatting. |
| snippets/csharp/System/LazyT/Overview/lambda.cs | Use target-typed new, expression-bodied property, and spacing fixes. |
| snippets/csharp/System/LazyT/Overview/example.cs | Use target-typed new, expression-bodied property, and spacing fixes. |
| snippets/csharp/System/LazyT/.ctor/example5.cs | Use target-typed new, spacing fixes, and expression-bodied finalizer. |
| snippets/csharp/System/LazyT/.ctor/example4.cs | Modernize exception messages and thread/event handling formatting. |
| snippets/csharp/System/LazyT/.ctor/example3.cs | Use expression-bodied factory and interpolated output. |
| snippets/csharp/System/LazyT/.ctor/example2.cs | Use expression-bodied factory, spacing fixes, and interpolated output. |
| snippets/csharp/System/LazyT/.ctor/example1.cs | Use expression-bodied ctor with interpolated output. |
| snippets/csharp/System/LazyT/.ctor/example.cs | Use target-typed new, spacing fixes, and expression-bodied property. |
| snippets/csharp/System/ComparisonT/Overview/source.cs | Modernize list initialization, foreach formatting, and output. |
| snippets/csharp/System/ComparisonT/Overview/comparisont1.cs | Modernize construction, formatting, and output alignment. |
Suppressed comments (1)
snippets/csharp/System/OperatingSystem/Clone/clone.cs:20
- Same formatting issue as above: the constructor argument list starts at column 1 on the next line, which is confusing in a short docs snippet. Keep the
new(...)expression on a single properly indented line.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
gewarren
commented
Aug 10, 2026
Corrected the spelling of 'Dalmation' to 'Dalmatian' in the code and comments.
Collaborator
Author
|
Snippets 5000 error is expected and intentional. |
gewarren
enabled auto-merge (squash)
August 13, 2026 22:54
adegeo
approved these changes
Aug 13, 2026
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.