From b896c4ae6e98b3231017bf3e75f7f849113d8dd1 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Wed, 20 Jul 2022 20:33:47 +0200 Subject: [PATCH 1/5] Minor refactoring for UpgradeToRegexGenerator --- .../gen/UpgradeToRegexGeneratorAnalyzer.cs | 40 ++++----- .../gen/UpgradeToRegexGeneratorCodeFixer.cs | 87 +++++-------------- 2 files changed, 40 insertions(+), 87 deletions(-) diff --git a/src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorAnalyzer.cs b/src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorAnalyzer.cs index 62efa986c2ead2..8a3ff0fcb41a10 100644 --- a/src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorAnalyzer.cs +++ b/src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorAnalyzer.cs @@ -27,8 +27,11 @@ public sealed class UpgradeToRegexGeneratorAnalyzer : DiagnosticAnalyzer private const string RegexTypeName = "System.Text.RegularExpressions.Regex"; private const string RegexGeneratorTypeName = "System.Text.RegularExpressions.RegexGeneratorAttribute"; - internal const string PatternIndexName = "PatternIndex"; - internal const string RegexOptionsIndexName = "RegexOptionsIndex"; + internal const string PatternArgumentName = "pattern"; + internal const string OptionsArgumentName = "options"; + + internal const string PatternKeyName = "Pattern"; + internal const string RegexOptionsKeyName = "RegexOption"; /// public override ImmutableArray SupportedDiagnostics => ImmutableArray.Create(DiagnosticDescriptors.UseRegexSourceGeneration); @@ -107,11 +110,8 @@ private static void AnalyzeInvocation(OperationAnalysisContext context, INamedTy // code fixer can later use that property bag to generate the code fix and emit the RegexGenerator attribute. if (staticMethodsToDetect.Contains(method)) { - string? patternArgumentIndex = null; - string? optionsArgumentIndex = null; - // Validate that arguments pattern and options are constant and timeout was not passed in. - if (!TryValidateParametersAndExtractArgumentIndices(invocationOperation.Arguments, ref patternArgumentIndex, ref optionsArgumentIndex)) + if (!TryValidateParametersAndExtractArgumentIndices(invocationOperation.Arguments, out string? patternArgument, out string? optionsArgument)) { return; } @@ -119,8 +119,8 @@ private static void AnalyzeInvocation(OperationAnalysisContext context, INamedTy // Create the property bag. ImmutableDictionary properties = ImmutableDictionary.CreateRange(new[] { - new KeyValuePair(PatternIndexName, patternArgumentIndex), - new KeyValuePair(RegexOptionsIndexName, optionsArgumentIndex) + new KeyValuePair(PatternKeyName, patternArgument), + new KeyValuePair(RegexOptionsKeyName, optionsArgument) }); // Report the diagnostic. @@ -150,10 +150,7 @@ private static void AnalyzeObjectCreation(OperationAnalysisContext context, INam return; } - string? patternArgumentIndex = null; - string? optionsArgumentIndex = null; - - if (!TryValidateParametersAndExtractArgumentIndices(operation.Arguments, ref patternArgumentIndex, ref optionsArgumentIndex)) + if (!TryValidateParametersAndExtractArgumentIndices(operation.Arguments, out string? patternArgument, out string? optionsArgument)) { return; } @@ -161,8 +158,8 @@ private static void AnalyzeObjectCreation(OperationAnalysisContext context, INam // Create the property bag. ImmutableDictionary properties = ImmutableDictionary.CreateRange(new[] { - new KeyValuePair(PatternIndexName, patternArgumentIndex), - new KeyValuePair(RegexOptionsIndexName, optionsArgumentIndex) + new KeyValuePair(PatternKeyName, patternArgument), + new KeyValuePair(RegexOptionsKeyName, optionsArgument) }); // Report the diagnostic. @@ -175,12 +172,13 @@ private static void AnalyzeObjectCreation(OperationAnalysisContext context, INam /// Validates the operation arguments ensuring they all have constant values, and if so it stores the argument /// indices for the pattern and options. If timeout argument was used, then this returns false. /// - private static bool TryValidateParametersAndExtractArgumentIndices(ImmutableArray arguments, ref string? patternArgumentIndex, ref string? optionsArgumentIndex) + private static bool TryValidateParametersAndExtractArgumentIndices(ImmutableArray arguments, out string? patternArgument, out string? optionsArgument) { const string timeoutArgumentName = "timeout"; const string matchTimeoutArgumentName = "matchTimeout"; - const string patternArgumentName = "pattern"; - const string optionsArgumentName = "options"; + + patternArgument = null; + optionsArgument = null; if (arguments == null) { @@ -200,19 +198,19 @@ private static bool TryValidateParametersAndExtractArgumentIndices(ImmutableArra } // If the argument is the pattern, then we validate that it is constant and we store the index. - if (argumentName.Equals(patternArgumentName, StringComparison.OrdinalIgnoreCase)) + if (argumentName.Equals(PatternArgumentName, StringComparison.OrdinalIgnoreCase)) { if (!IsConstant(argument)) { return false; } - patternArgumentIndex = i.ToString(); + patternArgument = (string)argument.Value.ConstantValue.Value; continue; } // If the argument is the options, then we validate that it is constant, that it doesn't have RegexOptions.NonBacktracking, and we store the index. - if (argumentName.Equals(optionsArgumentName, StringComparison.OrdinalIgnoreCase)) + if (argumentName.Equals(OptionsArgumentName, StringComparison.OrdinalIgnoreCase)) { if (!IsConstant(argument)) { @@ -225,7 +223,7 @@ private static bool TryValidateParametersAndExtractArgumentIndices(ImmutableArra return false; } - optionsArgumentIndex = i.ToString(); + optionsArgument = value.ToString(); continue; } } diff --git a/src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorCodeFixer.cs b/src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorCodeFixer.cs index f9c888a11c1a19..c02ac16c24c580 100644 --- a/src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorCodeFixer.cs +++ b/src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorCodeFixer.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Collections.Immutable; +using System.Composition; using System.Diagnostics; using System.Globalization; using System.Linq; @@ -24,7 +25,7 @@ namespace System.Text.RegularExpressions.Generator /// Roslyn code fixer that will listen to SysLIB1046 diagnostics and will provide a code fix which onboards a particular Regex into /// source generation. /// - [ExportCodeFixProvider(LanguageNames.CSharp)] + [ExportCodeFixProvider(LanguageNames.CSharp), Shared] public sealed class UpgradeToRegexGeneratorCodeFixer : CodeFixProvider { private const string RegexTypeName = "System.Text.RegularExpressions.Regex"; @@ -159,48 +160,21 @@ private static async Task ConvertToSourceGenerator(Document document, // Generate the modified type declaration depending on whether the callsite was a Regex constructor call // or a Regex static method invocation. + SyntaxNode replacement = generator.InvocationExpression(generator.IdentifierName(methodName)); if (operation is IInvocationOperation invocationOperation) // When using a Regex static method { - ImmutableArray arguments = invocationOperation.Arguments; + IEnumerable arguments = invocationOperation.Arguments + .Where(arg => arg.Parameter.Name is not (UpgradeToRegexGeneratorAnalyzer.OptionsArgumentName or UpgradeToRegexGeneratorAnalyzer.PatternArgumentName)) + .Select(arg => arg.Syntax); - // Parse the idices for where to get the arguments from. - int?[] indices = new[] - { - TryParseInt32(properties, UpgradeToRegexGeneratorAnalyzer.PatternIndexName), - TryParseInt32(properties, UpgradeToRegexGeneratorAnalyzer.RegexOptionsIndexName) - }; - - foreach (int? index in indices.Where(value => value != null).OrderByDescending(value => value)) - { - arguments = arguments.RemoveAt(index.GetValueOrDefault()); - } - - SyntaxNode createRegexMethod = generator.InvocationExpression(generator.IdentifierName(methodName)); - SyntaxNode method = generator.InvocationExpression(generator.MemberAccessExpression(createRegexMethod, invocationOperation.TargetMethod.Name), arguments.Select(arg => arg.Syntax).ToArray()); - - newTypeDeclarationOrCompilationUnit = newTypeDeclarationOrCompilationUnit.ReplaceNode(nodeToFix, WithTrivia(method, nodeToFix)); - } - else // When using a Regex constructor - { - SyntaxNode invokeMethod = generator.InvocationExpression(generator.IdentifierName(methodName)); - newTypeDeclarationOrCompilationUnit = newTypeDeclarationOrCompilationUnit.ReplaceNode(nodeToFix, WithTrivia(invokeMethod, nodeToFix)); + replacement = generator.InvocationExpression(generator.MemberAccessExpression(replacement, invocationOperation.TargetMethod.Name), arguments); } - // Initialize the inputs for the RegexGenerator attribute. - SyntaxNode? patternValue = null; - SyntaxNode? regexOptionsValue = null; + newTypeDeclarationOrCompilationUnit = newTypeDeclarationOrCompilationUnit.ReplaceNode(nodeToFix, WithTrivia(replacement, nodeToFix)); - // Try to get the pattern and RegexOptions values out from the diagnostic's property bag. - if (operation is IObjectCreationOperation objectCreationOperation) // When using the Regex constructors - { - patternValue = GetNode((objectCreationOperation).Arguments, properties, UpgradeToRegexGeneratorAnalyzer.PatternIndexName, generator, useOptionsMemberExpression: false, compilation, cancellationToken); - regexOptionsValue = GetNode((objectCreationOperation).Arguments, properties, UpgradeToRegexGeneratorAnalyzer.RegexOptionsIndexName, generator, useOptionsMemberExpression: true, compilation, cancellationToken); - } - else if (operation is IInvocationOperation invocation) // When using the Regex static methods. - { - patternValue = GetNode(invocation.Arguments, properties, UpgradeToRegexGeneratorAnalyzer.PatternIndexName, generator, useOptionsMemberExpression: false, compilation, cancellationToken); - regexOptionsValue = GetNode(invocation.Arguments, properties, UpgradeToRegexGeneratorAnalyzer.RegexOptionsIndexName, generator, useOptionsMemberExpression: true, compilation, cancellationToken); - } + // Initialize the inputs for the RegexGenerator attribute. + SyntaxNode? patternValue = GetNode(properties, UpgradeToRegexGeneratorAnalyzer.PatternKeyName, generator, useOptionsMemberExpression: false); + SyntaxNode? regexOptionsValue = GetNode(properties, UpgradeToRegexGeneratorAnalyzer.RegexOptionsKeyName, generator, useOptionsMemberExpression: true); // Generate the new static partial method MethodDeclarationSyntax newMethod = (MethodDeclarationSyntax)generator.MethodDeclaration( @@ -244,57 +218,38 @@ static IEnumerable GetAllMembers(ITypeSymbol? symbol) } } - // Helper method that searches the passed in property bag for the property with the passed in name, and if found, it converts the - // value to an int. - static int? TryParseInt32(ImmutableDictionary properties, string name) - { - if (!properties.TryGetValue(name, out string? value)) - { - return null; - } - - if (!int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out int result)) - { - return null; - } - - return result; - } - // Helper method that looks int the properties bag for the index of the passed in propertyname, and then returns that index from the args parameter. - static SyntaxNode? GetNode(ImmutableArray args, ImmutableDictionary properties, string propertyName, SyntaxGenerator generator, bool useOptionsMemberExpression, Compilation compilation, CancellationToken cancellationToken) + static SyntaxNode? GetNode(ImmutableDictionary properties, string propertyName, SyntaxGenerator generator, bool useOptionsMemberExpression) { - int? index = TryParseInt32(properties, propertyName); - if (index == null) + string? propertyValue = properties[propertyName]; + if (propertyValue is null) { return null; } if (!useOptionsMemberExpression) { - return generator.LiteralExpression(args[index.Value].Value.ConstantValue.Value); + return generator.LiteralExpression(propertyValue); } else { - RegexOptions options = (RegexOptions)(int)args[index.Value].Value.ConstantValue.Value; - string optionsLiteral = Literal(options); - return SyntaxFactory.ParseExpression(optionsLiteral).SyntaxTree.GetRoot(cancellationToken); + string optionsLiteral = Literal(propertyValue); + return SyntaxFactory.ParseExpression(optionsLiteral); } } - static string Literal(RegexOptions options) + static string Literal(string stringifiedRegexOptions) { - string s = options.ToString(); - if (int.TryParse(s, NumberStyles.Integer, CultureInfo.InvariantCulture, out _)) + if (int.TryParse(stringifiedRegexOptions, NumberStyles.Integer, CultureInfo.InvariantCulture, out int options)) { // The options were formatted as an int, which means the runtime couldn't // produce a textual representation. So just output casting the value as an int. - return $"(RegexOptions)({(int)options})"; + return $"(RegexOptions)({options})"; } // Parse the runtime-generated "Option1, Option2" into each piece and then concat // them back together. - string[] parts = s.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + string[] parts = stringifiedRegexOptions.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < parts.Length; i++) { parts[i] = "RegexOptions." + parts[i].Trim(); From 0dc31e0e905f97c526480b9bd193b10e9fab649c Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Sun, 24 Jul 2022 20:52:58 +0200 Subject: [PATCH 2/5] Don't use properties bag --- .../gen/UpgradeToRegexGeneratorAnalyzer.cs | 32 +++---------------- .../gen/UpgradeToRegexGeneratorCodeFixer.cs | 30 ++++++++++------- 2 files changed, 23 insertions(+), 39 deletions(-) diff --git a/src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorAnalyzer.cs b/src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorAnalyzer.cs index 8a3ff0fcb41a10..1cad7116c54cc1 100644 --- a/src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorAnalyzer.cs +++ b/src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorAnalyzer.cs @@ -30,9 +30,6 @@ public sealed class UpgradeToRegexGeneratorAnalyzer : DiagnosticAnalyzer internal const string PatternArgumentName = "pattern"; internal const string OptionsArgumentName = "options"; - internal const string PatternKeyName = "Pattern"; - internal const string RegexOptionsKeyName = "RegexOption"; - /// public override ImmutableArray SupportedDiagnostics => ImmutableArray.Create(DiagnosticDescriptors.UseRegexSourceGeneration); @@ -111,22 +108,15 @@ private static void AnalyzeInvocation(OperationAnalysisContext context, INamedTy if (staticMethodsToDetect.Contains(method)) { // Validate that arguments pattern and options are constant and timeout was not passed in. - if (!TryValidateParametersAndExtractArgumentIndices(invocationOperation.Arguments, out string? patternArgument, out string? optionsArgument)) + if (!TryValidateParametersAndExtractArgumentIndices(invocationOperation.Arguments)) { return; } - // Create the property bag. - ImmutableDictionary properties = ImmutableDictionary.CreateRange(new[] - { - new KeyValuePair(PatternKeyName, patternArgument), - new KeyValuePair(RegexOptionsKeyName, optionsArgument) - }); - // Report the diagnostic. SyntaxNode? syntaxNodeForDiagnostic = invocationOperation.Syntax; Debug.Assert(syntaxNodeForDiagnostic != null); - context.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.UseRegexSourceGeneration, syntaxNodeForDiagnostic.GetLocation(), properties)); + context.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.UseRegexSourceGeneration, syntaxNodeForDiagnostic.GetLocation())); } } @@ -150,36 +140,26 @@ private static void AnalyzeObjectCreation(OperationAnalysisContext context, INam return; } - if (!TryValidateParametersAndExtractArgumentIndices(operation.Arguments, out string? patternArgument, out string? optionsArgument)) + if (!TryValidateParametersAndExtractArgumentIndices(operation.Arguments)) { return; } - // Create the property bag. - ImmutableDictionary properties = ImmutableDictionary.CreateRange(new[] - { - new KeyValuePair(PatternKeyName, patternArgument), - new KeyValuePair(RegexOptionsKeyName, optionsArgument) - }); - // Report the diagnostic. SyntaxNode? syntaxNodeForDiagnostic = operation.Syntax; Debug.Assert(syntaxNodeForDiagnostic is not null); - context.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.UseRegexSourceGeneration, syntaxNodeForDiagnostic.GetLocation(), properties)); + context.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.UseRegexSourceGeneration, syntaxNodeForDiagnostic.GetLocation())); } /// /// Validates the operation arguments ensuring they all have constant values, and if so it stores the argument /// indices for the pattern and options. If timeout argument was used, then this returns false. /// - private static bool TryValidateParametersAndExtractArgumentIndices(ImmutableArray arguments, out string? patternArgument, out string? optionsArgument) + private static bool TryValidateParametersAndExtractArgumentIndices(ImmutableArray arguments) { const string timeoutArgumentName = "timeout"; const string matchTimeoutArgumentName = "matchTimeout"; - patternArgument = null; - optionsArgument = null; - if (arguments == null) { return false; @@ -205,7 +185,6 @@ private static bool TryValidateParametersAndExtractArgumentIndices(ImmutableArra return false; } - patternArgument = (string)argument.Value.ConstantValue.Value; continue; } @@ -223,7 +202,6 @@ private static bool TryValidateParametersAndExtractArgumentIndices(ImmutableArra return false; } - optionsArgument = value.ToString(); continue; } } diff --git a/src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorCodeFixer.cs b/src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorCodeFixer.cs index c02ac16c24c580..9b0a35351488d2 100644 --- a/src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorCodeFixer.cs +++ b/src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorCodeFixer.cs @@ -156,25 +156,30 @@ private static async Task ConvertToSourceGenerator(Document document, // We generate a new invocation node to call our new partial method, and use it to replace the nodeToFix. DocumentEditor editor = await DocumentEditor.CreateAsync(document, cancellationToken).ConfigureAwait(false); SyntaxGenerator generator = editor.Generator; - ImmutableDictionary properties = diagnostic.Properties; // Generate the modified type declaration depending on whether the callsite was a Regex constructor call // or a Regex static method invocation. SyntaxNode replacement = generator.InvocationExpression(generator.IdentifierName(methodName)); + ImmutableArray operationArguments; if (operation is IInvocationOperation invocationOperation) // When using a Regex static method { - IEnumerable arguments = invocationOperation.Arguments + operationArguments = invocationOperation.Arguments; + IEnumerable arguments = operationArguments .Where(arg => arg.Parameter.Name is not (UpgradeToRegexGeneratorAnalyzer.OptionsArgumentName or UpgradeToRegexGeneratorAnalyzer.PatternArgumentName)) .Select(arg => arg.Syntax); replacement = generator.InvocationExpression(generator.MemberAccessExpression(replacement, invocationOperation.TargetMethod.Name), arguments); } + else + { + operationArguments = ((IObjectCreationOperation)operation).Arguments; + } newTypeDeclarationOrCompilationUnit = newTypeDeclarationOrCompilationUnit.ReplaceNode(nodeToFix, WithTrivia(replacement, nodeToFix)); // Initialize the inputs for the RegexGenerator attribute. - SyntaxNode? patternValue = GetNode(properties, UpgradeToRegexGeneratorAnalyzer.PatternKeyName, generator, useOptionsMemberExpression: false); - SyntaxNode? regexOptionsValue = GetNode(properties, UpgradeToRegexGeneratorAnalyzer.RegexOptionsKeyName, generator, useOptionsMemberExpression: true); + SyntaxNode? patternValue = GetNode(operationArguments, generator, UpgradeToRegexGeneratorAnalyzer.PatternArgumentName); + SyntaxNode? regexOptionsValue = GetNode(operationArguments, generator, UpgradeToRegexGeneratorAnalyzer.OptionsArgumentName); // Generate the new static partial method MethodDeclarationSyntax newMethod = (MethodDeclarationSyntax)generator.MethodDeclaration( @@ -218,23 +223,24 @@ static IEnumerable GetAllMembers(ITypeSymbol? symbol) } } - // Helper method that looks int the properties bag for the index of the passed in propertyname, and then returns that index from the args parameter. - static SyntaxNode? GetNode(ImmutableDictionary properties, string propertyName, SyntaxGenerator generator, bool useOptionsMemberExpression) + // Helper method that looks generates the node for pattern argument or options argument. + static SyntaxNode? GetNode(ImmutableArray arguments, SyntaxGenerator generator, string parameterName) { - string? propertyValue = properties[propertyName]; - if (propertyValue is null) + var argument = arguments.SingleOrDefault(arg => arg.Parameter.Name == parameterName); + if (argument is null) { return null; } - if (!useOptionsMemberExpression) + Debug.Assert(parameterName is UpgradeToRegexGeneratorAnalyzer.OptionsArgumentName or UpgradeToRegexGeneratorAnalyzer.PatternArgumentName); + if (parameterName == UpgradeToRegexGeneratorAnalyzer.OptionsArgumentName) { - return generator.LiteralExpression(propertyValue); + string optionsLiteral = Literal(((RegexOptions)(int)argument.Value.ConstantValue.Value).ToString()); + return SyntaxFactory.ParseExpression(optionsLiteral); } else { - string optionsLiteral = Literal(propertyValue); - return SyntaxFactory.ParseExpression(optionsLiteral); + return generator.LiteralExpression(argument.Value.ConstantValue.Value); } } From 686e4f45316a6e978039950bf6ae269574096561 Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Tue, 26 Jul 2022 21:00:38 +0200 Subject: [PATCH 3/5] Rename --- .../gen/UpgradeToRegexGeneratorAnalyzer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorAnalyzer.cs b/src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorAnalyzer.cs index 1cad7116c54cc1..d3f68bd344b868 100644 --- a/src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorAnalyzer.cs +++ b/src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorAnalyzer.cs @@ -108,7 +108,7 @@ private static void AnalyzeInvocation(OperationAnalysisContext context, INamedTy if (staticMethodsToDetect.Contains(method)) { // Validate that arguments pattern and options are constant and timeout was not passed in. - if (!TryValidateParametersAndExtractArgumentIndices(invocationOperation.Arguments)) + if (!ValidateParameters(invocationOperation.Arguments)) { return; } @@ -140,7 +140,7 @@ private static void AnalyzeObjectCreation(OperationAnalysisContext context, INam return; } - if (!TryValidateParametersAndExtractArgumentIndices(operation.Arguments)) + if (!ValidateParameters(operation.Arguments)) { return; } @@ -155,7 +155,7 @@ private static void AnalyzeObjectCreation(OperationAnalysisContext context, INam /// Validates the operation arguments ensuring they all have constant values, and if so it stores the argument /// indices for the pattern and options. If timeout argument was used, then this returns false. /// - private static bool TryValidateParametersAndExtractArgumentIndices(ImmutableArray arguments) + private static bool ValidateParameters(ImmutableArray arguments) { const string timeoutArgumentName = "timeout"; const string matchTimeoutArgumentName = "matchTimeout"; From fcf9094d86736f140d8013f01c3f088509313be0 Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Tue, 26 Jul 2022 21:00:56 +0200 Subject: [PATCH 4/5] Update UpgradeToRegexGeneratorCodeFixer.cs --- .../gen/UpgradeToRegexGeneratorCodeFixer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorCodeFixer.cs b/src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorCodeFixer.cs index 9b0a35351488d2..31473936505c42 100644 --- a/src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorCodeFixer.cs +++ b/src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorCodeFixer.cs @@ -25,7 +25,7 @@ namespace System.Text.RegularExpressions.Generator /// Roslyn code fixer that will listen to SysLIB1046 diagnostics and will provide a code fix which onboards a particular Regex into /// source generation. /// - [ExportCodeFixProvider(LanguageNames.CSharp), Shared] + [ExportCodeFixProvider(LanguageNames.CSharp)] public sealed class UpgradeToRegexGeneratorCodeFixer : CodeFixProvider { private const string RegexTypeName = "System.Text.RegularExpressions.Regex"; From 61f9b44260d968a4567e98d07f92f307a26182dc Mon Sep 17 00:00:00 2001 From: Jose Perez Rodriguez Date: Tue, 26 Jul 2022 13:42:25 -0700 Subject: [PATCH 5/5] Update src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorCodeFixer.cs --- .../gen/UpgradeToRegexGeneratorCodeFixer.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorCodeFixer.cs b/src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorCodeFixer.cs index 31473936505c42..518bf6d8c42dc3 100644 --- a/src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorCodeFixer.cs +++ b/src/libraries/System.Text.RegularExpressions/gen/UpgradeToRegexGeneratorCodeFixer.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Collections.Immutable; -using System.Composition; using System.Diagnostics; using System.Globalization; using System.Linq;