Add polyfills for System.Collections.Generic.CollectionExtensions#113
Add polyfills for System.Collections.Generic.CollectionExtensions#113
Conversation
…nlySet, AddRange, InsertRange, CopyTo) Agent-Logs-Url: https://github.com/Tyrrrz/PolyShim/sessions/9885706c-31a6-4c46-9b44-82b59b776ef5 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
…mplexity Agent-Logs-Url: https://github.com/Tyrrrz/PolyShim/sessions/9885706c-31a6-4c46-9b44-82b59b776ef5 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
|
@copilot getting build errors |
Agent-Logs-Url: https://github.com/Tyrrrz/PolyShim/sessions/18409385-512a-4dd8-9138-68578dd5cbd5 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds new polyfills for missing System.Collections.Generic.CollectionExtensions members across older TFMs, including span-based List<T> helpers, AsReadOnly() helpers, and ReadOnlySet<T> / IReadOnlySet<T> support (plus a C# 14 extension-resolution bridge for .NET 5–9).
Changes:
- Add
IDictionary<TKey,TValue>.TryAdd()andRemove(key, out value)polyfills for older TFMs. - Add .NET 5-era
AsReadOnly()polyfills forIList<T>/IDictionary<TKey,TValue>and introduceIReadOnlySet<T>. - Add .NET 8-era span-based
List<T>polyfills and .NET 9/10ReadOnlySet<T>+ISet<T>.AsReadOnly()polyfills (with a C# 14 bridge on .NET 5+).
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| PolyShim/NetCore20/CollectionExtensions.cs | Adds TryAdd and Remove(key, out value) extension member polyfills for IDictionary. |
| PolyShim/Net80/CollectionExtensions.cs | Adds span-based List<T> extension member polyfills (AddRange, InsertRange, CopyTo). |
| PolyShim/Net50/IReadOnlySet.cs | Introduces IReadOnlySet<T> polyfill for non-.NET 5+ TFMs. |
| PolyShim/Net50/CollectionExtensions.cs | Adds AsReadOnly() polyfills for IList<T> and IDictionary<TKey,TValue>. |
| PolyShim/Net90/ReadOnlySet.cs | Adds ReadOnlySet<T> implementation for pre-.NET 9 TFMs. |
| PolyShim/Net100/CollectionExtensions.cs | Adds ISet<T>.AsReadOnly() and C# 14 resolution bridge for AsReadOnly() overloads on .NET 5+. |
| PolyShim.Tests/NetCore20/CollectionExtensionsTests.cs | Adds tests for TryAdd/Remove(key, out) behavior. |
| PolyShim.Tests/Net80/CollectionExtensionsTests.cs | Adds tests for span-based List<T> polyfills. |
| PolyShim.Tests/Net50/CollectionExtensionsTests.cs | Adds tests for AsReadOnly() on IList<T>/IDictionary<TKey,TValue>. |
| PolyShim.Tests/Net100/CollectionExtensionsTests.cs | Adds tests for ISet<T>.AsReadOnly() / ReadOnlySet<T> behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Agent-Logs-Url: https://github.com/Tyrrrz/PolyShim/sessions/1903ca0b-50c2-4812-b4c5-e84ced90bd18 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Tyrrrz/PolyShim/sessions/cbfccb0e-99ce-455b-9963-4d365f5d3307 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Tyrrrz/PolyShim/sessions/53e094a7-44dd-4b1a-af0e-c126bd175baf Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Tyrrrz/PolyShim/sessions/4344dc90-91c5-489e-abe7-eb8c47f0a70d Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
…llectionExtensions.cs Agent-Logs-Url: https://github.com/Tyrrrz/PolyShim/sessions/733dace9-cebe-4aa5-ba99-6ecf278ef2cc Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
…-bodied extension methods Agent-Logs-Url: https://github.com/Tyrrrz/PolyShim/sessions/80f3ffae-446a-4985-bb82-99b181547214 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## prime #113 +/- ##
==========================================
+ Coverage 90.64% 90.66% +0.02%
==========================================
Files 275 282 +7
Lines 4776 4898 +122
Branches 394 401 +7
==========================================
+ Hits 4329 4441 +112
- Misses 358 367 +9
- Partials 89 90 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Adds polyfills covering the missing members of
CollectionExtensionsacross .NET versions.New polyfills
.NET Core 2.0 (
NetCore20/CollectionExtensions.cs)IDictionary<TKey,TValue>.TryAdd(key, value)IDictionary<TKey,TValue>.Remove(key, out value).NET 5.0 (
Net50/IReadOnlySet.cs)IReadOnlySet<T>interface.NET 7.0 (
Net70/CollectionExtensions.cs)IList<T>.AsReadOnly()→ReadOnlyCollection<T>IDictionary<TKey,TValue>.AsReadOnly()→ReadOnlyDictionary<TKey,TValue>.NET 8.0 (
Net80/CollectionExtensions.cs)List<T>.AddRange(ReadOnlySpan<T>)List<T>.InsertRange(int, ReadOnlySpan<T>)— delegates toList<T>.InsertRange(IEnumerable<T>)for O(n) complexityList<T>.CopyTo(Span<T>).NET 9.0 (
Net90/ReadOnlySet.cs)ReadOnlySet<T>— wrapsISet<T>, implementsIReadOnlySet<T>.NET 10.0 (
Net100/CollectionExtensions.cs)ISet<T>.AsReadOnly()→ReadOnlySet<T>