Skip to content

Allow access modifiers for Razor component classes (e.g., internal for Blazor components) #63041

@FelipeCostaGualberto

Description

@FelipeCostaGualberto

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.

Razor components defined in .razor files are always generated as public classes. There is no supported way to declare a component as internal (or another modifier like private and file). This results in polluted RCL projects because its components "helpers" are shipped as public.

  • Current workaround using EditorBrowsable(Never) do not enforce encapsulation.
  • Writing components with BuildRenderTree accepts modifiers, but lose Razor syntax.

Describe the solution you'd like

Add a Razor directive to control the generated component class accessibility. If not present, component is public by default.

Example in .razor file:

`@accessibility internal`

If using a backing .razor.cs file, the developer must declare the class also with internal.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.✔️ Resolution: By DesignResolved because the behavior in this issue is the intended design.Status: Resolvedarea-blazorIncludes: Blazor, Razor Components

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions