Support implicit operators in method argument matching#977
Merged
Conversation
Agent-Logs-Url: https://github.com/zzzprojects/System.Linq.Dynamic.Core/sessions/82ed2f4e-0c76-407c-a330-d4043e96162f Co-authored-by: StefH <249938+StefH@users.noreply.github.com>
Agent-Logs-Url: https://github.com/zzzprojects/System.Linq.Dynamic.Core/sessions/82ed2f4e-0c76-407c-a330-d4043e96162f Co-authored-by: StefH <249938+StefH@users.noreply.github.com>
Agent-Logs-Url: https://github.com/zzzprojects/System.Linq.Dynamic.Core/sessions/82ed2f4e-0c76-407c-a330-d4043e96162f Co-authored-by: StefH <249938+StefH@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add support for implicit operators
Support implicit operators in method argument matching
Mar 29, 2026
…ConversionOperator Agent-Logs-Url: https://github.com/zzzprojects/System.Linq.Dynamic.Core/sessions/3d221836-ae46-4e82-b79f-a67b544ee3af Co-authored-by: StefH <249938+StefH@users.noreply.github.com>
| return sourceExpression; | ||
| } | ||
|
|
||
| // Check for implicit conversion operators (op_Implicit) from returnType to type. |
Contributor
Author
There was a problem hiding this comment.
Done in d0cc881. Added TryFindImplicitConversionOperator(Type sourceType, Type targetType, out MethodInfo? implicitOperator) to TypeHelper.cs, updated ExpressionPromoter.Promote and ExpressionParser.HasImplicitConversion to use it.
StefH
approved these changes
Mar 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a method parameter type differs from the passed argument type but an implicit operator exists between them, the parser failed with "No applicable method exists" — unlike plain C# which resolves such calls automatically.
Root cause
ExpressionPromoter.Promote(used byMethodFinder.IsApplicableto validate argument/parameter compatibility) had no knowledge ofop_Implicitoperators, so methods requiring implicit conversion were never considered applicable.Changes
ExpressionPromoter.cs— AfterTypeHelper.IsCompatibleWithfails, scanop_Implicitmethods on both the source and target types. If a matching operator is found (returnType → type), returnExpression.Convert(sourceExpression, type)to wire up the conversion.DynamicExpressionParserTests.cs— AddedMyStructWithImplicitOperator(struct withstring ↔ MyStructimplicit operators),MyMethodsWithImplicitOperatorSupport(a[DynamicLinqType]static class), and a test covering the scenario from the issue.Example
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.