-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Emit opted-in string literals into data section as UTF8 #76036
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
e9e701d
b89fbb8
1527232
8870eac
fc88a21
9022282
cd7bda0
9f240eb
5bf0385
17d9a2a
d225461
edc0103
d8767a3
1213122
960208e
e26e1c1
cc2cf59
3e69e33
ccee29f
9881daa
9e8938d
3439ccb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # String literals in data section | ||
|
|
||
| This opt-in Roslyn feature allows changing how string literals in C# programs are emitted into PE files (`.dll`/`.exe`). | ||
| By default, string literals are emitted to the UserString heap which is limited to [2^24 bytes](https://github.com/dotnet/roslyn/issues/9852). | ||
| When the limit is reached, the following compiler error is reported by Roslyn: | ||
|
|
||
| ``` | ||
| error CS8103: Combined length of user strings used by the program exceeds allowed limit. Try to decrease use of string literals. | ||
| ``` | ||
|
|
||
| By turning on the feature flag `utf8-string-encoding`, string literals (where possible) are instead emitted as UTF-8 data into a different section of the PE file | ||
| which does not have the same limit. The emit format is similar to [explicit u8 string literals](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-11.0/utf8-string-literals). | ||
|
|
||
| The feature flag can take a non-negative integer threshold. Only string literals whose length is over the threshold are emitted in the new way described above. | ||
| By default, the threshold is 100. Specifying 0 means all string literals are considered for the feature. Specifying `off` turns off the feature (this is the default). | ||
|
|
||
| The feature flag can be specified on the command line like `/features:utf8-string-encoding` or `/features:utf8-string-encoding=20`, | ||
| or in a project file in a `<PropertyGroup>` like `<Features>$(Features);utf8-string-encoding</Features>` or `<Features>$(Features);utf8-string-encoding=20</Features>`. | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.