Skip to content

Commit

Permalink
Adding analyzer/fixer for the Regex Source Generator (#68976) (#69872)
Browse files Browse the repository at this point in the history
* Adding analyzer/fixer for the Regex Source Generator

* Adding some tests to the analyzer and fixer

* Fix build and reference live ref pack

* Address remaining feedback and fix top-level statement programs

* Addressing PR Feedback

* Disabling the tests for Mono
  • Loading branch information
joperezr authored May 27, 2022
1 parent 032a7dc commit 44d8b31
Show file tree
Hide file tree
Showing 22 changed files with 1,656 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,13 @@ internal static class DiagnosticDescriptors
category: Category,
DiagnosticSeverity.Info,
isEnabledByDefault: true);

public static DiagnosticDescriptor UseRegexSourceGeneration { get; } = new DiagnosticDescriptor(
id: "SYSLIB1046",
title: new LocalizableResourceString(nameof(SR.UseRegexSourceGeneratorTitle), SR.ResourceManager, typeof(FxResources.System.Text.RegularExpressions.Generator.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.UseRegexSourceGeneratorMessage), SR.ResourceManager, typeof(FxResources.System.Text.RegularExpressions.Generator.SR)),
category: Category,
DiagnosticSeverity.Info,
isEnabledByDefault: true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -284,4 +284,10 @@
<value>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</value>
<comment>{Locked="RegexOptions.NonBacktracking"}</comment>
</data>
</root>
<data name="UseRegexSourceGeneratorMessage" xml:space="preserve">
<value>Use 'RegexGeneratorAttribute' to generate the regular expression implementation at compile-time.</value>
</data>
<data name="UseRegexSourceGeneratorTitle" xml:space="preserve">
<value>Convert to 'RegexGenerator'.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,16 @@
<target state="translated">Neukončený komentář (?#...).</target>
<note />
</trans-unit>
<trans-unit id="UseRegexSourceGeneratorMessage">
<source>Use 'RegexGeneratorAttribute' to generate the regular expression implementation at compile-time.</source>
<target state="new">Use 'RegexGeneratorAttribute' to generate the regular expression implementation at compile-time.</target>
<note />
</trans-unit>
<trans-unit id="UseRegexSourceGeneratorTitle">
<source>Convert to 'RegexGenerator'.</source>
<target state="new">Convert to 'RegexGenerator'.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,16 @@
<target state="translated">Nicht abgeschlossener (?#...)-Kommentar.</target>
<note />
</trans-unit>
<trans-unit id="UseRegexSourceGeneratorMessage">
<source>Use 'RegexGeneratorAttribute' to generate the regular expression implementation at compile-time.</source>
<target state="new">Use 'RegexGeneratorAttribute' to generate the regular expression implementation at compile-time.</target>
<note />
</trans-unit>
<trans-unit id="UseRegexSourceGeneratorTitle">
<source>Convert to 'RegexGenerator'.</source>
<target state="new">Convert to 'RegexGenerator'.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,16 @@
<target state="translated">Comentario (?#...) sin terminar.</target>
<note />
</trans-unit>
<trans-unit id="UseRegexSourceGeneratorMessage">
<source>Use 'RegexGeneratorAttribute' to generate the regular expression implementation at compile-time.</source>
<target state="new">Use 'RegexGeneratorAttribute' to generate the regular expression implementation at compile-time.</target>
<note />
</trans-unit>
<trans-unit id="UseRegexSourceGeneratorTitle">
<source>Convert to 'RegexGenerator'.</source>
<target state="new">Convert to 'RegexGenerator'.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,16 @@
<target state="translated">Commentaire (?#...) inachevé.</target>
<note />
</trans-unit>
<trans-unit id="UseRegexSourceGeneratorMessage">
<source>Use 'RegexGeneratorAttribute' to generate the regular expression implementation at compile-time.</source>
<target state="new">Use 'RegexGeneratorAttribute' to generate the regular expression implementation at compile-time.</target>
<note />
</trans-unit>
<trans-unit id="UseRegexSourceGeneratorTitle">
<source>Convert to 'RegexGenerator'.</source>
<target state="new">Convert to 'RegexGenerator'.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,16 @@
<target state="translated">Commento (?#...) non terminato.</target>
<note />
</trans-unit>
<trans-unit id="UseRegexSourceGeneratorMessage">
<source>Use 'RegexGeneratorAttribute' to generate the regular expression implementation at compile-time.</source>
<target state="new">Use 'RegexGeneratorAttribute' to generate the regular expression implementation at compile-time.</target>
<note />
</trans-unit>
<trans-unit id="UseRegexSourceGeneratorTitle">
<source>Convert to 'RegexGenerator'.</source>
<target state="new">Convert to 'RegexGenerator'.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,16 @@
<target state="translated">未終了の (?#...) コメントです。</target>
<note />
</trans-unit>
<trans-unit id="UseRegexSourceGeneratorMessage">
<source>Use 'RegexGeneratorAttribute' to generate the regular expression implementation at compile-time.</source>
<target state="new">Use 'RegexGeneratorAttribute' to generate the regular expression implementation at compile-time.</target>
<note />
</trans-unit>
<trans-unit id="UseRegexSourceGeneratorTitle">
<source>Convert to 'RegexGenerator'.</source>
<target state="new">Convert to 'RegexGenerator'.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,16 @@
<target state="translated">종결되지 않은 (?#...) 주석입니다.</target>
<note />
</trans-unit>
<trans-unit id="UseRegexSourceGeneratorMessage">
<source>Use 'RegexGeneratorAttribute' to generate the regular expression implementation at compile-time.</source>
<target state="new">Use 'RegexGeneratorAttribute' to generate the regular expression implementation at compile-time.</target>
<note />
</trans-unit>
<trans-unit id="UseRegexSourceGeneratorTitle">
<source>Convert to 'RegexGenerator'.</source>
<target state="new">Convert to 'RegexGenerator'.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,16 @@
<target state="translated">Niezakończony komentarz (?#...).</target>
<note />
</trans-unit>
<trans-unit id="UseRegexSourceGeneratorMessage">
<source>Use 'RegexGeneratorAttribute' to generate the regular expression implementation at compile-time.</source>
<target state="new">Use 'RegexGeneratorAttribute' to generate the regular expression implementation at compile-time.</target>
<note />
</trans-unit>
<trans-unit id="UseRegexSourceGeneratorTitle">
<source>Convert to 'RegexGenerator'.</source>
<target state="new">Convert to 'RegexGenerator'.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,16 @@
<target state="translated">Comentário (?#...) não finalizado.</target>
<note />
</trans-unit>
<trans-unit id="UseRegexSourceGeneratorMessage">
<source>Use 'RegexGeneratorAttribute' to generate the regular expression implementation at compile-time.</source>
<target state="new">Use 'RegexGeneratorAttribute' to generate the regular expression implementation at compile-time.</target>
<note />
</trans-unit>
<trans-unit id="UseRegexSourceGeneratorTitle">
<source>Convert to 'RegexGenerator'.</source>
<target state="new">Convert to 'RegexGenerator'.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,16 @@
<target state="translated">Комментарий (?#...) без признака завершения.</target>
<note />
</trans-unit>
<trans-unit id="UseRegexSourceGeneratorMessage">
<source>Use 'RegexGeneratorAttribute' to generate the regular expression implementation at compile-time.</source>
<target state="new">Use 'RegexGeneratorAttribute' to generate the regular expression implementation at compile-time.</target>
<note />
</trans-unit>
<trans-unit id="UseRegexSourceGeneratorTitle">
<source>Convert to 'RegexGenerator'.</source>
<target state="new">Convert to 'RegexGenerator'.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,16 @@
<target state="translated">Sonlandırılmayan (?#...) yorumu.</target>
<note />
</trans-unit>
<trans-unit id="UseRegexSourceGeneratorMessage">
<source>Use 'RegexGeneratorAttribute' to generate the regular expression implementation at compile-time.</source>
<target state="new">Use 'RegexGeneratorAttribute' to generate the regular expression implementation at compile-time.</target>
<note />
</trans-unit>
<trans-unit id="UseRegexSourceGeneratorTitle">
<source>Convert to 'RegexGenerator'.</source>
<target state="new">Convert to 'RegexGenerator'.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,16 @@
<target state="translated">未终止的(?#...)注释。</target>
<note />
</trans-unit>
<trans-unit id="UseRegexSourceGeneratorMessage">
<source>Use 'RegexGeneratorAttribute' to generate the regular expression implementation at compile-time.</source>
<target state="new">Use 'RegexGeneratorAttribute' to generate the regular expression implementation at compile-time.</target>
<note />
</trans-unit>
<trans-unit id="UseRegexSourceGeneratorTitle">
<source>Convert to 'RegexGenerator'.</source>
<target state="new">Convert to 'RegexGenerator'.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,16 @@
<target state="translated">未結束的 (?#...) 註解。</target>
<note />
</trans-unit>
<trans-unit id="UseRegexSourceGeneratorMessage">
<source>Use 'RegexGeneratorAttribute' to generate the regular expression implementation at compile-time.</source>
<target state="new">Use 'RegexGeneratorAttribute' to generate the regular expression implementation at compile-time.</target>
<note />
</trans-unit>
<trans-unit id="UseRegexSourceGeneratorTitle">
<source>Convert to 'RegexGenerator'.</source>
<target state="new">Convert to 'RegexGenerator'.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
Loading

0 comments on commit 44d8b31

Please sign in to comment.