-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Resolved because the question asked by the original author has been answered.Status: Resolvedarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Componentsquestion
Description
Is there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
Currently, the only global using equivalent for Razor is the _Imports.razor which unfortunately is not reusable or even modular in anyway. Meanwhile, C# has serveral ways: global using from multiple files, <Using Include="namespace" /> which can also be reused by using <Import /> from targets.
Describe the solution you'd like
- Razor Components should honor
<Using />when generating component. To prevent breaking change, maybe it should be opt-in with a property switch:
<PropertyGroup>
<RazorUsesUsings>true</RazorUsesUsings>
</PropertyGroup>
<ItemGroup>
<Using Include="Microsoft.AspNetCore.Components" />
<Using Include="Microsoft.AspNetCore.Components.Forms" />
<Using Include="Microsoft.AspNetCore.Components.Web" />
</ItemGroup>At first I thought about a new tag like RazorUsing but I think it's a bad idea because in the end it mostly will just repeat whatever Using there are.
- A reusable
_Imports.razorcomponent. I am not sure how feasible it should be, but it could be like this:
Common1.razor
<Using Namespace="Microsoft.AspNetCore.Components" />
<Using Namespace="Microsoft.AspNetCore.Components.Forms" />_Imports.razor
<Namespace.Common1 />
<Namespace.Common2 />Additional context
No response
Metadata
Metadata
Assignees
Labels
✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Resolved because the question asked by the original author has been answered.Status: Resolvedarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Componentsquestion