Repository navigation
Add MethodInfo.CreateDelegate<TDelegate> polyfills - #144
Conversation
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 #144 +/- ##
==========================================
+ Coverage 87.65% 87.71% +0.05%
==========================================
Files 339 341 +2
Lines 7389 7406 +17
Branches 539 539
==========================================
+ Hits 6477 6496 +19
+ Misses 744 742 -2
Partials 168 168 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The tests lack the namespace import required to compile against the polyfill on net472.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Adds .NET 5 generic MethodInfo.CreateDelegate<TDelegate> polyfills for older targets.
Changes:
- Implements both generic delegate-creation overloads.
- Adds tests and updates generated signatures.
| File | Description |
|---|---|
Signatures.md |
Documents the new members. |
PolyShim/Net50/MethodInfo.cs |
Implements the polyfills. |
PolyShim.Tests/Net50/MethodInfoTests.cs |
Tests both overloads. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
|
@copilot remove namespace declarations from both polyfill files. They should not need a |
Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Removed the namespace declarations, added the source-level reflection imports needed to resolve |

.NET 5 introduced generic overloads for
MethodInfo.CreateDelegate<TDelegate>()andMethodInfo.CreateDelegate<TDelegate>(object?), which were missing from the polyfill set.Polyfill
PolyShim/Net50/MethodInfo.cswith extension membersCreateDelegate<TDelegate>()andCreateDelegate<TDelegate>(object? target)onMethodInfo, constrained towhere TDelegate : Delegate.CreateDelegate(Type[, object])methods on frameworks that support them, and falls back to the staticDelegate.CreateDelegateoverloads on .NET Framework versions prior to 4.5, which lack the instance methods.Tests
PolyShim.Tests/Net50/MethodInfoTests.cscovering both the parameterless and the object-target overloads.Docs
Signatures.mdto include the newMethodInfoentries.