Skip to content

Investigate TagHelper scanning improvements #9299

Open
@333fred

Description

@333fred

Today, we need to scan all referenced assemblies to determine whether each assembly has defined any tag helpers. This is pretty inefficient, and pretty wasteful: most assemblies users reference couldn't have defined any tag helpers, since they don't reference Microsoft.AspNetCore.Razor.dll. Further, even among the assemblies that could have, many won't, so we're wasting a large amount of time looking for tag helpers where none exist. To address this, I'd like to propose the following scanning algorithm for .NET 9:

  1. Does the assembly reference Microsoft.AspNetCore.Razor.dll?
    1. If it does, is the version >8? If so, look for an attribute on the module, something like Microsoft.AspNetCore.Razor.ContainsTagHelpers. If that attribute is present, the assembly contains tag helpers and should be searched. Otherwise, it does not contain tag helpers and can be skipped.
    2. If it does, and the version is <=8, scan the assembly. We have no information on whether tag helpers are actually present.
  2. If it does not, there cannot be any tag helpers. Don't scan the assembly.

This will require putting a new source generator into the ref packages for Microsoft.AspNetCore.Razor so that anyone that defines tag helpers will get a module attribute automatically. This pattern is inspired by how C# does extension method lookups.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions