Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ namespace System.Text.RegularExpressions.Generator
{
internal static class DiagnosticDescriptors
{
private const string Category = "RegexGenerator";

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",
category: Category,
DiagnosticSeverity.Error,
isEnabledByDefault: true,
customTags: WellKnownDiagnosticTags.NotConfigurable);
Expand All @@ -21,7 +23,7 @@ internal static class DiagnosticDescriptors
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",
category: Category,
DiagnosticSeverity.Error,
isEnabledByDefault: true,
customTags: WellKnownDiagnosticTags.NotConfigurable);
Expand All @@ -30,7 +32,7 @@ internal static class DiagnosticDescriptors
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",
category: Category,
DiagnosticSeverity.Error,
isEnabledByDefault: true,
customTags: WellKnownDiagnosticTags.NotConfigurable);
Expand All @@ -39,7 +41,7 @@ internal static class DiagnosticDescriptors
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",
category: Category,
DiagnosticSeverity.Error,
isEnabledByDefault: true,
customTags: WellKnownDiagnosticTags.NotConfigurable);
Expand All @@ -48,9 +50,17 @@ internal static class DiagnosticDescriptors
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",
category: Category,
DiagnosticSeverity.Error,
isEnabledByDefault: true,
customTags: WellKnownDiagnosticTags.NotConfigurable);

public static DiagnosticDescriptor LimitedSourceGeneration { get; } = new DiagnosticDescriptor(
id: "SYSLIB1045",
title: new LocalizableResourceString(nameof(SR.LimitedSourceGenerationTitle), SR.ResourceManager, typeof(FxResources.System.Text.RegularExpressions.Generator.SR)),
messageFormat: new LocalizableResourceString(nameof(SR.LimitedSourceGenerationMessage), SR.ResourceManager, typeof(FxResources.System.Text.RegularExpressions.Generator.SR)),
category: Category,
DiagnosticSeverity.Info,
isEnabledByDefault: true);
}
}
1,798 changes: 293 additions & 1,505 deletions src/libraries/System.Text.RegularExpressions/gen/RegexGenerator.Emitter.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ private static bool IsSyntaxTargetForGeneration(SyntaxNode node) =>
SymbolDisplayFormat.FullyQualifiedFormat.WithGlobalNamespaceStyle(SymbolDisplayGlobalNamespaceStyle.Omitted));

var regexMethod = new RegexMethod(
methodSyntax,
regexMethodSymbol.Name,
methodSyntax.Modifiers.ToString(),
pattern,
Expand Down Expand Up @@ -231,7 +232,7 @@ static bool IsAllowedKind(SyntaxKind kind) =>
}

/// <summary>A regex method.</summary>
internal sealed record RegexMethod(string MethodName, string Modifiers, string Pattern, RegexOptions Options, int MatchTimeout, RegexCode Code);
internal sealed record RegexMethod(MethodDeclarationSyntax MethodSyntax, string MethodName, string Modifiers, string Pattern, RegexOptions Options, int MatchTimeout, RegexCode Code);

/// <summary>A type holding a regex method.</summary>
internal sealed record RegexType(RegexMethod? Method, string Keyword, string Namespace, string Name, string Constraints)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
context.ReportDiagnostic(d);
break;

case string s:
code.Add(s);
case ValueTuple<string, ImmutableArray<Diagnostic>> t:
code.Add(t.Item1);
foreach (Diagnostic d in t.Item2)
{
context.ReportDiagnostic(d);
}
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@
<data name="InvalidLangVersionMessage" xml:space="preserve">
<value>C# LangVersion of 10 or greater is required</value>
</data>
<data name="LimitedSourceGenerationTitle" xml:space="preserve">
<value>RegexGenerator limitation reached.</value>
</data>
<data name="LimitedSourceGenerationMessage" xml:space="preserve">
<value>The RegexGenerator couldn't generate a complete source implementation for the specified regular expression, due to an unsupported option or too complex a regular expression. The implementation will interpret the regular expression at run-time.</value>
</data>
<data name="Generic" xml:space="preserve">
<value>Regular expression parser error '{0}' at offset {1}.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@
<target state="translated">Délka nemůže být menší než 0 nebo přesáhnout délku vstupu.</target>
<note />
</trans-unit>
<trans-unit id="LimitedSourceGenerationMessage">
<source>The RegexGenerator couldn't generate a complete source implementation for the specified regular expression, due to an unsupported option or too complex a regular expression. The implementation will interpret the regular expression at run-time.</source>
<target state="new">The RegexGenerator couldn't generate a complete source implementation for the specified regular expression, due to an unsupported option or too complex a regular expression. The implementation will interpret the regular expression at run-time.</target>
<note />
</trans-unit>
<trans-unit id="LimitedSourceGenerationTitle">
<source>RegexGenerator limitation reached.</source>
<target state="new">RegexGenerator limitation reached.</target>
<note />
</trans-unit>
<trans-unit id="MakeException">
<source>Invalid pattern '{0}' at offset {1}. {2}</source>
<target state="translated">Neplatný vzor {0} u posunu {1}. {2}</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@
<target state="translated">Die Länge darf nicht kleiner als 0 sein oder die Eingabelänge überschreiten.</target>
<note />
</trans-unit>
<trans-unit id="LimitedSourceGenerationMessage">
<source>The RegexGenerator couldn't generate a complete source implementation for the specified regular expression, due to an unsupported option or too complex a regular expression. The implementation will interpret the regular expression at run-time.</source>
<target state="new">The RegexGenerator couldn't generate a complete source implementation for the specified regular expression, due to an unsupported option or too complex a regular expression. The implementation will interpret the regular expression at run-time.</target>
<note />
</trans-unit>
<trans-unit id="LimitedSourceGenerationTitle">
<source>RegexGenerator limitation reached.</source>
<target state="new">RegexGenerator limitation reached.</target>
<note />
</trans-unit>
<trans-unit id="MakeException">
<source>Invalid pattern '{0}' at offset {1}. {2}</source>
<target state="translated">Ungültiges Muster "{0}" bei Offset {1}. {2}</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@
<target state="translated">La longitud no puede ser inferior a 0 ni superar la longitud de entrada.</target>
<note />
</trans-unit>
<trans-unit id="LimitedSourceGenerationMessage">
<source>The RegexGenerator couldn't generate a complete source implementation for the specified regular expression, due to an unsupported option or too complex a regular expression. The implementation will interpret the regular expression at run-time.</source>
<target state="new">The RegexGenerator couldn't generate a complete source implementation for the specified regular expression, due to an unsupported option or too complex a regular expression. The implementation will interpret the regular expression at run-time.</target>
<note />
</trans-unit>
<trans-unit id="LimitedSourceGenerationTitle">
<source>RegexGenerator limitation reached.</source>
<target state="new">RegexGenerator limitation reached.</target>
<note />
</trans-unit>
<trans-unit id="MakeException">
<source>Invalid pattern '{0}' at offset {1}. {2}</source>
<target state="translated">Patrón '{0}' no válido en el desplazamiento {1}. {2}</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@
<target state="translated">La longueur ne peut pas être inférieure à 0 ou supérieure à la longueur d'entrée.</target>
<note />
</trans-unit>
<trans-unit id="LimitedSourceGenerationMessage">
<source>The RegexGenerator couldn't generate a complete source implementation for the specified regular expression, due to an unsupported option or too complex a regular expression. The implementation will interpret the regular expression at run-time.</source>
<target state="new">The RegexGenerator couldn't generate a complete source implementation for the specified regular expression, due to an unsupported option or too complex a regular expression. The implementation will interpret the regular expression at run-time.</target>
<note />
</trans-unit>
<trans-unit id="LimitedSourceGenerationTitle">
<source>RegexGenerator limitation reached.</source>
<target state="new">RegexGenerator limitation reached.</target>
<note />
</trans-unit>
<trans-unit id="MakeException">
<source>Invalid pattern '{0}' at offset {1}. {2}</source>
<target state="translated">Modèle « {0} » non valide au niveau du décalage {1}. {2}</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@
<target state="translated">Lenght non può essere minore di zero o superare la lunghezza di input.</target>
<note />
</trans-unit>
<trans-unit id="LimitedSourceGenerationMessage">
<source>The RegexGenerator couldn't generate a complete source implementation for the specified regular expression, due to an unsupported option or too complex a regular expression. The implementation will interpret the regular expression at run-time.</source>
<target state="new">The RegexGenerator couldn't generate a complete source implementation for the specified regular expression, due to an unsupported option or too complex a regular expression. The implementation will interpret the regular expression at run-time.</target>
<note />
</trans-unit>
<trans-unit id="LimitedSourceGenerationTitle">
<source>RegexGenerator limitation reached.</source>
<target state="new">RegexGenerator limitation reached.</target>
<note />
</trans-unit>
<trans-unit id="MakeException">
<source>Invalid pattern '{0}' at offset {1}. {2}</source>
<target state="translated">Criterio '{0}' non valido alla posizione di offset {1}. {2}</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@
<target state="translated">長さを 0 未満に設定したり、入力の長さを超えることはできません。</target>
<note />
</trans-unit>
<trans-unit id="LimitedSourceGenerationMessage">
<source>The RegexGenerator couldn't generate a complete source implementation for the specified regular expression, due to an unsupported option or too complex a regular expression. The implementation will interpret the regular expression at run-time.</source>
<target state="new">The RegexGenerator couldn't generate a complete source implementation for the specified regular expression, due to an unsupported option or too complex a regular expression. The implementation will interpret the regular expression at run-time.</target>
<note />
</trans-unit>
<trans-unit id="LimitedSourceGenerationTitle">
<source>RegexGenerator limitation reached.</source>
<target state="new">RegexGenerator limitation reached.</target>
<note />
</trans-unit>
<trans-unit id="MakeException">
<source>Invalid pattern '{0}' at offset {1}. {2}</source>
<target state="translated">オフセット {1} に無効なパターン '{0}' があります。{2}</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@
<target state="translated">길이는 0보다 작거나 입력 길이를 초과할 수 없습니다.</target>
<note />
</trans-unit>
<trans-unit id="LimitedSourceGenerationMessage">
<source>The RegexGenerator couldn't generate a complete source implementation for the specified regular expression, due to an unsupported option or too complex a regular expression. The implementation will interpret the regular expression at run-time.</source>
<target state="new">The RegexGenerator couldn't generate a complete source implementation for the specified regular expression, due to an unsupported option or too complex a regular expression. The implementation will interpret the regular expression at run-time.</target>
<note />
</trans-unit>
<trans-unit id="LimitedSourceGenerationTitle">
<source>RegexGenerator limitation reached.</source>
<target state="new">RegexGenerator limitation reached.</target>
<note />
</trans-unit>
<trans-unit id="MakeException">
<source>Invalid pattern '{0}' at offset {1}. {2}</source>
<target state="translated">오프셋 {1}에서 잘못된 패턴 '{0}'. {2}</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@
<target state="translated">Długość nie może być mniejsza od 0 ani przekraczać długości danych wejściowych.</target>
<note />
</trans-unit>
<trans-unit id="LimitedSourceGenerationMessage">
<source>The RegexGenerator couldn't generate a complete source implementation for the specified regular expression, due to an unsupported option or too complex a regular expression. The implementation will interpret the regular expression at run-time.</source>
<target state="new">The RegexGenerator couldn't generate a complete source implementation for the specified regular expression, due to an unsupported option or too complex a regular expression. The implementation will interpret the regular expression at run-time.</target>
<note />
</trans-unit>
<trans-unit id="LimitedSourceGenerationTitle">
<source>RegexGenerator limitation reached.</source>
<target state="new">RegexGenerator limitation reached.</target>
<note />
</trans-unit>
<trans-unit id="MakeException">
<source>Invalid pattern '{0}' at offset {1}. {2}</source>
<target state="translated">Nieprawidłowy wzorzec „{0}” przy przesunięciu {1}. {2}</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@
<target state="translated">Comprimento não pode ser menor que 0 ou exceder o comprimento de entrada.</target>
<note />
</trans-unit>
<trans-unit id="LimitedSourceGenerationMessage">
<source>The RegexGenerator couldn't generate a complete source implementation for the specified regular expression, due to an unsupported option or too complex a regular expression. The implementation will interpret the regular expression at run-time.</source>
<target state="new">The RegexGenerator couldn't generate a complete source implementation for the specified regular expression, due to an unsupported option or too complex a regular expression. The implementation will interpret the regular expression at run-time.</target>
<note />
</trans-unit>
<trans-unit id="LimitedSourceGenerationTitle">
<source>RegexGenerator limitation reached.</source>
<target state="new">RegexGenerator limitation reached.</target>
<note />
</trans-unit>
<trans-unit id="MakeException">
<source>Invalid pattern '{0}' at offset {1}. {2}</source>
<target state="translated">Padrão inválido '{0}' no deslocamento {1}. {2}</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@
<target state="translated">Длина не может быть меньше 0 или превышать длину ввода.</target>
<note />
</trans-unit>
<trans-unit id="LimitedSourceGenerationMessage">
<source>The RegexGenerator couldn't generate a complete source implementation for the specified regular expression, due to an unsupported option or too complex a regular expression. The implementation will interpret the regular expression at run-time.</source>
<target state="new">The RegexGenerator couldn't generate a complete source implementation for the specified regular expression, due to an unsupported option or too complex a regular expression. The implementation will interpret the regular expression at run-time.</target>
<note />
</trans-unit>
<trans-unit id="LimitedSourceGenerationTitle">
<source>RegexGenerator limitation reached.</source>
<target state="new">RegexGenerator limitation reached.</target>
<note />
</trans-unit>
<trans-unit id="MakeException">
<source>Invalid pattern '{0}' at offset {1}. {2}</source>
<target state="translated">Недопустимый шаблон "{0}" со смещением {1}. {2}</target>
Expand Down
Loading