Closed hannahchan closed 1 year ago
Pattern matching mutators would be awesome :)
I think there is not much else than not
, and
and or
. So the mutator would look like:
Original | Mutated |
---|---|
is |
is not |
is not |
is |
and |
or |
or |
and |
We could also remove brackets like:
bool IsLetter(char c) => c is (>= 'a' and <= 'z') or (>= 'A' and <= 'Z');
bool IsLetter(char c) => c is >= 'a' and <= 'z' or >= 'A' and <= 'Z';
Those are the interesting new operators to mutate, but I don't think we're currently mutating all existing pattern matching values since sometimes they need to be static. There might also be some fun stuff we could do with the is Type pattern matching. For example change an is Type pattern to a is var pattern.
Implemented by #2313 for switch patterns
I'm only just learning about this now so this might not make sense. I've got code like this;
The
is not
pattern combination is new to C# 9 and Stryker is currently unable to mutate it. It looks like there are other pattern operators such asand
and/oror
😄 . It would be nice to have mutators for those as well.Someone will need to take a look at the pattern matching specification of C# 9. The following might help.
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-9.0/patterns3