Skip to content

.Net 7.0 Regex SourceGen #67644

Answered by stephentoub
TonyValenti asked this question in Q&A
Discussion options

You must be logged in to vote

@stephentoub is doing amazing work on the regex source gen.

Thank you.

Are sourcegen-compiled regexes expected to execute faster than today's runtime-compiled post-warmup regexes?

There are a few answers here:

  • All of the parsing, analysis, optimization, and code generation (C#/IL) is done at build time with the source generator vs run-time for RegexOptions.Compiled, so first use / startup is faster with source generation.
  • Source-generated regexes still require System.Text.RegularExpressions.dll, but they don't require much of the code in it, so a trimmed application can omit much of the size from System.Text.RegularExpressions.dll, and if nothing else is using reflection emit, much o…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by danmoseley
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants