Open iamdmitrij opened 1 month ago
I tested your PR on the following code and it broke:
public string Test()
{
return "Hello " + " " + "World";
}
So there is some issue with the mutator logic
I tested your PR on the following code and it broke:
public string Test() { return "Hello " + " " + "World"; }
So there is some issue with the mutator logic
Can you specify what exactly fails here?
I have noticed it doesn't compile when concatenation operator +
is mutated to -
.
var a1 = "Hello"u8 + " "u8 + "World"u8; // OK
var a2 = "Hello"u8 - " "u8 - "World"u8; // Doesn't compile
var a3 = "Hello" + " " + "World"; // OK
var a4 = "Hello" - " " - "World"; // Doesn't compile
If that's the case, should it be fixed somehow? Because I don't see how current or previous string mutator code has solution for that. My best guess would be to fix BinaryExpressionMutator implementation to avoid this.
I have noticed it doesn't compile when concatenation operator
+
is mutated to-
.
This isn't the problem, we prevent this mutation from being placed.
var a1 = "Hello"u8 + " "u8 + "World"u8; // OK
var a2 = ""u8 + " "u8 + "World"u8; // Doesn't compile
var a3 = "Hello" + " " + "World"; // OK
var a4 = "" + " " + "World"; // OK
The above displays the issue. The interesting part is that the code should compile, but it doesn't because of how stryker places the mutation. I haven't investigate yet what exactly goes wrong, but my guess is that there is a flaw in our mutation placing logic
I have noticed it doesn't compile when concatenation operator
+
is mutated to-
.This isn't the problem, we prevent this mutation from being placed.
var a1 = "Hello"u8 + " "u8 + "World"u8; // OK var a2 = ""u8 + " "u8 + "World"u8; // Doesn't compile var a3 = "Hello" + " " + "World"; // OK var a4 = "" + " " + "World"; // OK
The above displays the issue. The interesting part is that the code should compile, but it doesn't because of how stryker places the mutation. I haven't investigate yet what exactly goes wrong, but my guess is that there is a flaw in our mutation placing logic
Thank you. Now it's clear, I will look into this use-case.
@iamdmitrij The integration tests have been updated and now also include my previous example.
Fixes #2923.
Implemented the same logic as in plain strings:
""u8
->"Stryker was here!"u8
""something8
->""u8
SyntaxFactory.Literal(string)
method used for string mutations doesn't work with UTF8 string literal type (ReadOnlySpan<byte>
), so I've taken inspiration on how to make it work from dotnet/roslyn analyzers' code.Tasks:
StringMutator
to support UTF8 string literals