Open kasperk81 opened 6 months ago
@firasdib this should be essentially just sugar, the regex goes in the [GeneratedRegex(...)]
instead of into string pattern = "..."
.
Is one method preferred over the other? I will trust your judgement :)
yes with GeneratedRegex attribute compiler generates c# code for a given pattern at build time, then compiles it to .net assembly https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-source-generators
.net 7 added [GeneratedRegex] attribute for compile-time code generation. https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-source-generators
feature request: show [GeneratedRegex] syntax in regex101's codegenerator as an alternative
Code Generator Language
C#
Code Snippet
current syntax, works with all versions of .net:
new / alternative code-generator syntax with performance advantage, works with .net 7 and above:
https://godbolt.org/z/Ws7dE8enc