Skip to content

Razor component tag regex misses dotted-namespace components like My.Nested.Component #1479

Description

@Widthdom

Summary

The Razor component tag regex captures only PascalCase non-dotted component names (e.g. <MyButton />). Real Blazor / Razor Components codebases routinely use dotted-namespace tags (e.g. <MyApp.Components.Forms.Button />) and these are not recognized as references to the underlying component type.

Evidence

  • src/CodeIndex/Indexer/References/Languages/RazorReferenceExtractor.csRazorComponentTagRegex (around the file's component-detection helper, support code at line 627-681).

  • Reproducer:

    @page "/"
    <MyApp.Components.Forms.LoginButton OnClick="HandleClick" />

    Index this file. The reference from the tag to MyApp.Components.Forms.LoginButton is missing or only the trailing segment is captured.

Impact

  • references on a fully-qualified Razor component type under-reports usage sites in any project that doesn't use @using blanket imports.
  • impact_analysis over a component is incomplete.

Proposed direction

  • Extend RazorComponentTagRegex to allow [A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*)* for the tag name.
  • When emitting the reference, use the fully-qualified name as the target identifier.
  • Add a unit test covering both single-segment and dotted-namespace component tags.

Repro env

  • Branch: main @ 2ee912d (release v1.21.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions