File tree Expand file tree Collapse file tree 4 files changed +35
-0
lines changed
csharp/ql/test/library-tests/dataflow/nullness Expand file tree Collapse file tree 4 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ using System ;
2+
3+ public class C
4+ {
5+ string Prop { get ; set ; }
6+
7+ void M ( object o , bool b )
8+ {
9+ // Conditional expr might be null.
10+ var conditionalExpr = b ? new object ( ) : null ;
11+
12+ // Null-coalescing expr might be null as the right operand is null.
13+ var nullCoalescing = o ?? null ;
14+
15+ // Cast might be null.
16+ var c = o as C ;
17+
18+ // Conditional access might be null as the qualifier might be null.
19+ var s1 = ( o as C ) ? . Prop ;
20+ }
21+ }
Original file line number Diff line number Diff line change 1+ | MaybeNullExpr.cs:10:31:10:53 | ... ? ... : ... |
2+ | MaybeNullExpr.cs:10:50:10:53 | null |
3+ | MaybeNullExpr.cs:13:30:13:38 | ... ?? ... |
4+ | MaybeNullExpr.cs:13:35:13:38 | null |
5+ | MaybeNullExpr.cs:16:17:16:22 | ... as ... |
6+ | MaybeNullExpr.cs:19:19:19:24 | ... as ... |
Original file line number Diff line number Diff line change 1+ import csharp
2+ import semmle.code.csharp.dataflow.Nullness
3+
4+ from MaybeNullExpr e
5+ where e .fromSource ( )
6+ select e
Original file line number Diff line number Diff line change 1+ semmle-extractor-options: /nostdlib /noconfig
2+ semmle-extractor-options: --load-sources-from-project:${testdir}/../../../resources/stubs/_frameworks/Microsoft.NETCore.App/Microsoft.NETCore.App.csproj
You can’t perform that action at this time.
0 commit comments