Open stephentoub opened 2 years ago
Tagging subscribers to this area: @dotnet/area-system-text-regularexpressions See info in area-owners.md if you want to be subscribed.
Author: | stephentoub |
---|---|
Assignees: | - |
Labels: | `area-System.Text.RegularExpressions` |
Milestone: | Future |
It is amazing to see all this regex work happening. I can see the amount of sophistication that goes into building this new engine. This is going to be state of the art. 👍
I suppose the parser would only create the comment nodes when being called from the source generator? I assume we wouldn't want to create these extra nodes (even when people enable the option for ignoring whitespaces) for any of the other engines.
I suppose the parser would only create the comment nodes when being called from the source generator?
That was my thinking.
The hard part here I think is figuring out to which node the comments actually apply. We also have a lot of assumptions in the tree about how many children each kind of node can have, and we probably don't want to disrupt that for this, so we'd likely need some side-channel.
If a developer specifies
RegexOptions.IgnorePatternWhitespace
or uses the(?x)
inline option, they can embed# comments
inside their regex pattern. Today the parser simply throws these away. When in the context of the source generator, we could instead store them and try to propagate them to the generated C# code as C# comments at an appropriate location in the source.