Closed rouke-broersma closed 4 years ago
Any chance you can share the code that triggers this? Reading the issue you are referring to, there is a chance that the generated syntax is actually invalid, triggering an internal error in Roslyn. Assuming I read the issue properly, of course.
@dupdob The latest comment on that issue says the following:
From discussion with @gafter the compiler should be resilient to syntax that was (or could be) produced by the parser, which is the case here. There should be no exception at all.
So some valid syntax (according to the parser) is not valid syntax in the compiler is how I read it. I'm trying to narrow down which part of the code triggers it, but since the compiler has an NPE I cannot determine from the exception where the invalid syntax is. I'm investigating manually by excluding more and more files from the mutation run.
I stand corrected. I (wrongly) understood the roslyn issue as 'syntactly correct' code that could not compile. It can be the case when referencing non existing type or members for example. In case that helps, the issue is linked to conditional access, ie the ?. operator.
I'm closing to finding the source code :p
I suspected the Linq mutator because it is the only mutator changing member names
Envoyé de mon iPhone
Le 4 sept. 2019 à 09:17, Rouke Broersma notifications@github.com a écrit :
I'm closing to finding the source code :p
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
Offending source code:
public Team GetTeam(string name)
{
var team = _teamRepository.GetTeam(name);
if (team?.Features.Any(f => f.Name == _apiOptions.ManageTeamsFeatureName) == true)
{
return null;
}
else
{
return team;
}
}
Mutates to this abomination with only linq mutator turned on:
public Team GetTeam(string name)
{
var team = _teamRepository.GetTeam(name);
if (team?(StrykerjDVloRFwLAEiZZO.MutantControl.IsActive(16)?.Features.All(f => f.Name == _apiOptions.ManageTeamsFeatureName) :.Features.Any(f => f.Name == _apiOptions.ManageTeamsFeatureName) )== true)
{
return null;
}
else
{
return team;
}
}
And this with all mutators turned on:
public Team GetTeam(string name)
{
var team = _teamRepository.GetTeam(name);
if ((StrykernXatqrr71KMnocx.MutantControl.IsActive(386)?team?.Features.Any(f => f.Name == _apiOptions.ManageTeamsFeatureName) != true:team?(StrykernXatqrr71KMnocx.MutantControl.IsActive(384)?.Features.All(f => f.Name == _apiOptions.ManageTeamsFeatureName) :.Features.Any(f => (StrykernXatqrr71KMnocx.MutantControl.IsActive(383)?f.Name != _apiOptions.ManageTeamsFeatureName:f.Name == _apiOptions.ManageTeamsFeatureName)) )== (StrykernXatqrr71KMnocx.MutantControl.IsActive(385)?false:true)))
{
return null;
}
else
{
return team;
}
}
My eyes! My eyes!
An abomination indeed!! Issue is obvious, cause is clear, fix will be tricky. The problem is that the conditional operator is not set on the proper expression. It can’t happen within a chain of member invocation, as ‘.’ is not an operator in C#.
On a second though, the fix may not be that difficult; we should change the LinqMutator logic so that:
I can confirm my previous analysis: the conditional operator presence results in a significantly different syntax tree, leading to the observed results.
@dupdob will you try to submit a pull request? If so we can focus on some other issues 👍
Ok. I take this issue
PR #706 should fix this issue. Please verify with your code for confirmation.
Verified, thank you!
Fixed by #706
Describe the bug We seem to be hitting https://github.com/dotnet/roslyn/issues/25262 It looks like we are generating valid syntax that is somehow not supported by the roslyn compiler, causing it to crash in a nasty way.
Nailed down to issue in linq mutator so far.
Desktop (please complete the following information):