-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Add initial regex source generator #59186
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
dd903b0
Add RegexGeneratorAttribute
stephentoub 111a50b
Implement RegexGenerator
stephentoub 2380294
Add generator test project
stephentoub 68fea06
Integrate source generator into many regex tests
stephentoub e18adbe
Address PR feedback
stephentoub 857caed
Improve cachability of source generator
stephentoub 2d4f159
Use closest matching ctor from GetRegexAsync
stephentoub 8abd7fb
Improve a few of the polyfills
stephentoub fba00ee
Address PR feedback
stephentoub 3963f7f
Fully qualify types and remove unnecessary $s
stephentoub 1c1c1f9
Suppress a couple more warnings
stephentoub 818f844
Fix stray !
stephentoub 2435db4
Fix TODO about unrolling multi comparisons
stephentoub 400147d
Update resources per PR feedback
stephentoub a07f142
Add more tests, clean up parser code, and allow instance/interface me…
stephentoub e153b3a
Fix test suppression on mobile
stephentoub 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 hidden or 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
This file contains hidden or 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
56 changes: 56 additions & 0 deletions
56
src/libraries/System.Text.RegularExpressions/gen/DiagnosticDescriptors.cs
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using Microsoft.CodeAnalysis; | ||
|
||
namespace System.Text.RegularExpressions.Generator | ||
{ | ||
internal static class DiagnosticDescriptors | ||
{ | ||
public static DiagnosticDescriptor InvalidRegexGeneratorAttribute { get; } = new DiagnosticDescriptor( | ||
id: "SYSLIB1040", | ||
title: new LocalizableResourceString(nameof(SR.InvalidRegexGeneratorAttributeTitle), SR.ResourceManager, typeof(FxResources.System.Text.RegularExpressions.Generator.SR)), | ||
messageFormat: new LocalizableResourceString(nameof(SR.InvalidRegexGeneratorAttributeMessage), SR.ResourceManager, typeof(FxResources.System.Text.RegularExpressions.Generator.SR)), | ||
category: "RegexGenerator", | ||
DiagnosticSeverity.Error, | ||
isEnabledByDefault: true, | ||
customTags: WellKnownDiagnosticTags.NotConfigurable); | ||
|
||
public static DiagnosticDescriptor MultipleRegexGeneratorAttributes { get; } = new DiagnosticDescriptor( | ||
id: "SYSLIB1041", | ||
title: new LocalizableResourceString(nameof(SR.InvalidRegexGeneratorAttributeTitle), SR.ResourceManager, typeof(FxResources.System.Text.RegularExpressions.Generator.SR)), | ||
messageFormat: new LocalizableResourceString(nameof(SR.MultipleRegexGeneratorAttributesMessage), SR.ResourceManager, typeof(FxResources.System.Text.RegularExpressions.Generator.SR)), | ||
category: "RegexGenerator", | ||
DiagnosticSeverity.Error, | ||
isEnabledByDefault: true, | ||
customTags: WellKnownDiagnosticTags.NotConfigurable); | ||
|
||
public static DiagnosticDescriptor InvalidRegexArguments { get; } = new DiagnosticDescriptor( | ||
id: "SYSLIB1042", | ||
title: new LocalizableResourceString(nameof(SR.InvalidRegexGeneratorAttributeTitle), SR.ResourceManager, typeof(FxResources.System.Text.RegularExpressions.Generator.SR)), | ||
messageFormat: new LocalizableResourceString(nameof(SR.InvalidRegexArgumentsMessage), SR.ResourceManager, typeof(FxResources.System.Text.RegularExpressions.Generator.SR)), | ||
category: "RegexGenerator", | ||
DiagnosticSeverity.Error, | ||
isEnabledByDefault: true, | ||
customTags: WellKnownDiagnosticTags.NotConfigurable); | ||
|
||
public static DiagnosticDescriptor RegexMethodMustHaveValidSignature { get; } = new DiagnosticDescriptor( | ||
id: "SYSLIB1043", | ||
title: new LocalizableResourceString(nameof(SR.InvalidRegexGeneratorAttributeTitle), SR.ResourceManager, typeof(FxResources.System.Text.RegularExpressions.Generator.SR)), | ||
messageFormat: new LocalizableResourceString(nameof(SR.RegexMethodMustHaveValidSignatureMessage), SR.ResourceManager, typeof(FxResources.System.Text.RegularExpressions.Generator.SR)), | ||
category: "RegexGenerator", | ||
DiagnosticSeverity.Error, | ||
isEnabledByDefault: true, | ||
customTags: WellKnownDiagnosticTags.NotConfigurable); | ||
|
||
public static DiagnosticDescriptor InvalidLangVersion { get; } = new DiagnosticDescriptor( | ||
id: "SYSLIB1044", | ||
title: new LocalizableResourceString(nameof(SR.InvalidRegexGeneratorAttributeTitle), SR.ResourceManager, typeof(FxResources.System.Text.RegularExpressions.Generator.SR)), | ||
messageFormat: new LocalizableResourceString(nameof(SR.InvalidLangVersionMessage), SR.ResourceManager, typeof(FxResources.System.Text.RegularExpressions.Generator.SR)), | ||
category: "RegexGenerator", | ||
DiagnosticSeverity.Error, | ||
isEnabledByDefault: true, | ||
customTags: WellKnownDiagnosticTags.NotConfigurable); | ||
} | ||
} |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.