IDE / CommandLine tag helper discovery differ
- Dominant language
- C#
- Stars
- 20.7k
- Forks
- 4.3k
- PR merge metrics
- PR metrics pending
Description
Today when discovering tag helpers the tooling code explicitly does not include tag helpers annotated with `[EditorBrowsable(EditorBrowsableState.Never)]`: https://github.com/dotnet/razor/blob/49c8ee8bcbb2786f8e1fef4575ce06d95f5d98cd/src/Razor/src/Microsoft.AspNetCore.Razor.ProjectEngineHost/ProjectExtensions.cs?plain=1#L52 -> https://github.com/dotnet/razor/blob/49c8ee8bcbb2786f8e1fef4575ce06d95f5d98cd/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/CSharp/DefaultTagHelperDescriptorFactory.cs?plain=1#L417
The command line compiler includes these tag helpers, which can lead to a difference in the generated code between IDE and runtime. A simple example is the `` tag helper https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.razor.taghelpers.bodytaghelper?view=aspnetcore-8.0 which is hidden. In an MVC document with a `` tag, it will be considered a tag helper at runtime, but not at design time. The current emit strategy does not emit any of the tag helper machinery if there are no referenced tag helpers, so you end up with a large difference in what code is eventually generated.
We should continue to read the `EditorBrowseable` state, but rather than excluding them completely, set a flag on the TagHelper indicating it is hidden. We can then update tooling to exclude it from things like Completion and Semantic Tokens, but still generate the same code as runtime.
Contributor guide
Assessment
This issue has not been assessed yet.