Add polyfills for IProgress<T>, Progress<T>, and EventHandler<T>#120
Add polyfills for IProgress<T>, Progress<T>, and EventHandler<T>#120
Conversation
Agent-Logs-Url: https://github.com/Tyrrrz/PolyShim/sessions/0a96a12f-80d9-4519-907a-e79c150cf0a6 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Tyrrrz/PolyShim/sessions/79555432-99f6-47b7-bdc5-00bc3ba358cf Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds PolyShim type polyfills for progress reporting (System.IProgress<T> and System.Progress<T>) on older target frameworks where these APIs are missing, along with signature list updates and basic behavioral tests.
Changes:
- Add
System.IProgress<T>polyfill for .NET Framework< 4.5and .NET Standard< 1.1. - Add
System.Progress<T>polyfill for .NET Framework< 4.5and .NET Standard< 1.3(withProgressChangedexcluded on older .NET Framework whereEventHandler<T>is constrained). - Update
Signatures.mdand addProgress<T>tests.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Signatures.md | Updates total/type counts and lists the newly added IProgress<T> and Progress<T> entries. |
| PolyShim/NetCore10/IProgress.cs | Introduces the System.IProgress<T> interface polyfill under older TFM guards. |
| PolyShim/NetCore10/Progress.cs | Introduces the System.Progress<T> implementation polyfill using SynchronizationContext. |
| PolyShim.Tests/NetCore10/ProgressTests.cs | Adds tests covering Report behavior for handler and event scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Agent-Logs-Url: https://github.com/Tyrrrz/PolyShim/sessions/92957363-d04e-40a4-a125-3628e9cc518f Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
| // ProgressChanged uses EventHandler<T> which requires T : EventArgs on .NET 3.5/4.0, | ||
| // so this test is only compiled on platforms where the event is available. | ||
| #if !NETFRAMEWORK || NET45_OR_GREATER |
There was a problem hiding this comment.
Yes — added EventHandler<T> polyfill in 8fb6a2e (PolyShim/NetCore10/EventHandler.cs, guarded to NETFRAMEWORK && !NET45_OR_GREATER) that declares the delegate without the where TEventArgs : EventArgs constraint. With that in place the #if guard is gone from both Progress.cs and the test, and ProgressChanged is now available on all polyfilled TFMs.
…ructor and is not null Agent-Logs-Url: https://github.com/Tyrrrz/PolyShim/sessions/29e8a6ad-0f5b-4461-a1b1-d3f0468d9de5 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Tyrrrz/PolyShim/sessions/1aefa506-e618-4d3b-a0c6-a0124243534f Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## prime #120 +/- ##
==========================================
+ Coverage 90.78% 90.83% +0.05%
==========================================
Files 284 285 +1
Lines 4935 4962 +27
Branches 404 404
==========================================
+ Hits 4480 4507 +27
Misses 365 365
Partials 90 90 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Agent-Logs-Url: https://github.com/Tyrrrz/PolyShim/sessions/16130bd1-c905-4796-b214-68efc9e6ebaa Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
…Handlers Agent-Logs-Url: https://github.com/Tyrrrz/PolyShim/sessions/4c010cd8-1ba3-41d5-a4f5-29c13a76cd56 Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Adds
IProgress<T>,Progress<T>, andEventHandler<T>polyfills for platforms that lack native support (.NET Framework < 4.5, .NET Standard < 1.1/1.3).New files
NetCore10/IProgress.cs—System.IProgress<T>interface polyfill, active onNETFRAMEWORK && !NET45_OR_GREATERorNETSTANDARD && !NETSTANDARD1_1_OR_GREATERNetCore10/Progress.cs—System.Progress<T>implementation, active onNETFRAMEWORK && !NET45_OR_GREATERorNETSTANDARD && !NETSTANDARD1_3_OR_GREATERNetCore10/EventHandler.cs—System.EventHandler<T>delegate polyfill without thewhere TEventArgs : EventArgsconstraint, active onNETFRAMEWORK && !NET45_OR_GREATERNotable details
EventHandler<TEventArgs>on net35/net40 enforcesTEventArgs : EventArgs. TheEventHandler<T>polyfill shadows the constrained BCL delegate for those TFMs, allowingProgress<T>.ProgressChangedto be declared and used with any unconstrainedTon all targets.