Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit ef42d61

Browse files
committed
Using GeneratedRegexAttribute to generate regex implementation at compile-time
1 parent 12c23c5 commit ef42d61

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tests/ServiceLayer.Mesh.Tests/FileTypes/NbssAppointmentEvents/Validation/RegexValidatorTests.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
namespace ServiceLayer.Mesh.Tests.FileTypes.NbssAppointmentEvents.Validation;
66

7-
public class RegexValidatorTests
7+
public partial class RegexValidatorTests
88
{
99
private const string FieldName = "TestField";
1010
private const string MissingCode = "ERR001";
1111
private const string InvalidFormatCode = "ERR002";
12-
private readonly Regex _pattern = new(@"^[A-Z]{2}\d{2}$", RegexOptions.Compiled);
12+
private readonly Regex _pattern = TestRegex();
1313

1414
[Fact]
1515
public void Validate_NullValue_ShouldReturnMissingError()
@@ -68,4 +68,7 @@ public void Validate_ValueMatchingPattern_ShouldReturnNoErrors(string validValue
6868

6969
Assert.Empty(errors);
7070
}
71+
72+
[GeneratedRegex(@"^[A-Z]{2}\d{2}$", RegexOptions.Compiled)]
73+
private static partial Regex TestRegex();
7174
}

0 commit comments

Comments
 (0)