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 Regex source generator #2794

Closed
martincostello opened this issue Apr 14, 2024 · 3 comments · Fixed by #2799
Closed

Use Regex source generator #2794

martincostello opened this issue Apr 14, 2024 · 3 comments · Fixed by #2799
Assignees

Comments

@martincostello
Copy link
Collaborator

For net7.0 and later we can look to leverage the Regex source generator to improve performance.

For example:

private static Regex RefTagPattern = new Regex(@"<(see|paramref) (name|cref|langword)=""([TPF]{1}:)?(?<display>.+?)"" ?/>");
private static Regex CodeTagPattern = new Regex(@"<c>(?<display>.+?)</c>");
private static Regex MultilineCodeTagPattern = new Regex(@"<code>(?<display>.+?)</code>", RegexOptions.Singleline);
private static Regex ParaTagPattern = new Regex(@"<para>(?<display>.+?)</para>", RegexOptions.Singleline);

@martincostello martincostello added the help-wanted A change up for grabs for contributions from the community label Apr 14, 2024
@martincostello martincostello self-assigned this Apr 14, 2024
@martincostello martincostello removed the help-wanted A change up for grabs for contributions from the community label Apr 14, 2024
@martincostello
Copy link
Collaborator Author

Turns out those are the only static occurences in the whole code base. All the others are based on dynamic inputs.

martincostello added a commit to martincostello/Swashbuckle.AspNetCore that referenced this issue Apr 14, 2024
Use the Regex source generator for .NET 7+.
Resolves domaindrivendev#2794.
martincostello added a commit to martincostello/Swashbuckle.AspNetCore that referenced this issue Apr 16, 2024
Use the Regex source generator for .NET 7+.
Resolves domaindrivendev#2794.
martincostello added a commit to martincostello/Swashbuckle.AspNetCore that referenced this issue Apr 23, 2024
Use the Regex source generator for .NET 7+.
Resolves domaindrivendev#2794.
martincostello added a commit to martincostello/Swashbuckle.AspNetCore that referenced this issue May 1, 2024
Use the Regex source generator for .NET 7+.
Resolves domaindrivendev#2794.
martincostello added a commit to martincostello/Swashbuckle.AspNetCore that referenced this issue May 8, 2024
Use the Regex source generator for .NET 7+.
Resolves domaindrivendev#2794.
@Saibamen
Copy link
Contributor

Saibamen commented May 14, 2024

How much perf boost after your changes?

@martincostello
Copy link
Collaborator Author

I didn't measure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants