@@ -14,7 +14,7 @@ public D(bool b, bool f)
1414 public void Caller ( )
1515 {
1616 Callee1 ( new object ( ) ) ;
17- Callee1 ( null ) ; // $ Source[cs/dereferenced-value-may-be-null]
17+ Callee1 ( null ) ;
1818 Callee2 ( new object ( ) ) ;
1919 }
2020
@@ -23,7 +23,7 @@ public void Callee1(object param)
2323 param . ToString ( ) ; // $ Alert[cs/dereferenced-value-may-be-null]
2424 }
2525
26- public void Callee2 ( object param ) // $ Source[cs/dereferenced-value-may-be-null]
26+ public void Callee2 ( object param )
2727 {
2828 if ( param != null )
2929 {
@@ -55,24 +55,24 @@ public void NullGuards()
5555 if ( ( 2 > 1 && o4 != null ) != false )
5656 o4 . ToString ( ) ; // GOOD
5757
58- var o5 = ( o4 != null ) ? "" : null ; // $ Source[cs/dereferenced-value-may-be-null]
58+ var o5 = ( o4 != null ) ? "" : null ;
5959 if ( o5 != null )
6060 o4 . ToString ( ) ; // GOOD
6161 if ( o4 != null )
62- o5 . ToString ( ) ; // $ SPURIOUS (false positive): Alert[cs/dereferenced-value-may-be-null]
62+ o5 . ToString ( ) ; // GOOD
6363
6464 var o6 = maybe ? null : "" ;
6565 if ( ! CustomIsNull ( o6 ) )
6666 o6 . ToString ( ) ; // GOOD
6767
68- var o7 = maybe ? null : "" ; // $ Source[cs/dereferenced-value-may-be-null]
68+ var o7 = maybe ? null : "" ;
6969 var ok = o7 != null && 2 > 1 ;
7070 if ( ok )
7171 o7 . ToString ( ) ; // GOOD
7272 else
7373 o7 . ToString ( ) ; // $ Alert[cs/dereferenced-value-may-be-null]
7474
75- var o8 = maybe ? null : "" ; // $ Source[cs/dereferenced-value-may-be-null]
75+ var o8 = maybe ? null : "" ;
7676 int track = o8 == null ? 42 : 1 + 1 ;
7777 if ( track == 2 )
7878 o8 . ToString ( ) ; // GOOD
@@ -86,7 +86,7 @@ public void NullGuards()
8686
8787 public void Deref ( int i )
8888 {
89- int [ ] xs = maybe ? null : new int [ 2 ] ; // $ Source[cs/dereferenced-value-may-be-null]
89+ int [ ] xs = maybe ? null : new int [ 2 ] ;
9090 if ( i > 1 )
9191 xs [ 0 ] = 5 ; // $ Alert[cs/dereferenced-value-may-be-null]
9292
@@ -122,7 +122,7 @@ public void F(bool b)
122122 x . ToString ( ) ; // GOOD
123123 }
124124
125- public void LengthGuard ( int [ ] a , int [ ] b ) // $ Source[cs/dereferenced-value-may-be-null]
125+ public void LengthGuard ( int [ ] a , int [ ] b )
126126 {
127127 int alen = a == null ? 0 : a . Length ; // GOOD
128128 int blen = b == null ? 0 : b . Length ; // GOOD
@@ -146,7 +146,7 @@ public void LengthGuard(int[] a, int[] b) // $ Source[cs/dereferenced-value-may-
146146 }
147147 }
148148
149- public void MissedGuard ( object obj ) // $ Source[cs/dereferenced-value-may-be-null]
149+ public void MissedGuard ( object obj )
150150 {
151151 obj . ToString ( ) ; // $ Alert[cs/dereferenced-value-may-be-null]
152152 var x = obj != null ? 1 : 0 ;
@@ -160,7 +160,7 @@ private object MkMaybe()
160160
161161 public void Exceptions ( )
162162 {
163- object obj = null ; // $ Source[cs/dereferenced-value-may-be-null]
163+ object obj = null ;
164164 try
165165 {
166166 obj = MkMaybe ( ) ;
@@ -237,16 +237,16 @@ public void CorrelatedConditions(bool cond, int num)
237237 if ( flag )
238238 o . ToString ( ) ; // GOOD
239239
240- o = null ; // $ Source[cs/dereferenced-value-may-be-null]
240+ o = null ;
241241 var other = maybe ? null : "" ;
242242 if ( other == null )
243243 o = "" ;
244244 if ( other != null )
245245 o . ToString ( ) ; // $ Alert[cs/dereferenced-value-may-be-null] (always - but reported as maybe)
246246 else
247- o . ToString ( ) ; // $ SPURIOUS (false positive): Alert[cs/dereferenced-value-may-be-null]
247+ o . ToString ( ) ; // GOOD
248248
249- var o2 = ( num < 0 ) ? null : "" ; // $ Source[cs/dereferenced-value-may-be-null]
249+ var o2 = ( num < 0 ) ? null : "" ;
250250 if ( num < 0 )
251251 o2 = "" ;
252252 else
@@ -255,7 +255,7 @@ public void CorrelatedConditions(bool cond, int num)
255255
256256 public void TrackingVariable ( int [ ] a )
257257 {
258- object o = null ; // $ Source[cs/dereferenced-value-may-be-null]
258+ object o = null ;
259259 object other = null ;
260260 if ( maybe )
261261 {
@@ -264,9 +264,9 @@ public void TrackingVariable(int[] a)
264264 }
265265
266266 if ( other is string )
267- o . ToString ( ) ; // $ SPURIOUS (false positive): Alert[cs/dereferenced-value-may-be-null]
267+ o . ToString ( ) ; // GOOD
268268
269- o = null ; // $ Source[cs/dereferenced-value-may-be-null]
269+ o = null ;
270270 int count = 0 ;
271271 var found = false ;
272272 for ( var i = 0 ; i < a . Length ; i ++ )
@@ -280,7 +280,7 @@ public void TrackingVariable(int[] a)
280280 }
281281 if ( a [ i ] > 10000 )
282282 {
283- o = null ; // $ Source[cs/dereferenced-value-may-be-null]
283+ o = null ;
284284 count = 0 ;
285285 if ( 2 > i ) { }
286286 found = false ;
@@ -291,17 +291,17 @@ public void TrackingVariable(int[] a)
291291 o . ToString ( ) ; // $ SPURIOUS (false positive): Alert[cs/dereferenced-value-may-be-null]
292292
293293 if ( found )
294- o . ToString ( ) ; // $ SPURIOUS (false positive): Alert[cs/dereferenced-value-may-be-null]
294+ o . ToString ( ) ; // GOOD
295295
296- object prev = null ; // $ Source[cs/dereferenced-value-may-be-null]
296+ object prev = null ;
297297 for ( var i = 0 ; i < a . Length ; ++ i )
298298 {
299299 if ( i != 0 )
300- prev . ToString ( ) ; // $ SPURIOUS (false positive): Alert[cs/dereferenced-value-may-be-null]
300+ prev . ToString ( ) ; // GOOD
301301 prev = a [ i ] ;
302302 }
303303
304- string s = null ; // $ Source[cs/dereferenced-value-may-be-null]
304+ string s = null ;
305305 {
306306 var s_null = true ;
307307 foreach ( var i in a )
@@ -310,18 +310,18 @@ public void TrackingVariable(int[] a)
310310 s = "" + a ;
311311 }
312312 if ( ! s_null )
313- s . ToString ( ) ; // $ SPURIOUS (false positive): Alert[cs/dereferenced-value-may-be-null]
313+ s . ToString ( ) ; // GOOD
314314 }
315315
316- object r = null ; // $ Source[cs/dereferenced-value-may-be-null]
316+ object r = null ;
317317 var stat = MyStatus . INIT ;
318318 while ( stat == MyStatus . INIT && stat != MyStatus . READY )
319319 {
320320 r = MkMaybe ( ) ;
321321 if ( stat == MyStatus . INIT )
322322 stat = MyStatus . READY ;
323323 }
324- r . ToString ( ) ; // $ SPURIOUS (false positive): Alert[cs/dereferenced-value-may-be-null]
324+ r . ToString ( ) ; // GOOD
325325 }
326326
327327 public enum MyStatus
@@ -348,7 +348,7 @@ public void G(object obj)
348348
349349 public void LoopCorr ( int iters )
350350 {
351- int [ ] a = null ; // $ Source[cs/dereferenced-value-may-be-null]
351+ int [ ] a = null ;
352352 if ( iters > 0 )
353353 a = new int [ iters ] ;
354354
@@ -357,13 +357,13 @@ public void LoopCorr(int iters)
357357
358358 if ( iters > 0 )
359359 {
360- string last = null ; // $ Source[cs/dereferenced-value-may-be-null]
360+ string last = null ;
361361 for ( var i = 0 ; i < iters ; i ++ )
362362 last = "abc" ;
363363 last . ToString ( ) ; // $ SPURIOUS (false positive): Alert[cs/dereferenced-value-may-be-null]
364364 }
365365
366- int [ ] b = maybe ? null : new int [ iters ] ; // $ Source[cs/dereferenced-value-may-be-null]
366+ int [ ] b = maybe ? null : new int [ iters ] ;
367367 if ( iters > 0 && ( b == null || b . Length < iters ) )
368368 throw new Exception ( ) ;
369369
@@ -385,7 +385,7 @@ void Test(Exception e, bool b)
385385 ioe . ToString ( ) ; // $ Alert[cs/dereferenced-value-is-always-null]
386386 }
387387
388- public void LengthGuard2 ( int [ ] a , int [ ] b ) // $ Source[cs/dereferenced-value-may-be-null]
388+ public void LengthGuard2 ( int [ ] a , int [ ] b )
389389 {
390390 int alen = a == null ? 0 : a . Length ; // GOOD
391391 int sum = 0 ;
@@ -402,13 +402,13 @@ public void LengthGuard2(int[] a, int[] b) // $ Source[cs/dereferenced-value-may
402402 i = - 3 ;
403403 }
404404
405- public void CorrConds2 ( object x , object y ) // $ Source[cs/dereferenced-value-may-be-null]
405+ public void CorrConds2 ( object x , object y )
406406 {
407407 if ( ( x != null && y == null ) || ( x == null && y != null ) )
408408 return ;
409409 if ( x != null )
410- y . ToString ( ) ; // $ SPURIOUS (false positive): Alert[cs/dereferenced-value-may-be-null]
410+ y . ToString ( ) ; // GOOD
411411 if ( y != null )
412- x . ToString ( ) ; // $ SPURIOUS (false positive): Alert[cs/dereferenced-value-may-be-null]
412+ x . ToString ( ) ; // GOOD
413413 }
414414}
0 commit comments