docs icon indicating copy to clipboard operation
docs copied to clipboard

Ambiguity in description of .NET regular expression source generators

Open gewarren opened this issue 5 months ago • 0 comments


Issue moved from MicrosoftDocs/feedback#3977

  • Please respond to @SetTrend.

From @SetTrend on Thursday, January 18, 2024 6:52:30 PM

In section Source generation, the documentation states:

The generated implementation of AbcOrDefGeneratedRegex() similarly caches a singleton Regex instance, so no additional caching is needed to consume code.

… but right below that you're providing a screenshot that's manually caching the generated RegEx() result in user code:

cached instance

What's true? — Do we need to cache the result in a static readonly variable or can we call RegEx() repeatedly without penalty to runtime execution time?


https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-source-generators#source-generation

gewarren avatar Jan 29 '24 22:01 gewarren