-
Notifications
You must be signed in to change notification settings - Fork 38
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 #179 from lucaslorentz/source-generators-fix
Source generators fix
- Loading branch information
Showing
6 changed files
with
52 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.Text.RegularExpressions; | ||
|
||
namespace Sample | ||
{ | ||
// This class is used to validate that Minicover can instrument assemblies containing code generated by a source generator. | ||
public static partial class ClassWithGeneratedRegex | ||
{ | ||
[GeneratedRegex($@"^[^@\s]+@[^@\s]+\.[^@\s]+$", RegexOptions.IgnoreCase)] | ||
private static partial Regex EmailRegex(); | ||
|
||
public static bool IsEmail(string text) | ||
{ | ||
return EmailRegex().IsMatch(text); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
sample/tests/Sample.UnitTests/ClassWithGeneratedRegexTest.cs
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Sample.TryFinally; | ||
using Xunit; | ||
|
||
namespace Sample.UnitTests | ||
{ | ||
public class ClassWithGeneratedRegexTest | ||
{ | ||
[Fact] | ||
public void Test() | ||
{ | ||
var isEmail = ClassWithGeneratedRegex.IsEmail("[email protected]"); | ||
Assert.True(isEmail); | ||
} | ||
} | ||
} |
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
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