Skip to content

Disable lambda conversion in normal bindings #1928

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

exyi
Copy link
Member

@exyi exyi commented Apr 26, 2025

In command bindings, expressions get automatically wrapped in a lambda function. Surprisingly, the behavior was also present in value/resource, which lead to some surprising effects when value/resource was accidentally assigned to a command property (#1742).

We also unify that untyped ICommandBinding and IStaticCommandBinding produce delegate of type Command (i.e. async function with no argument and no return value). Previously Delegate was used for commands,
which had the effect of sending the return value to the client

In command bindings, expressions get automatically wrapped in a lambda function. Surprisingly, the
behavior was also present in value/resource, which lead
to some surprising effects when value/resource was
accidentally assigned to a command property (#1742).

We also unify that untyped ICommandBinding and IStaticCommandBinding
produce delegate of type Command (i.e. async function with no argument and no return value).
Previously Delegate was used for commands,
which had the effect of sending the return value to the client
@exyi exyi requested a review from Copilot April 26, 2025 13:37
Copy link

@Copilot 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

This PR disables implicit lambda conversion in value/resource bindings while unifying command bindings to produce a Command delegate. Key changes include:

  • Updating tests to verify that value bindings no longer perform lambda conversion.
  • Refactoring binding helper methods by introducing a CreateBinding function and a new BindingType enum.
  • Adjustments in GeneralBindingPropertyResolvers, StaticCommandBindingExpression, and CommandBindingExpression to align with the new conversion behavior and syntax updates.

Reviewed Changes

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

Show a summary per file
File Description
src/Tests/Binding/BindingCompilationTests.cs Updated test methods to cover both Command and StaticCommand bindings and added a test to enforce that value bindings cannot perform lambda conversion.
src/Framework/Testing/BindingTestHelper.cs Introduced CreateBinding and a BindingType enum; refactored ExecuteBinding to use new array literal syntax for view model stack.
src/Framework/Framework/Compilation/Binding/GeneralBindingPropertyResolvers.cs Removed fallback to MagicLambdaConversion for value/resource bindings to disable lambda conversion.
src/Framework/Framework/Binding/Expressions/StaticCommandBindingExpression.cs Updated the syntax for GetResolvers using new array literal and spread operator syntax in line with language updates.
src/Framework/Framework/Binding/Expressions/CommandBindingExpression.cs Enhanced GetResolvers by combining common command methods with specific methods and updated command type conversion.

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.

1 participant