candoumbe / candoumbe/DataFilters

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

Open
#453 0 comments 0 reactions 1 assignee Claimed by @candoumbe View on GitHub
area:perf enhancement :sparkles: parsing
Dominant language
C#
Stars
33
Forks
5
Avg merge
15h 50m
Merged PRs (30d)
17

Description

**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]()

```csharp
ReadonlySpan input = ...;

var filter = input.ToFilter(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` extension method and make it returns an `Option`

**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](https://docs.microsoft.com/en-us/dotnet/api/system.text.json.jsonserializeroptions.maxdepth?view=net-9.0#system-text-json-jsonserializeroptions-maxdepth) provides

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.