Skip to content

Add polyfills for IProgress<T>, Progress<T>, and EventHandler<T>#120

Merged
Tyrrrz merged 10 commits intoprimefrom
copilot/add-polyfill-for-progress
Apr 17, 2026
Merged

Add polyfills for IProgress<T>, Progress<T>, and EventHandler<T>#120
Tyrrrz merged 10 commits intoprimefrom
copilot/add-polyfill-for-progress

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 17, 2026

Adds IProgress<T>, Progress<T>, and EventHandler<T> polyfills for platforms that lack native support (.NET Framework < 4.5, .NET Standard < 1.1/1.3).

New files

  • NetCore10/IProgress.csSystem.IProgress<T> interface polyfill, active on NETFRAMEWORK && !NET45_OR_GREATER or NETSTANDARD && !NETSTANDARD1_1_OR_GREATER
  • NetCore10/Progress.csSystem.Progress<T> implementation, active on NETFRAMEWORK && !NET45_OR_GREATER or NETSTANDARD && !NETSTANDARD1_3_OR_GREATER
  • NetCore10/EventHandler.csSystem.EventHandler<T> delegate polyfill without the where TEventArgs : EventArgs constraint, active on NETFRAMEWORK && !NET45_OR_GREATER

Notable details

EventHandler<TEventArgs> on net35/net40 enforces TEventArgs : EventArgs. The EventHandler<T> polyfill shadows the constrained BCL delegate for those TFMs, allowing Progress<T>.ProgressChanged to be declared and used with any unconstrained T on all targets.

// Works everywhere, including net35/net40
IProgress<int> progress = new Progress<int>(v => Console.WriteLine(v));
progress.Report(42);

// ProgressChanged is also available on all polyfilled targets
var p = new Progress<int>();
p.ProgressChanged += (_, v) => Console.WriteLine(v);

Agent-Logs-Url: https://github.com/Tyrrrz/PolyShim/sessions/0a96a12f-80d9-4519-907a-e79c150cf0a6

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
@Tyrrrz Tyrrrz added the enhancement New feature or request label Apr 17, 2026
@Tyrrrz Tyrrrz marked this pull request as ready for review April 17, 2026 13:46
Copilot AI review requested due to automatic review settings April 17, 2026 13:46
Comment thread PolyShim.Tests/NetCore10/ProgressTests.cs
Agent-Logs-Url: https://github.com/Tyrrrz/PolyShim/sessions/79555432-99f6-47b7-bdc5-00bc3ba358cf

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Comment thread PolyShim.Tests/NetCore10/ProgressTests.cs Outdated
Comment thread PolyShim/NetCore10/Progress.cs Outdated
Comment thread PolyShim/NetCore10/Progress.cs Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.5 and .NET Standard < 1.1.
  • Add System.Progress<T> polyfill for .NET Framework < 4.5 and .NET Standard < 1.3 (with ProgressChanged excluded on older .NET Framework where EventHandler<T> is constrained).
  • Update Signatures.md and add Progress<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.

Comment thread PolyShim/NetCore10/Progress.cs Outdated
Comment thread PolyShim/NetCore10/Progress.cs Outdated
Comment thread PolyShim/NetCore10/Progress.cs Outdated
Comment on lines +30 to +32
// 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
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we polyfill that too? @copilot

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copilot AI changed the title Add polyfills for IProgress<T> and Progress<T> Add polyfills for IProgress&lt;T&gt;, Progress&lt;T&gt;, and EventHandler&lt;T&gt; Apr 17, 2026
Comment thread PolyShim/NetCore10/Progress.cs Outdated
Comment thread PolyShim/NetCore10/Progress.cs Outdated
Comment thread PolyShim/NetCore10/Progress.cs
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.83%. Comparing base (3ccd557) to head (a9f6af6).
⚠️ Report is 1 commits behind head on prime.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI requested a review from Tyrrrz April 17, 2026 15:10
Copilot AI requested a review from Tyrrrz April 17, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants