-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Blazor API review changes: CompilerServices #11911
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
namespace Microsoft.AspNetCore.Components.CompilerServices | ||
{ | ||
/// <summary> | ||
/// Used by generated code produced by the Components code generator. Not intended or supported | ||
/// for use in application code. | ||
/// </summary> | ||
public static class RuntimeHelpers | ||
{ | ||
/// <summary> | ||
/// Not intended for use by application code. | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
/// <param name="value"></param> | ||
/// <returns></returns> | ||
public static T TypeCheck<T>(T value) => value; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -224,23 +224,6 @@ public void AddAttribute(int sequence, string name, Action value) | |
AddAttribute(sequence, name, (MulticastDelegate)value); | ||
} | ||
|
||
/// <summary> | ||
/// <para> | ||
/// Appends a frame representing an <see cref="Action{UIEventArgs}"/>-valued attribute. | ||
/// </para> | ||
/// <para> | ||
/// The attribute is associated with the most recently added element. If the value is <c>null</c> and the | ||
/// current element is not a component, the frame will be omitted. | ||
/// </para> | ||
/// </summary> | ||
/// <param name="sequence">An integer that represents the position of the instruction in the source code.</param> | ||
/// <param name="name">The name of the attribute.</param> | ||
/// <param name="value">The value of the attribute.</param> | ||
public void AddAttribute(int sequence, string name, Action<UIEventArgs> value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are unused except for some unit tests. It's still possible to attach arbitrary delegates to the RTB - these methods are here to support method-group-to-delegate conversion and aren't really needed anymore. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
But there's no use case for it, is there? Is this what we're discussing above with "should we remove the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The only use case for it would be making it nicer for someone writing RTB code by hand. Let's look at this again during the RTB API review. |
||
{ | ||
AddAttribute(sequence, name, (MulticastDelegate)value); | ||
} | ||
|
||
/// <summary> | ||
/// <para> | ||
/// Appends a frame representing a <see cref="Func{Task}"/>-valued attribute. | ||
|
@@ -258,23 +241,6 @@ public void AddAttribute(int sequence, string name, Func<Task> value) | |
AddAttribute(sequence, name, (MulticastDelegate)value); | ||
} | ||
|
||
/// <summary> | ||
/// <para> | ||
/// Appends a frame representing a <see cref="Func{UIEventArgs, Task}"/>-valued attribute. | ||
/// </para> | ||
/// <para> | ||
/// The attribute is associated with the most recently added element. If the value is <c>null</c> and the | ||
/// current element is not a component, the frame will be omitted. | ||
/// </para> | ||
/// </summary> | ||
/// <param name="sequence">An integer that represents the position of the instruction in the source code.</param> | ||
/// <param name="name">The name of the attribute.</param> | ||
/// <param name="value">The value of the attribute.</param> | ||
public void AddAttribute(int sequence, string name, Func<UIEventArgs, Task> value) | ||
{ | ||
AddAttribute(sequence, name, (MulticastDelegate)value); | ||
} | ||
|
||
/// <summary> | ||
/// <para> | ||
/// Appends a frame representing a delegate-valued attribute. | ||
|
@@ -287,14 +253,6 @@ public void AddAttribute(int sequence, string name, Func<UIEventArgs, Task> valu | |
/// <param name="sequence">An integer that represents the position of the instruction in the source code.</param> | ||
/// <param name="name">The name of the attribute.</param> | ||
/// <param name="value">The value of the attribute.</param> | ||
/// <remarks> | ||
/// This method is provided for infrastructure purposes, and is used to be | ||
/// <see cref="UIEventArgsRenderTreeBuilderExtensions"/> to provide support for delegates of specific | ||
/// types. For a good programming experience when using a custom delegate type, define an | ||
/// extension method similar to | ||
/// <see cref="UIEventArgsRenderTreeBuilderExtensions.AddAttribute(RenderTreeBuilder, int, string, Action{UIChangeEventArgs})"/> | ||
/// that calls this method. | ||
/// </remarks> | ||
public void AddAttribute(int sequence, string name, MulticastDelegate value) | ||
{ | ||
AssertCanAddAttribute(); | ||
|
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 - speakup if you have concerns. I'm specifically removing support for things like this (not using directive attributes). Should we do this with
Action
andFunc<Task>
as well?Uh oh!
There was an error while loading. Please reload this page.
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 expect this is fine, including removing the
Action
/Func<Task>
variants too. The ideal, if we have time for it, would be issuing a compile-time warning for people who put attributes namedonX
with delegate-type values when they fail to use the directive attribute.I just checked that our extensibility for event tag helpers works nicely (it does), so people are free to define their own custom event type names and values. This is essential because the HTML spec continues to evolve, and new or nonstandard event names will keep appearing.
Given that the tag helper extensibility works well, there's no use case for people trying to define events handlers any other way. The only risk is that they don't know about how to do it, which is where a compiler warning (perhaps with a fwlink to docs) would be ideal. If we don't have time to add the warning now, it could be added in the future.
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'm not certain how this would work in practice. We don't know in the Razor compiler what kind of value you're passing in when you set an attribute.