Skip to content

Optimize the Regex source generator's handling of Compilation objects. - #65431

Merged
stephentoub merged 4 commits into
dotnet:mainfrom
teo-tsirpanis:regex-gen-optimize
Feb 23, 2022
Merged

Optimize the Regex source generator's handling of Compilation objects.#65431
stephentoub merged 4 commits into
dotnet:mainfrom
teo-tsirpanis:regex-gen-optimize

Conversation

@teo-tsirpanis

Copy link
Copy Markdown
Contributor

This PR optimizes the Regex source generator's pipeline in a similar way to what was done in #64579.

The Compilation object was mostly removed from the pipeline, with its presence being restricted to an IncrementalValueProvider<bool> that contains whether unsafe code is allowed, which is seamlessly combined to the main pipeline without needing a custom comparer.

The GetRegexTypeToEmit method was merged with the GetSemanticTargetForGeneration method and moved earlier in the pipeline, according to feedback from the linked PR.

@ghostghost added area-System.Text.RegularExpressions community-contribution Indicates that the PR has been added by a community member labels Feb 16, 2022
@ghost

Copy link
Copy Markdown

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

Issue Details

This PR optimizes the Regex source generator's pipeline in a similar way to what was done in #64579.

The Compilation object was mostly removed from the pipeline, with its presence being restricted to an IncrementalValueProvider<bool> that contains whether unsafe code is allowed, which is seamlessly combined to the main pipeline without needing a custom comparer.

The GetRegexTypeToEmit method was merged with the GetSemanticTargetForGeneration method and moved earlier in the pipeline, according to feedback from the linked PR.

Author:teo-tsirpanis
Assignees:-
Labels:

area-System.Text.RegularExpressions

Milestone:-

@teo-tsirpanisteo-tsirpanis changed the title Optimize the Regex source generator's handling of Compilation objects.Optimize the Regex source generator's handling of Compilation objects.Feb 16, 2022
Comment threadsrc/libraries/System.Text.RegularExpressions/gen/RegexGenerator.Parser.cs Outdated
@stephentoub

Copy link
Copy Markdown
Member

@sharwell, @chsienki, please review.

@chsienkichsienki left a comment

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.

Thanks @teo-tsirpanis, this looks like a nice improvement! I've written my thoughts on the attribute lookup change.

Will leave it to @stephentoub to decide, but maybe for this PR we should leave the old behavior using GetBestTypeByMetadataName and consider being more permissive in a separate change.

@teo-tsirpanis

Copy link
Copy Markdown
ContributorAuthor

PR feedback was addressed; we still use GetBestTypeByMetadataName.

Comment threadsrc/libraries/System.Text.RegularExpressions/gen/RegexGenerator.cs Outdated
@joperezrjoperezr self-assigned this Feb 22, 2022

@stephentoubstephentoub left a comment

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.

Thanks.

@stephentoub
stephentoub merged commit 05920e1 into dotnet:mainFeb 23, 2022
@teo-tsirpanis
teo-tsirpanis deleted the regex-gen-optimize branch February 23, 2022 13:55
@ghostghost locked as resolved and limited conversation to collaborators Mar 25, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Text.RegularExpressionscommunity-contributionIndicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@teo-tsirpanis@stephentoub@sharwell@chsienki@joperezr