Commit 00aa651
authored
Add initial regex source generator (dotnet#59186)
* Add RegexGeneratorAttribute
Adds the new RegexGenerator attribute that's a signal to the regex
generator to generate code for the specified regex.
* Implement RegexGenerator
Add a source generator for generating C# code for Regex. This is
primarily a port of RegexCompiler.cs, generating C# code instead of
MSIL.
* Add generator test project
Adds tests dedicated to the mechanics of the source generator, e.g. that
appropriate diagnostics are issued for improper use of RegexGenerator.
* Integrate source generator into many regex tests
Start integrating the source generator into the regex test suite, so
that many existing tests also validate the generated code.
* Address PR feedback
* Improve cachability of source generator
Changing the generator to not collect all regexes together means we don't need to reprocess/regenerate all regexes every time any one of them is changed.
* Use closest matching ctor from GetRegexAsync
To better test the appropriate ctor usage.
* Improve a few of the polyfills
* Address PR feedback
* Fully qualify types and remove unnecessary $s
Also fixed one place where the IL we were generating wasn't as good as the reflection emit code.
* Suppress a couple more warnings
* Fix stray !
* Fix TODO about unrolling multi comparisons
Also clean up generated code in a few places to make it more readable / concise.
* Update resources per PR feedback
* Add more tests, clean up parser code, and allow instance/interface methods
* Fix test suppression on mobile1 parent 072cbae commit 00aa651
File tree
55 files changed
+10017
-975
lines changed- docs/project
- src/libraries/System.Text.RegularExpressions
- gen
- Resources
- xlf
- ref
- src
- System/Text/RegularExpressions
- tests
- System.Text.RegularExpressions.Generators.Tests
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
55 files changed
+10017
-975
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
Lines changed: 23 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
2 | 6 | | |
3 | 7 | | |
4 | 8 | | |
| |||
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
20 | 30 | | |
21 | 31 | | |
22 | 32 | | |
| |||
47 | 57 | | |
48 | 58 | | |
49 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
50 | 68 | | |
51 | 69 | | |
52 | 70 | | |
53 | 71 | | |
54 | 72 | | |
55 | 73 | | |
56 | | - | |
57 | 74 | | |
58 | | - | |
59 | 75 | | |
| 76 | + | |
60 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
61 | 81 | | |
62 | 82 | | |
63 | 83 | | |
| |||
Lines changed: 56 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
0 commit comments