-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44770 from eerhardt/AlphaRegexSG-main
Use the Regex source generator in the AlphaRouteConstraint.
- Loading branch information
Showing
3 changed files
with
13 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Text.RegularExpressions; | ||
|
||
namespace Microsoft.AspNetCore.Routing.Constraints; | ||
|
||
/// <summary> | ||
/// Constrains a route parameter to contain only lowercase or uppercase letters A through Z in the English alphabet. | ||
/// </summary> | ||
public class AlphaRouteConstraint : RegexRouteConstraint | ||
public partial class AlphaRouteConstraint : RegexRouteConstraint | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="AlphaRouteConstraint" /> class. | ||
/// </summary> | ||
public AlphaRouteConstraint() : base(@"^[a-z]*$") | ||
public AlphaRouteConstraint() : base(GetAlphaRouteRegex()) | ||
{ | ||
} | ||
|
||
[GeneratedRegex(@"^[A-Za-z]*$")] | ||
private static partial Regex GetAlphaRouteRegex(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters