Skip to content

Commit 83d1305

Browse files
committed
SYSLIB1045 Use 'GeneratedRegexAttribute' to generate the regular expression implementation at compile-time.
Convert to 'GeneratedRegexAttribute'
1 parent 49f9b28 commit 83d1305

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Ocelot/Authorization/ClaimsAuthorizer.cs

+6-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace Ocelot.Authorization
1010
{
11-
public class ClaimsAuthorizer : IClaimsAuthorizer
11+
public partial class ClaimsAuthorizer : IClaimsAuthorizer
1212
{
1313
private readonly IClaimsParser _claimsParser;
1414

@@ -35,7 +35,7 @@ List<PlaceholderNameAndValue> urlPathPlaceholderNameAndValues
3535
if (values.Data != null)
3636
{
3737
// dynamic claim
38-
var match = Regex.Match(required.Value, @"^{(?<variable>.+)}$");
38+
var match = VariableRegex().Match(required.Value);
3939
if (match.Success)
4040
{
4141
var variableName = match.Captures[0].Value;
@@ -69,7 +69,7 @@ List<PlaceholderNameAndValue> urlPathPlaceholderNameAndValues
6969
}
7070
else
7171
{
72-
//if required value is not specified
72+
// if required value is not specified
7373
if (string.IsNullOrEmpty(required.Value))
7474
{
7575
continue;
@@ -92,5 +92,8 @@ List<PlaceholderNameAndValue> urlPathPlaceholderNameAndValues
9292

9393
return new OkResponse<bool>(true);
9494
}
95+
96+
[GeneratedRegex("^{(?<variable>.+)}$")]
97+
private static partial Regex VariableRegex();
9598
}
9699
}

0 commit comments

Comments
 (0)