-
Notifications
You must be signed in to change notification settings - Fork 191
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
Directive attributes part 1: Support parameters in bound attributes #597
Conversation
src/Razor/src/Microsoft.AspNetCore.Razor.Language/BoundAttributeParameterDescriptor.cs
Show resolved
Hide resolved
src/Razor/src/Microsoft.AspNetCore.Razor.Language/Components/ComponentBindLoweringPass.cs
Outdated
Show resolved
Hide resolved
new RazorDiagnosticDescriptor( | ||
$"{DiagnosticPrefix}10005", | ||
() => "Specifying event handlers in bind attributes are no longer supported. Specify it using the bind:event=... attribute.", | ||
RazorDiagnosticSeverity.Warning); |
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.
I've made this a warning but the ErrorList pane doesn't respect it. It still shows up as an error.
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.
One day we'll make that work 😄
src/Razor/src/Microsoft.AspNetCore.Razor.Language/DefaultBoundAttributeDescriptorBuilder.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Razor/BindTagHelperDescriptorProvider.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.AspNetCore.Razor.Language/TagHelperMatchingConventions.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.AspNetCore.Razor.Language/TagHelperMatchingConventions.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.AspNetCore.Razor.Language/TagHelperMatchingConventions.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.AspNetCore.Razor.Language/TagHelperMatchingConventions.cs
Outdated
Show resolved
Hide resolved
@@ -6,6 +6,7 @@ namespace Microsoft.AspNetCore.Razor.Language | |||
public enum RazorDiagnosticSeverity | |||
{ | |||
// Purposely using the same value as Roslyn here. | |||
Warning = 2, |
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.
Curious: If you build in VS do you get a warning in the window?
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.
Nope. Not even an error. Build just succeeds.
src/Razor/src/Microsoft.CodeAnalysis.Razor/BindTagHelperDescriptorProvider.cs
Show resolved
Hide resolved
src/Razor/src/Microsoft.AspNetCore.Razor.Language/ComponentResources.resx
Show resolved
Hide resolved
src/Razor/src/Microsoft.AspNetCore.Razor.Language/Components/ComponentBindLoweringPass.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.AspNetCore.Razor.Language/Components/ComponentBindLoweringPass.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.AspNetCore.Razor.Language/Components/ComponentBindLoweringPass.cs
Show resolved
Hide resolved
...r/src/Microsoft.AspNetCore.Razor.Language/DefaultBoundAttributeParameterDescriptorBuilder.cs
Outdated
Show resolved
Hide resolved
...r/src/Microsoft.AspNetCore.Razor.Language/DefaultBoundAttributeParameterDescriptorBuilder.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorIntermediateNodeLoweringPhase.cs
Outdated
Show resolved
Hide resolved
b79eb81
to
e48c009
Compare
🆙 📅 |
@@ -249,6 +252,17 @@ private IntermediateNode[] RewriteUsage(IntermediateNode parent, BindEntry bindE | |||
format = GetAttributeContent(bindEntry.BindFormatNode); | |||
} | |||
|
|||
if (TryGetFormatNode( |
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.
Should we separate these into a separate pass to make it easy to delete in the future? I'm a little worried to see munging on the happy path, but I could be convinced otherwise.
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.
Technically this pass removes all the extra nodes like these and rewrites to ComponentAttributes. While this case is easy to do in a separate pass, teh diagnostic for bind-value-onchange
will be hard to add later on because it would already be rewritten.
Also, when we want to delete these diagnostics, we also want to cleanup BindTagHelperDescriptorProvider
to remove the bound attribute descriptors for format-
attributes. So a separate pass here won't contain all the temporary code.
@@ -351,7 +351,7 @@ public static RazorDiagnostic CreateBindAttributeParameter_MissingBind(SourceSpa | |||
public static readonly RazorDiagnosticDescriptor BindAttribute_UnsupportedFormat = | |||
new RazorDiagnosticDescriptor( | |||
$"{DiagnosticPrefix}10005", | |||
() => "Specifying event handlers in bind attributes are no longer supported. Specify it using the bind:event=... attribute.", | |||
() => "Specifying event handlers in bind attributes are no longer supported. Specify it using the bind:event=... attribute instead.", |
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.
👍
src/Razor/src/Microsoft.AspNetCore.Razor.Language/BoundAttributeDescriptorBuilderExtensions.cs
Show resolved
Hide resolved
src/Razor/src/Microsoft.AspNetCore.Razor.Language/Components/ComponentBindLoweringPass.cs
Show resolved
Hide resolved
src/Razor/src/Microsoft.AspNetCore.Razor.Language/Components/ComponentBindLoweringPass.cs
Outdated
Show resolved
Hide resolved
0c7afeb
to
44a19fb
Compare
🆙 📅 |
src/Razor/src/Microsoft.AspNetCore.Razor.Language/Components/ComponentBindLoweringPass.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.
once the case sensitiveness is accounted for.
src/Razor/src/Microsoft.AspNetCore.Razor.Language/BoundAttributeDescriptorBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
parameter.Documentation = string.Format(ComponentResources.BindTagHelper_Fallback_Event_Documentation, attributeName); | ||
|
||
parameter.SetPropertyName("Event"); | ||
}); |
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.
👍
src/Razor/src/Microsoft.CodeAnalysis.Razor/BindTagHelperDescriptorProvider.cs
Outdated
Show resolved
Hide resolved
@@ -982,7 +982,7 @@ public void BuiltIn_BindToInputText_WithFormat_WritesAttributes() | |||
|
|||
// Act | |||
var generated = CompileToCSharp(@" | |||
<input type=""text"" bind=""@CurrentDate"" format-value=""MM/dd/yyyy""/> | |||
<input type=""text"" bind=""@CurrentDate"" bind:format=""MM/dd/yyyy""/> |
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.
@SteveSandersonMS for deliciousness 😀
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 🌶
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.
👍
Did you test in VS? |
Yes |
6007143
to
a47665c
Compare
@@ -28,7 +28,7 @@ protected virtual async Task<TagHelperResolutionResult> GetTagHelpersAsync(Proje | |||
throw new ArgumentNullException(nameof(engine)); | |||
} | |||
|
|||
var providers = engine.Engine.Features.OfType<ITagHelperDescriptorProvider>().ToArray(); | |||
var providers = engine.Engine.Features.OfType<ITagHelperDescriptorProvider>().OrderBy(f => f.Order).ToArray(); |
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.
@rynowak, this bug was causing bind to run before component descriptor provider in design time.
…otnet/razor#597) * Directive attributes part 1: Support parameters in bound attributes * update * Fix test * feedback * Updated design * Do case sensitive comparison * more * Bug fix \n\nCommit migrated from dotnet/razor@9bbf240
…otnet/razor#597) * Directive attributes part 1: Support parameters in bound attributes * update * Fix test * feedback * Updated design * Do case sensitive comparison * more * Bug fix \n\nCommit migrated from dotnet/razor@9bbf240 Commit migrated from dotnet/aspnetcore@5bad5de7ee95
Part of dotnet/aspnetcore#6364
This PR introduces support for things like the following,
BoundAttributeParameterDescriptor
to represent bind:event
etc portion of the bound attributeTagHelperBlockRewriter
andIntermediateLoweringPass
now respects bound attributes with parametersBindTagHelperDescriptorProvider
to bind attributes toevent
andformat
parametersTagHelperDescriptorJsonConverter