Is it possible to use .NET regular expression source generators in LINQPad?
I was watching the Deep Dive into RegEx with Stephen Toub video and learned about .NET regular expression source generators, so I decided to see if I could use them in LINQPad but it doesn't seem possible. I created the following script in LINQPad v8.2.4 (X64) based on one shown in the video.
void Main() { Console.WriteLine(Example.Demo().Count("abc")); } static partial class Example { [GeneratedRegex("abc")] public static partial Regex Demo(); }
Unfortunately this doesn't work, drawing a red squiggly under Demo
in the partial method declaration; the error being "CS8795 Partial method 'UserQuery.Example.Demo()' must have an implementation part because it has accessibility modifiers." It seems that the generation of the other side of the partial
class and method happens.
Have I missed some setting that might allow this or is it not possible in LINQPad at this time?
Comments
I noticed there was a new version and have updated to v8.3.7 but it hasn't helped.
LINQPad doesn't support source generators right now. It would require either switching the LINQPad GUI from .NET 6+ back to .NET Framework, or moving the entire Roslyn toolchain out-of-process - a massive job with performance implications.
I also wants this [GeneratedRegex] function.