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.46k stars 10.03k forks source link

Improve Razor Component Sections #48219

Open EdCharbeneau opened 1 year ago

EdCharbeneau commented 1 year ago

Is there an existing issue for this?

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

I'm testing out the new Sections feature in Preview. Overall, I like the way it works; however I'm finding them a little hard to organize.

In order to make sections discoverable, I used a class named "Sections". This makes a nice API where you can get all of the sections for a layout through intellisense by typing the name of the layout. The downside is that using static classes means you can access sections that are not actually in scope of the component, but are in scope due to access level. Example, if I have a TwoColumn layout, and ThreeColumn layout, I can reference sections from both from either layout.

It would be nice if the compiler or tooling could understand the layouts in scope and issue warnings if they wont produce an output.

Currently setting a section to an Id that is out of scope fails silently.

If there were some ways to automatically surface the sections without organizing them into a class, it would make it easier as well.

Describe the solution you'd like

1) Throw a compiler warning if a section is used in a layout that does not have a section with the Id used. Currently setting a section to an Id that is out of scope fails silently.

2) Implement tooling that surfaces Sections via intellisense.

Additional context

Current example using a class: Organizing Sections (github.com)

MackinnonBuck commented 1 year ago

Thanks for reaching out! We're going to put this in the backlog for now to gather more feedback. There is a lot of complexity in determining at compile time which SectionContent instances are definitely not going to match a SectionOutlet, and there's risk of having false positives or locking customers into specific usage patterns with sections. It's not clear to us yet whether the problem you've described is one that will be encountered frequently enough to warrant introducing new analyzers/tooling.

ghost commented 1 year ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

ghost commented 11 months ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.