Skip to content

Adding partial namespaces in Blazor's razor markup #22194

@simonziegler

Description

@simonziegler

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

Not a problem, but this would improve maintainability for a moderate to large project composed from multiple libraries (both regular C# netstandard and razor libraries).

Describe the solution you'd like

Blazor's Razor markup doesn't support partial namespaces. I am building a suite of libraries and would like all of them to share a single top level namespace, say foo. The libraries would then apply namespaces:

  • Library 1: namespace foo.bar1 with components Bish.razor, Bash.razor and Bosh.razor.
  • Library 2: namespace foo.bar2
  • Library 3: namespace foo.bar3

The app consuming the libraries would then place @using foo and use the remainder of the namespace in a component tag. So for instance using the component Bish from library 1, the markup would be <bar1.Bish ... />.

This is geared towards maintainability and clarity of usage.

Additional context

https://docs.microsoft.com/en-us/aspnet/core/blazor/components?view=aspnetcore-3.1#import-components.

Metadata

Metadata

Assignees

No one assigned

    Labels

    affected-fewThis issue impacts only small number of customersarea-blazorIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing onefeature-razor.languageseverity-majorThis label is used by an internal tool

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions