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
Regex("(?(?x)yesno)")// System.NullReferenceException: Object reference not set to an instance of an object.
Expected: a normal ArgumentException as any invalid regex raises that. The error in this regex is that the conditional part missing an alternation character |. Correct would be: ?(?x)yes|no)
Note that (?(x)yesno) compiles fine, so there's an argument to be made for the above to compile fine too, as technically they should be equivalent (a conditional alternation with only a true-part).
(found while working on #38872, but not related to that issue per se)
The text was updated successfully, but these errors were encountered:
This was fixed in .NET Core several versions ago. It now produces:
"System.Text.RegularExpressions.RegexParseException: Invalid pattern '(?(?x)yesno)' at offset 5. Unrecognized grouping construct."
Description
The following code raises an NRE:
Expected: a normal
ArgumentException
as any invalid regex raises that. The error in this regex is that the conditional part missing an alternation character|
. Correct would be:?(?x)yes|no)
Note that
(?(x)yesno)
compiles fine, so there's an argument to be made for the above to compile fine too, as technically they should be equivalent (a conditional alternation with only a true-part).(found while working on #38872, but not related to that issue per se)
The text was updated successfully, but these errors were encountered: