From b888253929ba9c4dafc9a22bcc62c7b0e98b6c36 Mon Sep 17 00:00:00 2001 From: Shreyas Jejurkar Date: Tue, 8 Mar 2022 06:26:25 +0000 Subject: [PATCH 1/5] feat : Add `StringSyntax` for regex parameters --- .../Routing/src/Constraints/RegexInlineRouteConstraint.cs | 4 +++- src/Http/Routing/src/Constraints/RegexRouteConstraint.cs | 3 ++- src/Middleware/Rewrite/src/ApacheModRewrite/RuleBuilder.cs | 3 ++- .../Rewrite/src/ApacheModRewrite/RuleRegexParser.cs | 4 +++- .../Rewrite/src/IISUrlRewrite/UriMatchCondition.cs | 5 +++-- src/Middleware/Rewrite/src/RedirectRule.cs | 3 ++- src/Middleware/Rewrite/src/RewriteOptionsExtensions.cs | 7 ++++--- src/Middleware/Rewrite/src/RewriteRule.cs | 3 ++- src/Middleware/Rewrite/src/UrlMatches/RegexMatch.cs | 3 ++- .../shared/Mvc.Core.TestCommon/ValidationAttributeUtil.cs | 2 +- 10 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/Http/Routing/src/Constraints/RegexInlineRouteConstraint.cs b/src/Http/Routing/src/Constraints/RegexInlineRouteConstraint.cs index 465e0a9f9c5d..ef4d5c8d039d 100644 --- a/src/Http/Routing/src/Constraints/RegexInlineRouteConstraint.cs +++ b/src/Http/Routing/src/Constraints/RegexInlineRouteConstraint.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Diagnostics.CodeAnalysis; + namespace Microsoft.AspNetCore.Routing.Constraints; /// @@ -12,7 +14,7 @@ public class RegexInlineRouteConstraint : RegexRouteConstraint /// Initializes a new instance of the class. /// /// The regular expression pattern to match. - public RegexInlineRouteConstraint(string regexPattern) + public RegexInlineRouteConstraint([StringSyntax(StringSyntaxAttribute.Regex)] string regexPattern) : base(regexPattern) { } diff --git a/src/Http/Routing/src/Constraints/RegexRouteConstraint.cs b/src/Http/Routing/src/Constraints/RegexRouteConstraint.cs index 27b0a08a9de9..f9228fb9d90e 100644 --- a/src/Http/Routing/src/Constraints/RegexRouteConstraint.cs +++ b/src/Http/Routing/src/Constraints/RegexRouteConstraint.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.RegularExpressions; using Microsoft.AspNetCore.Http; @@ -33,7 +34,7 @@ public RegexRouteConstraint(Regex regex) /// Constructor for a given a . /// /// A string containing the regex pattern. - public RegexRouteConstraint(string regexPattern) + public RegexRouteConstraint([StringSyntax(StringSyntaxAttribute.Regex)] string regexPattern) { if (regexPattern == null) { diff --git a/src/Middleware/Rewrite/src/ApacheModRewrite/RuleBuilder.cs b/src/Middleware/Rewrite/src/ApacheModRewrite/RuleBuilder.cs index ffbe6d24095d..36a5d1e9d8ca 100644 --- a/src/Middleware/Rewrite/src/ApacheModRewrite/RuleBuilder.cs +++ b/src/Middleware/Rewrite/src/ApacheModRewrite/RuleBuilder.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.RegularExpressions; using Microsoft.AspNetCore.Http; @@ -156,7 +157,7 @@ public void AddConditionFromParts( } public void AddMatch( - ParsedModRewriteInput input, + [StringSyntax(StringSyntaxAttribute.Regex)] ParsedModRewriteInput input, Flags flags) { Debug.Assert(input.Operand != null); diff --git a/src/Middleware/Rewrite/src/ApacheModRewrite/RuleRegexParser.cs b/src/Middleware/Rewrite/src/ApacheModRewrite/RuleRegexParser.cs index 7c3d15305a44..a7c6d34fcef3 100644 --- a/src/Middleware/Rewrite/src/ApacheModRewrite/RuleRegexParser.cs +++ b/src/Middleware/Rewrite/src/ApacheModRewrite/RuleRegexParser.cs @@ -1,11 +1,13 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Diagnostics.CodeAnalysis; + namespace Microsoft.AspNetCore.Rewrite.ApacheModRewrite; internal class RuleRegexParser { - public static ParsedModRewriteInput ParseRuleRegex(string regex) + public static ParsedModRewriteInput ParseRuleRegex([StringSyntax(StringSyntaxAttribute.Regex)] string regex) { if (string.IsNullOrEmpty(regex)) { diff --git a/src/Middleware/Rewrite/src/IISUrlRewrite/UriMatchCondition.cs b/src/Middleware/Rewrite/src/IISUrlRewrite/UriMatchCondition.cs index ce6f8f52d325..0c88334cf4b4 100644 --- a/src/Middleware/Rewrite/src/IISUrlRewrite/UriMatchCondition.cs +++ b/src/Middleware/Rewrite/src/IISUrlRewrite/UriMatchCondition.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Diagnostics.CodeAnalysis; using System.Text.RegularExpressions; using Microsoft.AspNetCore.Rewrite.UrlMatches; @@ -10,7 +11,7 @@ internal class UriMatchCondition : Condition { private static readonly TimeSpan _regexTimeout = TimeSpan.FromSeconds(1); - public UriMatchCondition(InputParser inputParser, string input, string pattern, UriMatchPart uriMatchPart, bool ignoreCase, bool negate) + public UriMatchCondition(InputParser inputParser, string input, [StringSyntax(StringSyntaxAttribute.Regex)] string pattern, UriMatchPart uriMatchPart, bool ignoreCase, bool negate) : base(CreatePattern(inputParser, input, uriMatchPart), CreateRegexMatch(pattern, ignoreCase, negate)) { } @@ -20,7 +21,7 @@ private static Pattern CreatePattern(InputParser inputParser, string input, UriM return inputParser.ParseInputString(input, uriMatchPart); } - private static RegexMatch CreateRegexMatch(string pattern, bool ignoreCase, bool negate) + private static RegexMatch CreateRegexMatch([StringSyntax(StringSyntaxAttribute.Regex)] string pattern, bool ignoreCase, bool negate) { var regexOptions = RegexOptions.CultureInvariant | RegexOptions.Compiled; regexOptions = ignoreCase ? regexOptions | RegexOptions.IgnoreCase : regexOptions; diff --git a/src/Middleware/Rewrite/src/RedirectRule.cs b/src/Middleware/Rewrite/src/RedirectRule.cs index 52746859b921..246eae8eccae 100644 --- a/src/Middleware/Rewrite/src/RedirectRule.cs +++ b/src/Middleware/Rewrite/src/RedirectRule.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Diagnostics.CodeAnalysis; using System.Text.RegularExpressions; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Extensions; @@ -14,7 +15,7 @@ internal class RedirectRule : IRule public Regex InitialMatch { get; } public string Replacement { get; } public int StatusCode { get; } - public RedirectRule(string regex, string replacement, int statusCode) + public RedirectRule([StringSyntax(StringSyntaxAttribute.Regex)] string regex, string replacement, int statusCode) { if (string.IsNullOrEmpty(regex)) { diff --git a/src/Middleware/Rewrite/src/RewriteOptionsExtensions.cs b/src/Middleware/Rewrite/src/RewriteOptionsExtensions.cs index 37baa577c20e..7a0841b1dd32 100644 --- a/src/Middleware/Rewrite/src/RewriteOptionsExtensions.cs +++ b/src/Middleware/Rewrite/src/RewriteOptionsExtensions.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Diagnostics.CodeAnalysis; using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Rewrite; @@ -42,7 +43,7 @@ public static RewriteOptions Add(this RewriteOptions options, ActionIf the regex matches, what to replace the uri with. /// If the regex matches, conditionally stop processing other rules. /// The Rewrite options. - public static RewriteOptions AddRewrite(this RewriteOptions options, string regex, string replacement, bool skipRemainingRules) + public static RewriteOptions AddRewrite(this RewriteOptions options, [StringSyntax(StringSyntaxAttribute.Regex)] string regex, string replacement, bool skipRemainingRules) { options.Rules.Add(new RewriteRule(regex, replacement, skipRemainingRules)); return options; @@ -55,7 +56,7 @@ public static RewriteOptions AddRewrite(this RewriteOptions options, string rege /// The regex string to compare with. /// If the regex matches, what to replace the uri with. /// The Rewrite options. - public static RewriteOptions AddRedirect(this RewriteOptions options, string regex, string replacement) + public static RewriteOptions AddRedirect(this RewriteOptions options, [StringSyntax(StringSyntaxAttribute.Regex)] string regex, string replacement) { return AddRedirect(options, regex, replacement, statusCode: StatusCodes.Status302Found); } @@ -68,7 +69,7 @@ public static RewriteOptions AddRedirect(this RewriteOptions options, string reg /// If the regex matches, what to replace the uri with. /// The status code to add to the response. /// The Rewrite options. - public static RewriteOptions AddRedirect(this RewriteOptions options, string regex, string replacement, int statusCode) + public static RewriteOptions AddRedirect(this RewriteOptions options, [StringSyntax(StringSyntaxAttribute.Regex)] string regex, string replacement, int statusCode) { options.Rules.Add(new RedirectRule(regex, replacement, statusCode)); return options; diff --git a/src/Middleware/Rewrite/src/RewriteRule.cs b/src/Middleware/Rewrite/src/RewriteRule.cs index c99db5cd3b41..278609de7408 100644 --- a/src/Middleware/Rewrite/src/RewriteRule.cs +++ b/src/Middleware/Rewrite/src/RewriteRule.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Diagnostics.CodeAnalysis; using System.Text.RegularExpressions; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Extensions; @@ -14,7 +15,7 @@ internal class RewriteRule : IRule public Regex InitialMatch { get; } public string Replacement { get; } public bool StopProcessing { get; } - public RewriteRule(string regex, string replacement, bool stopProcessing) + public RewriteRule([StringSyntax(StringSyntaxAttribute.Regex)] string regex, string replacement, bool stopProcessing) { if (string.IsNullOrEmpty(regex)) { diff --git a/src/Middleware/Rewrite/src/UrlMatches/RegexMatch.cs b/src/Middleware/Rewrite/src/UrlMatches/RegexMatch.cs index 3daf2fae015a..c955e3ca29c2 100644 --- a/src/Middleware/Rewrite/src/UrlMatches/RegexMatch.cs +++ b/src/Middleware/Rewrite/src/UrlMatches/RegexMatch.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Diagnostics.CodeAnalysis; using System.Text.RegularExpressions; namespace Microsoft.AspNetCore.Rewrite.UrlMatches; @@ -15,7 +16,7 @@ public RegexMatch(Regex match, bool negate) Negate = negate; } - public override MatchResults Evaluate(string pattern, RewriteContext context) + public override MatchResults Evaluate([StringSyntax(StringSyntaxAttribute.Regex)] string pattern, RewriteContext context) { var res = _match.Match(pattern); return new MatchResults(success: res.Success != Negate, new BackReferenceCollection(res.Groups)); diff --git a/src/Mvc/shared/Mvc.Core.TestCommon/ValidationAttributeUtil.cs b/src/Mvc/shared/Mvc.Core.TestCommon/ValidationAttributeUtil.cs index 6a290a3e369c..4aa28fcfebea 100644 --- a/src/Mvc/shared/Mvc.Core.TestCommon/ValidationAttributeUtil.cs +++ b/src/Mvc/shared/Mvc.Core.TestCommon/ValidationAttributeUtil.cs @@ -24,7 +24,7 @@ public static string GetStringLengthErrorMessage(int? minimumLength, int maximum return attr.FormatErrorMessage(field); } - public static string GetRegExErrorMessage(string pattern, string field) + public static string GetRegExErrorMessage([StringSyntax(StringSyntaxAttribute.Regex)] string pattern, string field) { var attr = new RegularExpressionAttribute(pattern); return attr.FormatErrorMessage(field); From 742d6def6078972cac392ec7cfdf803952cf0ec0 Mon Sep 17 00:00:00 2001 From: Shreyas Jejurkar Date: Tue, 8 Mar 2022 10:12:27 +0000 Subject: [PATCH 2/5] add missing using statement. --- src/Mvc/shared/Mvc.Core.TestCommon/ValidationAttributeUtil.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Mvc/shared/Mvc.Core.TestCommon/ValidationAttributeUtil.cs b/src/Mvc/shared/Mvc.Core.TestCommon/ValidationAttributeUtil.cs index 4aa28fcfebea..0be462e83b02 100644 --- a/src/Mvc/shared/Mvc.Core.TestCommon/ValidationAttributeUtil.cs +++ b/src/Mvc/shared/Mvc.Core.TestCommon/ValidationAttributeUtil.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.ComponentModel.DataAnnotations; +using System.Diagnostics.CodeAnalysis; namespace Microsoft.AspNetCore.Mvc.ModelBinding; From 03a4e9bc2ca90360d0bc44e9718fd9a9b5935100 Mon Sep 17 00:00:00 2001 From: Shreyas Jejurkar Date: Tue, 8 Mar 2022 14:06:35 +0000 Subject: [PATCH 3/5] addressed PR feedback --- .../Routing/src/Constraints/RegexInlineRouteConstraint.cs | 3 ++- src/Http/Routing/src/Constraints/RegexRouteConstraint.cs | 2 +- src/Middleware/Rewrite/src/ApacheModRewrite/RuleBuilder.cs | 2 +- .../Rewrite/src/ApacheModRewrite/RuleRegexParser.cs | 4 +--- .../Rewrite/src/IISUrlRewrite/UriMatchCondition.cs | 5 ++--- src/Middleware/Rewrite/src/RedirectRule.cs | 3 +-- src/Middleware/Rewrite/src/RewriteRule.cs | 3 +-- src/Middleware/Rewrite/src/UrlMatches/RegexMatch.cs | 3 +-- 8 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/Http/Routing/src/Constraints/RegexInlineRouteConstraint.cs b/src/Http/Routing/src/Constraints/RegexInlineRouteConstraint.cs index ef4d5c8d039d..50963a0df25f 100644 --- a/src/Http/Routing/src/Constraints/RegexInlineRouteConstraint.cs +++ b/src/Http/Routing/src/Constraints/RegexInlineRouteConstraint.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics.CodeAnalysis; +using System.Text.RegularExpressions; namespace Microsoft.AspNetCore.Routing.Constraints; @@ -14,7 +15,7 @@ public class RegexInlineRouteConstraint : RegexRouteConstraint /// Initializes a new instance of the class. /// /// The regular expression pattern to match. - public RegexInlineRouteConstraint([StringSyntax(StringSyntaxAttribute.Regex)] string regexPattern) + public RegexInlineRouteConstraint([StringSyntax(StringSyntaxAttribute.Regex, RegexOptions.CultureInvariant | RegexOptions.IgnoreCase)] string regexPattern) : base(regexPattern) { } diff --git a/src/Http/Routing/src/Constraints/RegexRouteConstraint.cs b/src/Http/Routing/src/Constraints/RegexRouteConstraint.cs index f9228fb9d90e..fb693cdde727 100644 --- a/src/Http/Routing/src/Constraints/RegexRouteConstraint.cs +++ b/src/Http/Routing/src/Constraints/RegexRouteConstraint.cs @@ -34,7 +34,7 @@ public RegexRouteConstraint(Regex regex) /// Constructor for a given a . /// /// A string containing the regex pattern. - public RegexRouteConstraint([StringSyntax(StringSyntaxAttribute.Regex)] string regexPattern) + public RegexRouteConstraint([StringSyntax(StringSyntaxAttribute.Regex, RegexOptions.CultureInvariant | RegexOptions.IgnoreCase)] string regexPattern) { if (regexPattern == null) { diff --git a/src/Middleware/Rewrite/src/ApacheModRewrite/RuleBuilder.cs b/src/Middleware/Rewrite/src/ApacheModRewrite/RuleBuilder.cs index 36a5d1e9d8ca..db8ecf3f6b52 100644 --- a/src/Middleware/Rewrite/src/ApacheModRewrite/RuleBuilder.cs +++ b/src/Middleware/Rewrite/src/ApacheModRewrite/RuleBuilder.cs @@ -157,7 +157,7 @@ public void AddConditionFromParts( } public void AddMatch( - [StringSyntax(StringSyntaxAttribute.Regex)] ParsedModRewriteInput input, + ParsedModRewriteInput input, Flags flags) { Debug.Assert(input.Operand != null); diff --git a/src/Middleware/Rewrite/src/ApacheModRewrite/RuleRegexParser.cs b/src/Middleware/Rewrite/src/ApacheModRewrite/RuleRegexParser.cs index a7c6d34fcef3..7c3d15305a44 100644 --- a/src/Middleware/Rewrite/src/ApacheModRewrite/RuleRegexParser.cs +++ b/src/Middleware/Rewrite/src/ApacheModRewrite/RuleRegexParser.cs @@ -1,13 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Diagnostics.CodeAnalysis; - namespace Microsoft.AspNetCore.Rewrite.ApacheModRewrite; internal class RuleRegexParser { - public static ParsedModRewriteInput ParseRuleRegex([StringSyntax(StringSyntaxAttribute.Regex)] string regex) + public static ParsedModRewriteInput ParseRuleRegex(string regex) { if (string.IsNullOrEmpty(regex)) { diff --git a/src/Middleware/Rewrite/src/IISUrlRewrite/UriMatchCondition.cs b/src/Middleware/Rewrite/src/IISUrlRewrite/UriMatchCondition.cs index 0c88334cf4b4..ce6f8f52d325 100644 --- a/src/Middleware/Rewrite/src/IISUrlRewrite/UriMatchCondition.cs +++ b/src/Middleware/Rewrite/src/IISUrlRewrite/UriMatchCondition.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Diagnostics.CodeAnalysis; using System.Text.RegularExpressions; using Microsoft.AspNetCore.Rewrite.UrlMatches; @@ -11,7 +10,7 @@ internal class UriMatchCondition : Condition { private static readonly TimeSpan _regexTimeout = TimeSpan.FromSeconds(1); - public UriMatchCondition(InputParser inputParser, string input, [StringSyntax(StringSyntaxAttribute.Regex)] string pattern, UriMatchPart uriMatchPart, bool ignoreCase, bool negate) + public UriMatchCondition(InputParser inputParser, string input, string pattern, UriMatchPart uriMatchPart, bool ignoreCase, bool negate) : base(CreatePattern(inputParser, input, uriMatchPart), CreateRegexMatch(pattern, ignoreCase, negate)) { } @@ -21,7 +20,7 @@ private static Pattern CreatePattern(InputParser inputParser, string input, UriM return inputParser.ParseInputString(input, uriMatchPart); } - private static RegexMatch CreateRegexMatch([StringSyntax(StringSyntaxAttribute.Regex)] string pattern, bool ignoreCase, bool negate) + private static RegexMatch CreateRegexMatch(string pattern, bool ignoreCase, bool negate) { var regexOptions = RegexOptions.CultureInvariant | RegexOptions.Compiled; regexOptions = ignoreCase ? regexOptions | RegexOptions.IgnoreCase : regexOptions; diff --git a/src/Middleware/Rewrite/src/RedirectRule.cs b/src/Middleware/Rewrite/src/RedirectRule.cs index 246eae8eccae..52746859b921 100644 --- a/src/Middleware/Rewrite/src/RedirectRule.cs +++ b/src/Middleware/Rewrite/src/RedirectRule.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Diagnostics.CodeAnalysis; using System.Text.RegularExpressions; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Extensions; @@ -15,7 +14,7 @@ internal class RedirectRule : IRule public Regex InitialMatch { get; } public string Replacement { get; } public int StatusCode { get; } - public RedirectRule([StringSyntax(StringSyntaxAttribute.Regex)] string regex, string replacement, int statusCode) + public RedirectRule(string regex, string replacement, int statusCode) { if (string.IsNullOrEmpty(regex)) { diff --git a/src/Middleware/Rewrite/src/RewriteRule.cs b/src/Middleware/Rewrite/src/RewriteRule.cs index 278609de7408..c99db5cd3b41 100644 --- a/src/Middleware/Rewrite/src/RewriteRule.cs +++ b/src/Middleware/Rewrite/src/RewriteRule.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Diagnostics.CodeAnalysis; using System.Text.RegularExpressions; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Extensions; @@ -15,7 +14,7 @@ internal class RewriteRule : IRule public Regex InitialMatch { get; } public string Replacement { get; } public bool StopProcessing { get; } - public RewriteRule([StringSyntax(StringSyntaxAttribute.Regex)] string regex, string replacement, bool stopProcessing) + public RewriteRule(string regex, string replacement, bool stopProcessing) { if (string.IsNullOrEmpty(regex)) { diff --git a/src/Middleware/Rewrite/src/UrlMatches/RegexMatch.cs b/src/Middleware/Rewrite/src/UrlMatches/RegexMatch.cs index c955e3ca29c2..3daf2fae015a 100644 --- a/src/Middleware/Rewrite/src/UrlMatches/RegexMatch.cs +++ b/src/Middleware/Rewrite/src/UrlMatches/RegexMatch.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Diagnostics.CodeAnalysis; using System.Text.RegularExpressions; namespace Microsoft.AspNetCore.Rewrite.UrlMatches; @@ -16,7 +15,7 @@ public RegexMatch(Regex match, bool negate) Negate = negate; } - public override MatchResults Evaluate([StringSyntax(StringSyntaxAttribute.Regex)] string pattern, RewriteContext context) + public override MatchResults Evaluate(string pattern, RewriteContext context) { var res = _match.Match(pattern); return new MatchResults(success: res.Success != Negate, new BackReferenceCollection(res.Groups)); From e31dcf49f09aebd3b88ec8826586dfa33bfe3f9f Mon Sep 17 00:00:00 2001 From: Shreyas Jejurkar Date: Tue, 8 Mar 2022 20:07:28 +0530 Subject: [PATCH 4/5] Update RuleBuilder.cs --- src/Middleware/Rewrite/src/ApacheModRewrite/RuleBuilder.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Middleware/Rewrite/src/ApacheModRewrite/RuleBuilder.cs b/src/Middleware/Rewrite/src/ApacheModRewrite/RuleBuilder.cs index db8ecf3f6b52..ffbe6d24095d 100644 --- a/src/Middleware/Rewrite/src/ApacheModRewrite/RuleBuilder.cs +++ b/src/Middleware/Rewrite/src/ApacheModRewrite/RuleBuilder.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.RegularExpressions; using Microsoft.AspNetCore.Http; From 35ff54eb23495728ba7b7e1fbb311533cf098228 Mon Sep 17 00:00:00 2001 From: Shreyas Jejurkar Date: Fri, 11 Mar 2022 05:40:59 +0000 Subject: [PATCH 5/5] removed usage from test utils --- src/Mvc/shared/Mvc.Core.TestCommon/ValidationAttributeUtil.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Mvc/shared/Mvc.Core.TestCommon/ValidationAttributeUtil.cs b/src/Mvc/shared/Mvc.Core.TestCommon/ValidationAttributeUtil.cs index 0be462e83b02..6a290a3e369c 100644 --- a/src/Mvc/shared/Mvc.Core.TestCommon/ValidationAttributeUtil.cs +++ b/src/Mvc/shared/Mvc.Core.TestCommon/ValidationAttributeUtil.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.ComponentModel.DataAnnotations; -using System.Diagnostics.CodeAnalysis; namespace Microsoft.AspNetCore.Mvc.ModelBinding; @@ -25,7 +24,7 @@ public static string GetStringLengthErrorMessage(int? minimumLength, int maximum return attr.FormatErrorMessage(field); } - public static string GetRegExErrorMessage([StringSyntax(StringSyntaxAttribute.Regex)] string pattern, string field) + public static string GetRegExErrorMessage(string pattern, string field) { var attr = new RegularExpressionAttribute(pattern); return attr.FormatErrorMessage(field);