Files
codeql/csharp/ql/test/query-tests/standalone/Bad Practices/Control-Flow/ConstantCondition/ConstantCondition.cs
2026-03-31 09:38:44 +02:00

28 lines
434 B
C#

using System;
partial class C1
{
public C2 Prop { get; set; }
}
class C2 { }
class ConstantMatching
{
void M1()
{
var c1 = new C1();
if (c1.Prop is int) // Descoped, no longer reported by the query.
{
}
// Should not be considered a constant condition as
// we don't know anything about D.
var d = new D();
if (d.Prop is C2)
{
}
}
}