You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Let the code generators set the pattern match limit written into generated code #1022
Generated code (V5 and V4) carries the pattern match limit as a literal: 1 second, written into each [GeneratedRegex] attribute, each Regex constructor call and the options of the generated schema program. A consumer who needs a different limit, or none, has to use the runtime evaluator, where JsonSchemaEvaluatorOptions.RegexMatchTimeout sets it.
This issue asks for a way to choose the limit when code is generated.
Proposal
A generator option for the match limit, with the current 1 second as the default:
a switch on the corvusjson CLI and an entry in the generator configuration schema,
a property on the source generator's attribute or its MSBuild options.
The value would still be fixed at generation time, so changing it means regenerating. That keeps [GeneratedRegex] usable, since the attribute cannot take a run-time value.
Alternatives considered
Read the limit at run time from an AppContext value. [GeneratedRegex] expressions would have to become constructed ones and would lose source generation.
Omit the limit and rely on the process-wide REGEX_DEFAULT_MATCH_TIMEOUT. The limit would then be off unless the host sets it, and it would apply to every Regex in the process.
Context
The limit and its default come from the pattern conformance and resource limit work on fix/separated-list-anchors. The restriction is documented in docs/CodeGenerator.md and docs/SourceGenerator.md there.
Activity
Backlog fixes: #1021, #1022, #943, #953, #1049 and smaller issues (5.…