Skip to content

Modernize C# snippets (System.Collections.Generic) - #13005

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

Modernize C# snippets (System.Collections.Generic)#13005
gewarren wants to merge 2 commits into
dotnet:mainfrom
gewarren:modernize-code-system-collections-generic

Conversation

@gewarren

@gewarren gewarren commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Contributes to #12713.


Internal previews

Toggle expand/collapse
File Preview link
snippets/csharp/System.Collections.Generic/ComparerT/Overview/program.cs Preview published page
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/.ctor/source.cs Preview published page
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/.ctor/source1.cs Preview published page
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/.ctor/source2.cs Preview published page
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/.ctor/source3.cs Preview published page
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/.ctor/source4.cs Preview published page
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.cs Preview published page
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source2.cs Preview published page
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/System.Collections.IDictionary.Add/source.cs Preview published page
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/System.Collections.IDictionary.Contains/source.cs Preview published page
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/System.Collections.IDictionary.GetEnumerator/source.cs Preview published page
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/System.Collections.IDictionary.Item/source.cs Preview published page
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/System.Collections.IDictionary.Keys/source.cs Preview published page
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/System.Collections.IDictionary.Remove/source.cs Preview published page
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/System.Collections.IDictionary.Values/source.cs Preview published page
snippets/csharp/System.Collections.Generic/EqualityComparerT/Default/program.cs Preview published page
snippets/csharp/System.Collections.Generic/EqualityComparerT/Overview/program.cs Preview published page
snippets/csharp/System.Collections.Generic/HashSetT/.ctor/Program.cs Preview published page
snippets/csharp/System.Collections.Generic/HashSetT/.ctor/source2.cs Preview published page
snippets/csharp/System.Collections.Generic/HashSetT/Clear/Program.cs Preview published page
snippets/csharp/System.Collections.Generic/HashSetT/Contains/Program.cs Preview published page
snippets/csharp/System.Collections.Generic/HashSetT/IsProperSubsetOf/Program.cs Preview published page
snippets/csharp/System.Collections.Generic/HashSetT/Overview/Program.cs Preview published page
snippets/csharp/System.Collections.Generic/HashSetT/SymmetricExceptWith/Program.cs Preview published page
snippets/csharp/System.Collections.Generic/ICollectionT/Overview/program.cs Preview published page
snippets/csharp/System.Collections.Generic/IDictionaryTKey,TValue/Overview/source.cs Preview published page
snippets/csharp/System.Collections.Generic/IDictionaryTKey,TValue/Overview/source2.cs Preview published page
snippets/csharp/System.Collections.Generic/IEnumerableT/Overview/program.cs Preview published page
snippets/csharp/System.Collections.Generic/LinkedListNodeT/Overview/llnctor.cs Preview published page
snippets/csharp/System.Collections.Generic/LinkedListT/.ctor/llctor.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 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

Modernizes System.Collections.Generic C# documentation snippets and adds .NET 10 compilation harnesses for multi-example directories.

Changes:

  • Adopts collection expressions, target-typed new, built-in aliases, and consistent formatting.
  • Renames conflicting entry points and adds shared runners.
  • Adds .NET 10 projects and removes an obsolete package reference.

Reviewed changes

Copilot reviewed 92 out of 92 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
snippets/csharp/System.Collections.Generic/StackT/Overview/source.cs Modernizes stack syntax.
snippets/csharp/System.Collections.Generic/SortedSetT/Overview/program.cs Modernizes set construction and formatting.
snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/System.Collections.IDictionary.Add/source.cs Modernizes initialization and loops.
snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.cs Modernizes the overview example.
snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/Overview/remarks.cs Modernizes the remarks example.
snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/Overview/Project.csproj Adds a .NET 10 project.
snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/Overview/Program.cs Runs overview examples.
snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/.ctor/source4.cs Modernizes constructor example 5.
snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/.ctor/source3.cs Modernizes constructor example 4.
snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/.ctor/source2.cs Modernizes constructor example 3.
snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/.ctor/source1.cs Modernizes constructor example 2.
snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/.ctor/source.cs Modernizes constructor example 1.
snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/.ctor/Project.csproj Adds a .NET 10 project.
snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/.ctor/Program.cs Runs constructor examples.
snippets/csharp/System.Collections.Generic/SortedDictionaryTKey,TValue/System.Collections.IDictionary.Add/source.cs Modernizes initialization and loops.
snippets/csharp/System.Collections.Generic/SortedDictionaryTKey,TValue/Overview/source.cs Modernizes the overview example.
snippets/csharp/System.Collections.Generic/SortedDictionaryTKey,TValue/.ctor/source2.cs Modernizes constructor example 3.
snippets/csharp/System.Collections.Generic/SortedDictionaryTKey,TValue/.ctor/source1.cs Modernizes constructor example 2.
snippets/csharp/System.Collections.Generic/SortedDictionaryTKey,TValue/.ctor/source.cs Modernizes constructor example 1.
snippets/csharp/System.Collections.Generic/SortedDictionaryTKey,TValue/.ctor/Project.csproj Adds a .NET 10 project.
snippets/csharp/System.Collections.Generic/SortedDictionaryTKey,TValue/.ctor/Program.cs Runs constructor examples.
snippets/csharp/System.Collections.Generic/QueueT/Overview/source.cs Modernizes queue syntax.
snippets/csharp/System.Collections.Generic/ListT/Sort/Sort1.cs Modernizes and namespaces sort example 1.
snippets/csharp/System.Collections.Generic/ListT/Sort/RunExamples.cs Runs sort examples.
snippets/csharp/System.Collections.Generic/ListT/Sort/Project.csproj Adds a .NET 10 project.
snippets/csharp/System.Collections.Generic/ListT/Sort/program.cs Modernizes and namespaces sort example 2.
snippets/csharp/System.Collections.Generic/ListT/Reverse/source.cs Modernizes list initialization and loops.
snippets/csharp/System.Collections.Generic/ListT/Overview/source.cs Modernizes overview example 1.
snippets/csharp/System.Collections.Generic/ListT/Overview/RunExamples.cs Runs list overview examples.
snippets/csharp/System.Collections.Generic/ListT/Overview/Project.csproj Adds a .NET 10 project.
snippets/csharp/System.Collections.Generic/ListT/Overview/program.cs Modernizes overview example 2.
snippets/csharp/System.Collections.Generic/ListT/LastIndexOf/source.cs Modernizes list initialization.
snippets/csharp/System.Collections.Generic/ListT/IndexOf/source.cs Modernizes list initialization.
snippets/csharp/System.Collections.Generic/ListT/FindIndex/Project.csproj Adds a .NET 10 project.
snippets/csharp/System.Collections.Generic/ListT/FindIndex/Program.cs Runs FindIndex examples.
snippets/csharp/System.Collections.Generic/ListT/FindIndex/FindIndex3.cs Modernizes and namespaces example 3.
snippets/csharp/System.Collections.Generic/ListT/FindIndex/FindIndex2.cs Modernizes and namespaces example 2.
snippets/csharp/System.Collections.Generic/ListT/FindIndex/FindIndex1.cs Modernizes and namespaces example 1.
snippets/csharp/System.Collections.Generic/ListT/Find/program.cs Modernizes Find examples.
snippets/csharp/System.Collections.Generic/ListT/Exists/source.cs Modernizes list and string syntax.
snippets/csharp/System.Collections.Generic/ListT/CopyTo/source.cs Modernizes list initialization and loops.
snippets/csharp/System.Collections.Generic/ListT/Contains/program1.cs Modernizes part-list initialization.
snippets/csharp/System.Collections.Generic/ListT/Contains/program.cs Modernizes cube-list initialization.
snippets/csharp/System.Collections.Generic/ListT/Capacity/program.cs Uses an empty collection expression.
snippets/csharp/System.Collections.Generic/ListT/BinarySearch/source2.cs Modernizes and namespaces example 3.
snippets/csharp/System.Collections.Generic/ListT/BinarySearch/source1.cs Modernizes and namespaces example 2.
snippets/csharp/System.Collections.Generic/ListT/BinarySearch/source.cs Modernizes and namespaces example 1.
snippets/csharp/System.Collections.Generic/ListT/BinarySearch/Project.csproj Adds a .NET 10 project.
snippets/csharp/System.Collections.Generic/ListT/BinarySearch/Program.cs Runs BinarySearch examples.
snippets/csharp/System.Collections.Generic/ListT/.ctor/source1.cs Converts the example into a runnable class.
snippets/csharp/System.Collections.Generic/ListT/.ctor/source.cs Renames the constructor example.
snippets/csharp/System.Collections.Generic/ListT/.ctor/RunExamples.cs Runs list constructor examples.
snippets/csharp/System.Collections.Generic/LinkedListT/Overview/source.cs Modernizes linked-list syntax and output comments.
snippets/csharp/System.Collections.Generic/LinkedListT/.ctor/llctor.cs Uses aliases and target-typed construction.
snippets/csharp/System.Collections.Generic/LinkedListNodeT/Overview/llnctor.cs Modernizes formatting and construction.
snippets/csharp/System.Collections.Generic/IEnumerableT/Overview/program.cs Modernizes formatting and collection syntax.
snippets/csharp/System.Collections.Generic/IDictionaryTKey,TValue/Overview/source2.cs Modernizes overview example 2.
snippets/csharp/System.Collections.Generic/IDictionaryTKey,TValue/Overview/source.cs Modernizes overview example 1.
snippets/csharp/System.Collections.Generic/IDictionaryTKey,TValue/Overview/Project.csproj Adds a .NET 10 project.
snippets/csharp/System.Collections.Generic/IDictionaryTKey,TValue/Overview/Program.cs Runs interface overview examples.
snippets/csharp/System.Collections.Generic/ICollectionT/Overview/program.cs Modernizes collection initialization and formatting.
snippets/csharp/System.Collections.Generic/HashSetT/SymmetricExceptWith/Program.cs Uses empty collection expressions.
snippets/csharp/System.Collections.Generic/HashSetT/Overview/Program.cs Modernizes set construction.
snippets/csharp/System.Collections.Generic/HashSetT/IsProperSubsetOf/Program.cs Modernizes set construction and comments.
snippets/csharp/System.Collections.Generic/HashSetT/Contains/Program.cs Modernizes construction and braces.
snippets/csharp/System.Collections.Generic/HashSetT/Clear/Program.cs Uses an empty collection expression.
snippets/csharp/System.Collections.Generic/HashSetT/.ctor/source2.cs Modernizes constructor example 2.
snippets/csharp/System.Collections.Generic/HashSetT/.ctor/RunExamples.cs Runs HashSet constructor examples.
snippets/csharp/System.Collections.Generic/HashSetT/.ctor/Project.csproj Adds a .NET 10 project.
snippets/csharp/System.Collections.Generic/HashSetT/.ctor/Program.cs Converts example 1 to a shared runner.
snippets/csharp/System.Collections.Generic/EqualityComparerT/Overview/program.cs Uses aliases and target-typed construction.
snippets/csharp/System.Collections.Generic/EqualityComparerT/Default/program.cs Replaces inferred locals with explicit types.
snippets/csharp/System.Collections.Generic/EqualityComparerT/Default/cs.csproj Removes the obsolete ValueTuple package.
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/System.Collections.IDictionary.Values/source.cs Modernizes dictionary initialization and loops.
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/System.Collections.IDictionary.Remove/source.cs Modernizes dictionary initialization.
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/System.Collections.IDictionary.Keys/source.cs Modernizes dictionary initialization and loops.
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/System.Collections.IDictionary.Item/source.cs Modernizes dictionary initialization.
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/System.Collections.IDictionary.GetEnumerator/source.cs Modernizes initialization and enumeration.
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/System.Collections.IDictionary.Contains/source.cs Modernizes dictionary initialization.
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/System.Collections.IDictionary.Add/source.cs Modernizes initialization and loops.
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source2.cs Modernizes overview example 2.
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.cs Modernizes overview example 1.
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/Project.csproj Adds a .NET 10 project.
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/Program.cs Runs dictionary overview examples.
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/.ctor/source4.cs Modernizes constructor example 5.
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/.ctor/source3.cs Modernizes constructor example 4.
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/.ctor/source2.cs Modernizes constructor example 3.
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/.ctor/source1.cs Modernizes constructor example 2.
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/.ctor/source.cs Modernizes constructor example 1.
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/.ctor/Project.csproj Adds a .NET 10 project.
snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/.ctor/Program.cs Runs dictionary constructor examples.
snippets/csharp/System.Collections.Generic/ComparerT/Overview/program.cs Modernizes comparer example construction.

💡 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.Collections.Generic/ListT/.ctor/source1.cs Outdated
Comment thread snippets/csharp/System.Collections.Generic/LinkedListT/Overview/source.cs Outdated
Comment thread snippets/csharp/System.Collections.Generic/ListT/Sort/program.cs Outdated
Comment thread snippets/csharp/System.Collections.Generic/ListT/Contains/program1.cs Outdated
@gewarren
gewarren marked this pull request as ready for review August 19, 2026 19:42
@gewarren
gewarren requested a review from a team as a code owner August 19, 2026 19:42
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