Home

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

Sign In or Register to comment.