dotnet / dotnet/aspnetcore

Improve Razor Component Sections

Open
#48,219 3 comments 0 reactions 0 assignees View on GitHub
area-blazor
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

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.

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)](https://protect-us.mimecast.com/s/lTY5CjRBDBS5yBxniWDZRp?domain=gist.github.com)

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.