-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Introduce 'RenderTreeBuilder.AddComponentParameter()' #46562
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 |
|---|---|---|
|
|
@@ -505,6 +505,18 @@ public void OpenComponent(int sequence, [DynamicallyAccessedMembers(Component)] | |
| OpenComponentUnchecked(sequence, componentType); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Appends a frame representing a component parameter. | ||
| /// </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 AddComponentParameter(int sequence, string name, object? value) | ||
|
Member
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. How does this approach work when the parameters are splatted?
Member
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. That calls If you're suggesting adding a |
||
| { | ||
| AssertCanAddComponentParameter(); | ||
| _entries.AppendAttribute(sequence, name, value); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Assigns the specified key value to the current element or component. | ||
| /// </summary> | ||
|
|
@@ -649,6 +661,14 @@ private void AssertCanAddAttribute() | |
| } | ||
| } | ||
|
|
||
| private void AssertCanAddComponentParameter() | ||
| { | ||
| if (_lastNonAttributeFrameType != RenderTreeFrameType.Component) | ||
| { | ||
| throw new InvalidOperationException($"Component parameters may only be added immediately after frames of type {RenderTreeFrameType.Component}"); | ||
| } | ||
| } | ||
|
|
||
| private int? GetCurrentParentFrameIndex() | ||
| => _openElementIndices.Count == 0 ? (int?)null : _openElementIndices.Peek(); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.