Skip to content

Several tweaks to RegexGenerator (the tool, not the emitted code)#60667

Merged
stephentoub merged 1 commit intodotnet:mainfrom
stephentoub:regexgentweaks
Oct 21, 2021
Merged

Several tweaks to RegexGenerator (the tool, not the emitted code)#60667
stephentoub merged 1 commit intodotnet:mainfrom
stephentoub:regexgentweaks

Conversation

@stephentoub
Copy link
Copy Markdown
Member

  • Fixed a bunch of nullable reference types warnings (they're suppressed as a netstandard2.0 project, but I temporarily and locally compiled it for netcoreapp current to get clean)
  • Fixed the comparer used to aid in avoiding recomputing regexes when typing
  • Added a hook to start exploring code gen for NonBacktracking

@ghost
Copy link
Copy Markdown

ghost commented Oct 20, 2021

Tagging subscribers to this area: @eerhardt, @dotnet/area-system-text-regularexpressions
See info in area-owners.md if you want to be subscribed.

Issue Details
  • Fixed a bunch of nullable reference types warnings (they're suppressed as a netstandard2.0 project, but I temporarily and locally compiled it for netcoreapp current to get clean)
  • Fixed the comparer used to aid in avoiding recomputing regexes when typing
  • Added a hook to start exploring code gen for NonBacktracking
Author: stephentoub
Assignees: -
Labels:

area-System.Text.RegularExpressions

Milestone: 7.0.0

- Fixed a bunch of nullable reference types warnings (they're suppressed as a netstandard2.0 project, but I temporarily and locally compiled it for netcoreapp current to get clean)
- Fixed the comparer used to aid in avoiding recomputing regexes when typing
- Added a hook to start exploring code gen for NonBacktracking
Copy link
Copy Markdown
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one question. LGTM otherwise.

}
private static bool SupportsCustomCodeGeneration(RegexMethod rm) =>
// The generator doesn't currently know how to emit code for NonBacktracking.
(rm.Options & RegexOptions.NonBacktracking) == 0;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about invalid options? Before we would return false, but now we would return true.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're weeded out in the parser here:

// Validate the options
const RegexOptions SupportedOptions =
RegexOptions.IgnoreCase |
RegexOptions.Multiline |
RegexOptions.ExplicitCapture |
RegexOptions.Compiled |
RegexOptions.Singleline |
RegexOptions.IgnorePatternWhitespace |
RegexOptions.RightToLeft |
#if DEBUG
RegexOptions.Debug |
#endif
RegexOptions.ECMAScript |
RegexOptions.CultureInvariant |
RegexOptions.NonBacktracking;
if ((regexOptions & ~SupportedOptions) != 0)
{
return Diagnostic.Create(DiagnosticDescriptors.InvalidRegexArguments, methodSyntax.GetLocation(), "options");
}

@stephentoub stephentoub merged commit ed9ab1b into dotnet:main Oct 21, 2021
@stephentoub stephentoub deleted the regexgentweaks branch October 21, 2021 17:04
@ghost ghost locked as resolved and limited conversation to collaborators Nov 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants