-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use IndexOfAnyValues in Regex.Escape #78667
Merged
stephentoub
merged 2 commits into
dotnet:main
from
MihaZupan:indexofanyvalues-regex-escape
Nov 22, 2022
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I merged the PR, but... this should be NET8_0_OR_GREATER. Seems like an artifact of our build system right now that this work. Once we fix that, these are going to start to fail presumably.
cc: @ViktorHofer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, the
NET8
directives don't seem to exist yet.Once they are added, would we ever build this with an actual 7.0 target? That is, would this continue to just "work", while being misleading to the reader since the API doesn't actually exist on 7?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might. We have several libraries that build for older .NET Core versions, and while System.Text.RegularExpressions.dll itself isn't one of them, it's feasible the source generator could.
Plus, it's confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I would have used
#if NET
here instead as presumably at the time that we would ship a .NETCoreApp version of the Regex source generator (which isn't planned), we wouldn't build older tfms like net6.0 and net7.0 anymore.Can you please either submit a PR to change this to
#NET
or create an issue that tracks updating this toNET8_0_OR_GREATER
?Updating the tfm to net8.0 is being take care of via #78354.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW I think that's just as if not more confusing. All of this is .NET.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same objection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting that you object to that. Can you please elaborate? We use
#if NETCOREAPP
all over the places here in the repo to differentiate between "modern .NET -> NETCOREAPP" and older frameworks like ".NET Standard" and ".NET Framework".There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both .NET 7 and .NET 8 are netcoreapp.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's why I suggested to use
#if NET
as if we would ever make the source generator targetNETCOREAPP
we likely wouldn't buildnet7.0
anymore. We don't version preprocessor directives in the BCL if there isn't a current need. I.e., there aren't anyNETCOREAPP_3_1_OR_GREATER
(or earlier) symbols because we don't build such frameworks anymore.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.NET Core 3.1 is old and unsupported. We just shipped NET 7 last week. I'm glad it's not confusing to you; it's highly confusing to me. Many projects in the repo build for .NET 7, so seeing code that doesn't actually work on .NET 7 ifdef'd in a way that suggests it should is wrong, IMHO.