Skip to content

✨ add a timeout to the ToFilter<T>() extension method #453

@candoumbe

Description

@candoumbe

Is your feature request related to a problem? Please describe.
Some naughty strings like groups can cause StackOverflowException.

Describe the solution you'd like
One way to prevent that could be to let the caller submit a "timeout" duration like what the BCL provides when calling Regex.IsMatch

ReadonlySpan<char> input = ...;

var filter = input.ToFilter<T>(timeout: TimeSpan.FromSeconds(30)); 

By explicitly defining a timeout, the developer would acknowledged that converting the input could fail.

Going one step further could be to introduce a breaking change in the ToFilter<T> extension method and make it returns an Option<IFilter, TimeoutException>

Describe alternatives you've considered
I could try to prevent those stack overflow by analyzing the input and eliminating cases where GroupExpression are nested too deeply, either with a global parameter (like the "maxdepth" parameter System.Text.Json provides

Additional context
Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

Labels

area:perfSomething related to performanceenhancement ✨New feature or requestparsingThe issue is related to parsing

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions