dotnet / dotnet/roslyn

Please add [CompilerGeneratedAttribute] to generated blazor components

Open
#85,550 0 comments 0 reactions 0 assignees View on GitHub
Area-Razor Area-Razor-Compiler Feature Request
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

If I have a .razor file that generates a `BuildRenderTree`, the generated output doesn't contain a [CompilerGeneratedAttribute] on top of it. This causes tools that inspect the assembly, e.g. auto-documentation tools in my case, to consider the generated output as lacking XML summaries.

See ticket https://github.com/dotnet/aspnetcore/issues/32356 for a similar issue, where this request was granted.

### Describe the solution you'd like

```csharp

[global::System.CodeDom.Compiler.GeneratedCodeAttribute("GeneratorClass", "Version")]
protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
{
// build component
}
```

### Additional context

This implementation should be backwards-compatible for .NET 6 through 8.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.