Skip to content

Modernize C# snippets (System.Collections.Specialized) - #13006

Open
gewarren wants to merge 3 commits into
dotnet:mainfrom
gewarren:modernize-code-system-collections-specialized
Open

Modernize C# snippets (System.Collections.Specialized)#13006
gewarren wants to merge 3 commits into
dotnet:mainfrom
gewarren:modernize-code-system-collections-specialized

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.Specialized/BitVector32/CreateMask/bitvector32_createmasks.cs Preview published page
snippets/csharp/System.Collections.Specialized/BitVector32/Equals/bitvector32_equals.cs Preview published page
snippets/csharp/System.Collections.Specialized/BitVector32/Overview/bitvector32_bitflags.cs Preview published page
snippets/csharp/System.Collections.Specialized/BitVector32+Section/Overview/bitvector32_sections.cs Preview published page
snippets/csharp/System.Collections.Specialized/CollectionsUtil/Overview/source.cs Preview published page
snippets/csharp/System.Collections.Specialized/HybridDictionary/Add/hybriddictionary_addremove.cs Preview published page
snippets/csharp/System.Collections.Specialized/HybridDictionary/Contains/hybriddictionary_contains.cs Preview published page
snippets/csharp/System.Collections.Specialized/HybridDictionary/CopyTo/hybriddictionary_copyto.cs Preview published page
snippets/csharp/System.Collections.Specialized/HybridDictionary/Count/hybriddictionary_enumerator.cs Preview published page
snippets/csharp/System.Collections.Specialized/HybridDictionary/Overview/hybriddictionary.cs Preview published page
snippets/csharp/System.Collections.Specialized/HybridDictionary/Overview/source2.cs Preview published page
snippets/csharp/System.Collections.Specialized/IOrderedDictionary/Overview/iordereddictionary.cs Preview published page
snippets/csharp/System.Collections.Specialized/ListDictionary/Add/listdictionary_addremove.cs Preview published page
snippets/csharp/System.Collections.Specialized/ListDictionary/Contains/listdictionary_contains.cs Preview published page
snippets/csharp/System.Collections.Specialized/ListDictionary/CopyTo/listdictionary_copyto.cs Preview published page
snippets/csharp/System.Collections.Specialized/ListDictionary/Count/listdictionary_enumerator.cs Preview published page
snippets/csharp/System.Collections.Specialized/ListDictionary/Overview/listdictionary.cs Preview published page
snippets/csharp/System.Collections.Specialized/ListDictionary/Overview/source2.cs Preview published page
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseAdd/nocb_baseadd.cs Preview published page
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseClear/nocb_baseclear.cs Preview published page
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseGetAllKeys/nocb_basegetall.cs Preview published page
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseGetKey/nocb_baseget.cs Preview published page
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseHasKeys/nocb_basehaskeys.cs Preview published page
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseRemove/nocb_baseremove.cs Preview published page
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseSet/nocb_baseset.cs Preview published page
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/IsReadOnly/nocb_isreadonly.cs Preview published page
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/Overview/nameobjectcollectionbase.cs Preview published page
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/Overview/remarks.cs Preview published page
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase+KeysCollection/System.Collections.ICollection.IsSynchronized/source.cs Preview published page
snippets/csharp/System.Collections.Specialized/NameValueCollection/Overview/nvc.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.Specialized C# snippets for issue #12713.

Changes:

  • Adopts current C# syntax and formatting.
  • Converts snippet projects into executable .NET 10 projects.
  • Adds runners for folders containing multiple samples.

Reviewed changes

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

Show a summary per file
File Description
snippets/csharp/System.Collections.Specialized/StringEnumerator/Overview/stringenumerator.cs Modernizes the enumerator sample.
snippets/csharp/System.Collections.Specialized/StringEnumerator/Overview/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/StringDictionary/Overview/stringdictionary.cs Modernizes the dictionary overview.
snippets/csharp/System.Collections.Specialized/StringDictionary/Overview/source2.cs Modernizes and renames the synchronization sample.
snippets/csharp/System.Collections.Specialized/StringDictionary/Overview/Project.csproj Adds an executable project.
snippets/csharp/System.Collections.Specialized/StringDictionary/Overview/Program.cs Runs both overview samples.
snippets/csharp/System.Collections.Specialized/StringDictionary/Count/values.cs Modernizes the values sample.
snippets/csharp/System.Collections.Specialized/StringDictionary/Count/stringdictionary_enumeration.cs Modernizes the enumeration sample.
snippets/csharp/System.Collections.Specialized/StringDictionary/Count/Project.csproj Adds an executable project.
snippets/csharp/System.Collections.Specialized/StringDictionary/Count/Program.cs Runs both count samples.
snippets/csharp/System.Collections.Specialized/StringDictionary/CopyTo/stringdictionary_copyto.cs Modernizes the copy sample.
snippets/csharp/System.Collections.Specialized/StringDictionary/CopyTo/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/StringDictionary/ContainsKey/stringdictionary_contains.cs Modernizes the lookup sample.
snippets/csharp/System.Collections.Specialized/StringDictionary/ContainsKey/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/StringDictionary/Add/stringdictionary_addremove.cs Modernizes add/remove operations.
snippets/csharp/System.Collections.Specialized/StringDictionary/Add/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/StringCollection/Overview/stringcollection.cs Modernizes the collection overview.
snippets/csharp/System.Collections.Specialized/StringCollection/Overview/remarks.cs Modernizes and renames the synchronization sample.
snippets/csharp/System.Collections.Specialized/StringCollection/Overview/Project.csproj Adds an executable project.
snippets/csharp/System.Collections.Specialized/StringCollection/Overview/Program.cs Runs both overview samples.
snippets/csharp/System.Collections.Specialized/StringCollection/CopyTo/stringcollectioncopyto.cs Modernizes the copy sample.
snippets/csharp/System.Collections.Specialized/StringCollection/CopyTo/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/StringCollection/Contains/stringcollectioncontains.cs Modernizes the containment sample.
snippets/csharp/System.Collections.Specialized/StringCollection/Contains/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/StringCollection/Clear/stringcollectionremove.cs Modernizes removal and clearing.
snippets/csharp/System.Collections.Specialized/StringCollection/Clear/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/StringCollection/Add/stringcollectionadd.cs Modernizes collection additions.
snippets/csharp/System.Collections.Specialized/StringCollection/Add/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/OrderedDictionary/Overview/source2.cs Modernizes and renames the secondary sample.
snippets/csharp/System.Collections.Specialized/OrderedDictionary/Overview/Project.csproj Adds an executable project.
snippets/csharp/System.Collections.Specialized/OrderedDictionary/Overview/Program.cs Runs both overview samples.
snippets/csharp/System.Collections.Specialized/OrderedDictionary/Overview/OrderedDictionary1.cs Modernizes dictionary operations and comments.
snippets/csharp/System.Collections.Specialized/NameValueCollection/Overview/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/NameValueCollection/Overview/nvc.cs Modernizes the overview sample.
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase+KeysCollection/System.Collections.ICollection.IsSynchronized/source.cs Modernizes the derived collection sample.
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase+KeysCollection/System.Collections.ICollection.IsSynchronized/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/Overview/remarks.cs Modernizes and renames the synchronization sample.
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/Overview/Project.csproj Adds an executable project.
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/Overview/Program.cs Runs both overview samples.
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/Overview/nameobjectcollectionbase.cs Modernizes the primary overview sample.
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/IsReadOnly/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/IsReadOnly/nocb_isreadonly.cs Modernizes the read-only sample.
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseSet/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseSet/nocb_baseset.cs Modernizes the BaseSet sample.
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseRemove/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseRemove/nocb_baseremove.cs Modernizes the removal sample.
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseHasKeys/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseHasKeys/nocb_basehaskeys.cs Modernizes the key-checking sample.
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseGetKey/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseGetKey/nocb_baseget.cs Modernizes the key retrieval sample.
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseGetAllKeys/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseGetAllKeys/nocb_basegetall.cs Modernizes key and value retrieval.
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseClear/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseClear/nocb_baseclear.cs Modernizes the clearing sample.
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseAdd/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseAdd/nocb_baseadd.cs Modernizes the addition sample.
snippets/csharp/System.Collections.Specialized/ListDictionary/Overview/source2.cs Modernizes and renames the synchronization sample.
snippets/csharp/System.Collections.Specialized/ListDictionary/Overview/Project.csproj Adds an executable project.
snippets/csharp/System.Collections.Specialized/ListDictionary/Overview/Program.cs Runs both overview samples.
snippets/csharp/System.Collections.Specialized/ListDictionary/Overview/listdictionary.cs Modernizes the dictionary overview.
snippets/csharp/System.Collections.Specialized/ListDictionary/Count/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/ListDictionary/Count/listdictionary_enumerator.cs Modernizes enumeration examples.
snippets/csharp/System.Collections.Specialized/ListDictionary/CopyTo/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/ListDictionary/CopyTo/listdictionary_copyto.cs Modernizes the copy sample.
snippets/csharp/System.Collections.Specialized/ListDictionary/Contains/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/ListDictionary/Contains/listdictionary_contains.cs Modernizes the lookup sample.
snippets/csharp/System.Collections.Specialized/ListDictionary/Add/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/ListDictionary/Add/listdictionary_addremove.cs Modernizes add/remove operations.
snippets/csharp/System.Collections.Specialized/IOrderedDictionary/Overview/remarks.cs Modernizes the secondary implementation.
snippets/csharp/System.Collections.Specialized/IOrderedDictionary/Overview/Project.csproj Adds an executable project.
snippets/csharp/System.Collections.Specialized/IOrderedDictionary/Overview/Program.cs Runs both implementations.
snippets/csharp/System.Collections.Specialized/IOrderedDictionary/Overview/iordereddictionary.cs Modernizes the primary implementation.
snippets/csharp/System.Collections.Specialized/HybridDictionary/Overview/source2.cs Modernizes the secondary sample.
snippets/csharp/System.Collections.Specialized/HybridDictionary/Overview/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/HybridDictionary/Overview/Program.cs Runs both overview samples.
snippets/csharp/System.Collections.Specialized/HybridDictionary/Overview/hybriddictionary.cs Modernizes the dictionary overview.
snippets/csharp/System.Collections.Specialized/HybridDictionary/Count/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/HybridDictionary/Count/hybriddictionary_enumerator.cs Modernizes enumeration examples.
snippets/csharp/System.Collections.Specialized/HybridDictionary/CopyTo/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/HybridDictionary/CopyTo/hybriddictionary_copyto.cs Modernizes the copy sample.
snippets/csharp/System.Collections.Specialized/HybridDictionary/Contains/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/HybridDictionary/Contains/hybriddictionary_contains.cs Modernizes the lookup sample.
snippets/csharp/System.Collections.Specialized/HybridDictionary/Add/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/HybridDictionary/Add/hybriddictionary_addremove.cs Modernizes add/remove operations.
snippets/csharp/System.Collections.Specialized/CollectionsUtil/Overview/source.cs Modernizes output formatting.
snippets/csharp/System.Collections.Specialized/CollectionsUtil/Overview/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/BitVector32+Section/Overview/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/BitVector32+Section/Overview/bitvector32_sections.cs Modernizes the section sample.
snippets/csharp/System.Collections.Specialized/BitVector32/Overview/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/BitVector32/Overview/bitvector32_bitflags.cs Modernizes the bit-flag sample.
snippets/csharp/System.Collections.Specialized/BitVector32/Equals/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/BitVector32/Equals/bitvector32_equals.cs Modernizes comparison examples.
snippets/csharp/System.Collections.Specialized/BitVector32/CreateMask/Project.csproj Makes the project executable.
snippets/csharp/System.Collections.Specialized/BitVector32/CreateMask/bitvector32_createmasks.cs Modernizes mask creation.
Suppressed comments (1)

snippets/csharp/System.Collections.Specialized/IOrderedDictionary/Overview/remarks.cs:136

  • ArrayList(int) reserves capacity but doesn't create elements. Because ValueCollection is still empty, assigning ValueCollection[i] throws ArgumentOutOfRangeException for every nonempty SimpleOD; populate it with Add instead.
            ArrayList ValueCollection = new(itemlist.Count);

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@gewarren
gewarren marked this pull request as ready for review August 19, 2026 18:25
@gewarren
gewarren requested a review from a team as a code owner August 19, 2026 18:25
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