3 ms·
Why does the generated Regex need to be a partial field in a partial class? Why didn’t they make it something like: Regex myRegex = Regex.Generated(“…”) o
by armchairhacker 5y ago
Why does the generated Regex need to be a partial field in a partial class? Why didn’t they make it something like:
Regex myRegex = Regex.Generated(“…”)
or
Regex myRegex = MyRegex()
[RegexGenerated(…)]
partial class MyRegex {}
- X-Cubed 5y ago.Net source generators can't modify existing code, they can only add additional code files, so your first example wouldn't be able to be rewritten by the source generator. You can read the development discussion and syntax reasoning in the GitHub issue: https://github.com/dotnet/runtime/issues/44676 https://github.com/dotnet/runtime/issues/44676