-
Notifications
You must be signed in to change notification settings - Fork 190
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
Components that accept bind-Something can request SomethingExpression #213
Components that accept bind-Something can request SomethingExpression #213
Conversation
src/Razor/src/Microsoft.AspNetCore.Razor.Language/Components/ComponentBindLoweringPass.cs
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Razor/BindTagHelperDescriptorProvider.cs
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Razor/BindTagHelperDescriptorProvider.cs
Show resolved
Hide resolved
src/Razor/src/Microsoft.AspNetCore.Razor.Language/Components/ComponentBindLoweringPass.cs
Show resolved
Hide resolved
...Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentCodeGenerationTestBase.cs
Show resolved
Hide resolved
...Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/ComponentCodeGenerationTestBase.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really great!
@ajaybhargavb it would be super cool if you would look at this as well - if only to come up to speed on what this does.
@NTaylorMullen FYI in case you are interesting. Dopeness is happening. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
…dotnet/razor#213) * In binding to components, automatically supply FooExpression when requested * Fix tests * CR feedback \n\nCommit migrated from dotnet/razor@ca9de74
…dotnet/razor#213) * In binding to components, automatically supply FooExpression when requested * Fix tests * CR feedback \n\nCommit migrated from dotnet/razor@ca9de74 Commit migrated from dotnet/aspnetcore@82d850d3a7a8
This is needed for the forms and validation enhancements in Components for Preview 3. It extends the pattern around binding to component properties with a new optional "*Expression" parameter, e.g.:
It's optional, so if the component doesn't declare
*Expression
, then there's no change to the generated code versus what we had before.If the component does declare
*Expression
(where*
is something our existing rules match for binding based on the presence of*Changed
), then when a consumer uses the binding, e.g.:... then it expands to be equivalent to:
This makes it possible for
MyEditor
to read any metadata it wants about the thing you're binding to (e.g., validation annotations). What we actually use it for in the new built-in forms/validation system is uniquely identifying the bound field within theEditContext
, so for exampleMyEditor
could highlight different states based on whether that field is currently tracked as modified/invalid/etc.Note: This is only for binding to components. There's no equivalent when binding to plain elements, since plain elements have no way of declaring that they want
*Expression
(and no reason why they should, since they couldn't do anything with it).