Description
Describe the bug
Since update 4.6.0 Stryker gives me a null reference exception. This seems to happen because of the newly added support of filtering implicit constructors. See also
As far as i can gather it does not handle the implicit object creation correctly. For example when the implicit object creation is not inside a variable declaration.
For example DoSomething(new("test"));
will be null for creation.FirstAncestorOrSelf<VariableDeclarationSyntax>()
since there is no variable declaration. This than gives a null reference exception.
See also 52a9961#diff-81655880c375520982183e68e29cb430c74cc9f6d7efe0669d5af8ce7be81debR49
Expected behavior
Something like a null check on creation.FirstAncestorOrSelf<VariableDeclarationSyntax>()
Desktop (please complete the following information):
- OS: [e.g. Windows]
- Type of project: core
- Framework Version: .NET 8
- Stryker Version: 4.6.0
Additional context
public class Example
{
public Example(string value) { }
public static Example Create() => new("test"); // explicit, should be handled correctly
public static Example CreateImplicit() => new("test"); // implicit, but still in a return statement, should be handled correctly
public void DoSomething(Example ex) { }
public void CallWithImplicit()
{
DoSomething(new("test")); // <-- implicit object creation, not in a variable declaration, this is probably failing
}
}