docs
docs copied to clipboard
Ambiguity in description of .NET regular expression source generators
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 singletonRegex
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:
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