-
-
Notifications
You must be signed in to change notification settings - Fork 229
Closed
Labels
Description
We've got lots of regexes defined as properties, with backing methods specifically because we had to use methods to leverage the source generated regexes. For example:
sentry-dotnet/src/Sentry/Internal/OriginHelper.cs
Lines 8 to 18 in 3e70c31
| #if NET8_0_OR_GREATER | |
| [GeneratedRegex(ValidOriginPattern, RegexOptions.Compiled)] | |
| private static partial Regex ValidOriginRegEx(); | |
| private static readonly Regex ValidOrigin = ValidOriginRegEx(); | |
| #else | |
| private static readonly Regex ValidOrigin = new (ValidOriginPattern, RegexOptions.Compiled); | |
| #endif | |
| public static bool IsValidOrigin(string? value) => value == null || ValidOrigin.IsMatch(value); | |
| internal static string? TryParse(string origin) => IsValidOrigin(origin) ? origin : null; |
We should be able to tidy that code up now that [GeneratedRegex] can also be added to properties.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Projects
Status
Done