Skip to content
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
merged 2 commits into from
Nov 22, 2022

Conversation

MihaZupan
Copy link
Member

@MihaZupan MihaZupan commented Nov 21, 2022

Contributes to #78204

Method Toolchain Input Mean Error Ratio
Escape main \\\\(...)\\\\ [100] 729.5873 ns 4.3207 ns 1.00
Escape pr \\\\(...)\\\\ [100] 933.7590 ns 4.9799 ns 1.28
Escape main aaaa(...)aaaa [100] 64.3942 ns 0.2537 ns 1.00
Escape pr aaaa(...)aaaa [100] 8.3966 ns 0.0516 ns 0.13

@ghost
Copy link

ghost commented Nov 21, 2022

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

Issue Details

Contributes to #78204

Author: MihaZupan
Assignees: -
Labels:

area-System.Text.RegularExpressions

Milestone: 8.0.0

@ghost ghost assigned MihaZupan Nov 21, 2022
@stephentoub stephentoub merged commit cce374c into dotnet:main Nov 22, 2022
@@ -2081,6 +2076,27 @@ private bool IsCaptureSlot(int i)
// ' a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Q, S, 0, 0, 0};

#if NET7_0_OR_GREATER
Copy link
Member

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

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member

@ViktorHofer ViktorHofer Nov 22, 2022

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 to NET8_0_OR_GREATER?

Updating the tfm to net8.0 is being take care of via #78354.

Copy link
Member

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

FWIW I think that's just as if not more confusing. All of this is .NET.

Copy link
Member

Choose a reason for hiding this comment

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

Same objection.

Copy link
Member

@ViktorHofer ViktorHofer Nov 22, 2022

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".

Copy link
Member

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.

Copy link
Member

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 target NETCOREAPP we likely wouldn't build net7.0 anymore. We don't version preprocessor directives in the BCL if there isn't a current need. I.e., there aren't any NETCOREAPP_3_1_OR_GREATER (or earlier) symbols because we don't build such frameworks anymore.

Copy link
Member

@stephentoub stephentoub Nov 22, 2022

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.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 22, 2022
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.

3 participants