- Adds a source generator which optimizes
PcreRegexcalls when constant values are used:- Static method calls in the
PcreRegexclass, such asPcreRegex.Match(string subject, string pattern, PcreOptions options), with constant patterns and options will be permanently cached in a dedicatedstaticfield on their first use.
Therefore, usage ofPcreOptions.Compiledis now encouraged in these situations, as the compilation will occur only once. - Constant replacement strings used in
PcreRegex.Replacemethods will be pre-compiled, for both static and instance methods. Note thatPcreRegex.Substituteis not affected.
- Static method calls in the
This feature requires Roslyn 5.0 (shipped in the .NET 10 SDK or with Visual Studio 2026 version 18.0) and usage of C# 11 or later. It is AOT-compatible and transitive across projects.
If needed, it can be disabled by setting the PcreNetInterceptors property to false in your project file.