-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Razor generic parameter cascading #29767
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
Merged
SteveSandersonMS
merged 40 commits into
main
from
stevesa/razor-generic-parameter-cascading
Feb 16, 2021
Merged
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
b87a9f4
Begin adding test for type parameter cascading
SteveSandersonMS 0377b32
Cascade explicit ancestor type args
SteveSandersonMS e3d57e1
Switch to a push model for cascading generic types
SteveSandersonMS 78fc1da
Refactoring to simplify next change
SteveSandersonMS 8b8898b
Further refactoring to simplify next change
SteveSandersonMS 46b0113
Make inferred generic types actually cascade.
SteveSandersonMS d371491
Minor refactoring (name change etc.)
SteveSandersonMS 8a20d8c
Avoid multiple evaluations of the expression used for generic type in…
SteveSandersonMS fcebf92
Make cascaded type inference work with generic child content
SteveSandersonMS bac0a64
Handle lambdas on both provider and receiver sides
SteveSandersonMS 219f78a
Handle inference of multiple generic parameters without duplicate eva…
SteveSandersonMS d035c9c
Update design time to match previous
SteveSandersonMS 23004f8
Steps towards handling further cases
SteveSandersonMS e0d0ec5
Refactoring that will simplify subsequent updates
SteveSandersonMS db33c8f
Revert some changes I no longer want
SteveSandersonMS 0edc442
Use the refactorings to simplify and ensure consistency about ordering
SteveSandersonMS 2c91775
Emit _CaptureParameters variant of type inference method
SteveSandersonMS fb3e773
Call the _CaptureParameters method to ensure single evaluation
SteveSandersonMS c0cd58f
Supply captured variables to descendants for cascading generic type i…
SteveSandersonMS 6ac9f1c
Update new baselines
SteveSandersonMS 875f009
Update comments
SteveSandersonMS 2be20d0
Step towards being able to handle unrelated generic types
SteveSandersonMS e698841
Handle provision of unrelated generic types via diagnostic
SteveSandersonMS 105dbb4
Remove obsolete comment
SteveSandersonMS fa6b428
Begin filtering which type params cascade
SteveSandersonMS 980c987
Now actually filter provided cascading generic types
SteveSandersonMS ee71f8a
Eliminate unnecessary parameter capturing for non-cascading-components
SteveSandersonMS 24de67f
Update baselines
SteveSandersonMS fb6d02a
More test cases
SteveSandersonMS 5feebaa
Show we can have siblings
SteveSandersonMS 9b49599
Show type cascading can pass through multiple levels
SteveSandersonMS 1de1e1d
Clarify how we're retaining back-compat in a very obscure case
SteveSandersonMS 8c362ef
Better comments
SteveSandersonMS c897740
Clean up APIs
SteveSandersonMS 46466d5
CR: Null check
SteveSandersonMS 59df23c
Rename attribute for consistency with other framework terminology
SteveSandersonMS e46c9d8
Add CascadingTypeParameterAttribute
SteveSandersonMS 78d7097
Update tests to match new attribute name
SteveSandersonMS 99830e6
CR: More tests and simplification
SteveSandersonMS 70fd168
CR: Rename
SteveSandersonMS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/Components/Components/src/CascadingTypeParameterAttribute.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // 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. | ||
|
|
||
| using System; | ||
|
|
||
| namespace Microsoft.AspNetCore.Components | ||
| { | ||
| /// <summary> | ||
| /// Denotes the generic type parameter as cascading. This allows generic type inference | ||
| /// to use this type parameter value automatically on descendants that also have a type | ||
| /// parameter with the same name. | ||
| /// </summary> | ||
| [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)] | ||
| public sealed class CascadingTypeParameterAttribute : Attribute | ||
| { | ||
| /// <summary> | ||
| /// Constructs an instance of <see cref="CascadingTypeParameterAttribute"/>. | ||
| /// </summary> | ||
| /// <param name="name">The name of the type parameter.</param> | ||
| public CascadingTypeParameterAttribute(string name) | ||
| { | ||
| if (name == null) | ||
| { | ||
| throw new ArgumentNullException(nameof(name)); | ||
| } | ||
|
|
||
| Name = name; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets the name of the type parameter. | ||
| /// </summary> | ||
| public string Name { get; } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.