Repository navigation
Fix ILVerify validation of interface MethodImpl bodies - #133670
Conversation
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
MethodImpl validation remains skipped for abstract types, default interface methods, and types with only inherited interfaces.
Review effort: Balanced
Findings: 1
What changed in this PR
Adds ILVerify validation for invalid interface MethodImpl bodies and supports static interface implementations.
Changes:
- Adds an
InvalidMethodImpldiagnostic. - Validates instance/static compatibility and virtual instance bodies.
- Adds regression IL cases.
| File | Description |
|---|---|
VerifierError.cs |
Defines the new error code. |
TypeVerifier.cs |
Adds MethodImpl validation and static resolution. |
Strings.resx |
Adds diagnostic text. |
InterfaceImplementation.il |
Adds valid and invalid regression cases. |
|
Thanks for this. I maintain an IL rewriter whose method bodies are gated on ILVerification (type-level checks aren't in that gate yet), so I ran this PR against a corpus. At f854d22, Beyond the PR's own tests, 30 hand-built cases against the CoreCLR 10.0.12 loader: nothing it accepts is flagged; 10 it rejects are newly caught. The misses we found also occur at the parent. The five cases below exercise the post-resolution check and the Note This comment was prepared with AI assistance (Anthropic Claude and OpenAI Codex), under my direction. I reviewed it before posting. Five extra cases for
|
Thanks! I've added all five test cases. |
|
/ba-g known issue #132291 |


Fixes #133500
Reject non-virtual instance
MethodImplbodies before interface resolution, which can return a virtual base method and hide the invalid mapping.Use the static resolver for static interface methods to allow valid non-virtual implementations.
And add regression tests.