dotnet / dotnet/aspnetcore

Consider using UTF8 literals for string literals generated from .razor and .cshtml

Open
#50,788 6 comments 5 reactions 0 assignees View on GitHub
area-ui-rendering enhancement
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

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.

The source generator currently uses regular string literals for HTML content.

For example,
```C#
__builder.AddMarkupContent(4, "

Hello, world!

\n\nWelcome to your new app!\n\n");
```

String literals are stored in the assembly in `#US` metadata heap using UTF16 encoding. The heap size is limited and larger apps run out of the space.
See https://github.com/dotnet/aspnetcore/issues/20224.

### Describe the solution you'd like

Using UTF8 literals would address this issue. UTF8 literals are stored directly in the PE image at specified RVA. The metadata heap size limitations thus do not apply.

Besides, it would likely be faster and more memory efficient to render the pages since UTF16 to UTF8 encoding might be avoided.

### Additional context

_No response_

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.