Description of the false positive
In the code below it warns that spanDirective is never read even though the value is passed to a method in which it is read:
if (directiveNode is LineSpanDirectiveTriviaSyntax spanDirective)
{
return GetLineSpanDirectiveEntry(spanDirective, directiveLineNumber);
}
The compiler transforms the code into this (you can view the IL here)
LineSpanDirectiveTriviaSyntax lineSpanDirectiveTriviaSyntax = directiveNode as LineSpanDirectiveTriviaSyntax;
if (lineSpanDirectiveTriviaSyntax != null)
{
return GetLineSpanDirectiveEntry(spanDirective, directiveLineNumber);
}
So this is a false positive unless we can prove that there exists no conversion to LineSpanDirectiveTriviaSyntax that can ever succeed.
URL to the alert on the project page on LGTM.com
https://lgtm.com/projects/g/dotnet/roslyn/snapshot/c9e0dd1ec0e440897388bbd55184fb53a555e3a4/files/src/Compilers/CSharp/Portable/Syntax/CSharpLineDirectiveMap.cs?sort=name&dir=ASC&mode=heatmap#xfcee166e229ccb35:1
Description of the false positive
In the code below it warns that
spanDirectiveis never read even though the value is passed to a method in which it is read:The compiler transforms the code into this (you can view the IL here)
So this is a false positive unless we can prove that there exists no conversion to
LineSpanDirectiveTriviaSyntaxthat can ever succeed.URL to the alert on the project page on LGTM.com
https://lgtm.com/projects/g/dotnet/roslyn/snapshot/c9e0dd1ec0e440897388bbd55184fb53a555e3a4/files/src/Compilers/CSharp/Portable/Syntax/CSharpLineDirectiveMap.cs?sort=name&dir=ASC&mode=heatmap#xfcee166e229ccb35:1