Skip to content

Implement polymorphic dispatch error handling and add tests for derived member resolution#77

Open
koenbeuk wants to merge 1 commit into
mainfrom
fix/unresolvable-polymorphic-dispatch-message
Open

Implement polymorphic dispatch error handling and add tests for derived member resolution#77
koenbeuk wants to merge 1 commit into
mainfrom
fix/unresolvable-polymorphic-dispatch-message

Conversation

@koenbeuk

Copy link
Copy Markdown
Collaborator

small QOL improvement to show a better exception message when polymorphic dispatch fails due to missing generated expressions on derived members.

Copilot AI review requested due to automatic review settings July 26, 2026 00:50
@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/ExpressiveSharp/Services/ExpressiveReplacer.cs 75.00% 2 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the runtime experience around polymorphic dispatch of virtual/override [Expressive] members by surfacing a more actionable exception when an override’s expression cannot be resolved, and it adds coverage to validate both the new error message and resolver-isolation expectations.

Changes:

  • Add a dedicated polymorphic-dispatch probe (TryGetReflectedExpressionForDispatch) that wraps resolver failures with remediation guidance.
  • Add a test ensuring a derived-override resolution failure produces an actionable InvalidOperationException with an inner exception.
  • Add a test asserting polymorphic plan caching does not leak derived-override discovery across different resolvers.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tests/ExpressiveSharp.Tests/Services/ExpressiveReplacerTests.cs Adds tests for actionable polymorphic-dispatch failure messaging and for resolver-isolated polymorphic plan behavior.
src/ExpressiveSharp/Services/ExpressiveReplacer.cs Introduces a dispatch-specific resolver probe that wraps failures with a more actionable exception message.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 359 to 363
private PolymorphicPlan BuildPolymorphicPlan(Type rootType, MemberInfo baseMember)
{
var rootMember = ResolveConcreteMember(rootType, baseMember) ?? baseMember;
var rootRegistered = TryGetReflectedExpressionSafe(rootMember, out _);
var rootRegistered = TryGetReflectedExpressionForDispatch(rootMember, baseMember, out _);

Comment on lines +474 to +475
$"Polymorphic dispatch for '{baseMember.DeclaringType}.{baseMember.Name}' requires the generated " +
$"expression for [Expressive] member '{memberInfo.DeclaringType}.{memberInfo.Name}', which could not " +
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants