False positive in csharp for useless-assignment-to-local
@hvitved ya está trabajando en esto.
Desde el 23/6/2026.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
Description of the false positive
The context is the following: the variable is used inside a lambda and captured by it.
It is not clear to me what the exact cause is. I tried to create a self-contained code sample, but I was not able to trigger the false positive that way, so the sample code relies on AspNetCore, which is the context where I got the warning.
Code samples or links to source code
To reproduce, you need a project that depends on AspNetCore, which is possible with a project file like the following: Sample.csproj:
<Project Sdk="Microsoft.NET.Sdk.Web">
</Project>
The following is helper code to configure a AspNetCore WebApplication:
public static class App
{
extension(WebApplication app)
{
public void Configure()
{
string redirectPath = "/app";
app.MapGet("/", () => Results.Redirect(redirectPath));
}
}
}
CodeQL complains about the redirectPath not being used. The type of the lambda passed to MapGet is Delegate. An example with self-contained code with a similar setup and the use of a Delegate type did not trigger the false positive.
- Lenguaje dominante
- CodeQL
- Estrellas
- 10.1k
- Forks
- 2.1k
- Merge medio
- 2 d 11 h
- PR fusionados (30 d)
- 129
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de github/codeql
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
-
C#: cs/simplifiable-boolean-expression false positive on Nullable<bool> compared with a literal Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
false-positive
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
False positive Abiertofalse-positive
Dificultad 4/5 3-5 días Aptitud para principiantes 15/100