dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.27k stars 9.96k forks source link

[Blazor] Add @abstract directive #21665

Open JvanderStad opened 4 years ago

JvanderStad commented 4 years ago

Feature request: Create a new razor component directive to mark the generated class as abstract. @abstract seems like a good candidate.

mkArtakMSFT commented 4 years ago

We've moved this issue to the Backlog milestone. This means that it is not going to happen for the coming release. We will reassess the backlog following the current release and consider this item at that time. However, keep in mind that there are many other high priority features with which it will be competing for resources.

HaraldMuehlhoffCC commented 6 months ago

Ran in this today; we've got a GridRenderer.razor which I'd like to be abstract because only the two derived components should be instantiated. Also without @abstract I can't make sure at compile time that all required overrides are in place ...

elaforma commented 1 week ago

Ran into this today trying to make a component only instantiable in specific locations. The usual workaround for making this happen in C# is to make the class abstract, and have a subclass that is private to each "friend" class. This is not currently possible with Razor components.