dotnet / dotnet/roslyn

[Blazor] Support for direct using generic parameters as components at Razor pages

Open
#85,562 0 comments 1 reaction 0 assignees View on GitHub
Area-Language Design Area-Razor Area-Razor-Compiler
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

It would boost productivity if we could use generic parameters as components directly in razor pages.

Consider such container and its razor page -- `MyContainer`

```

This is my component

```

This gives error and indeed it should give error:

But if we add the constraints:
```
class MyContainer where TComponent : ComponentBase
```

now we know that it is truly a component, and now it would be great if Razor could recognize it as in the snippet above.

### Describe the solution you'd like

See above.

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.