File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed
csharp/ql/test/query-tests/Likely Bugs/HashedButNoHash Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -7,9 +7,26 @@ public void M()
7
7
{
8
8
var h = new Hashtable ( ) ;
9
9
h . Add ( this , null ) ; // $ Alert
10
+ h . Contains ( this ) ; // $ Alert
11
+ h . ContainsKey ( this ) ; // $ Alert
12
+ h [ this ] = null ; // $ Alert
13
+ h . Remove ( this ) ; // $ Alert
14
+
15
+ var l = new List < Test > ( ) ;
16
+ l . Add ( this ) ; // Good
10
17
11
18
var d = new Dictionary < Test , bool > ( ) ;
12
19
d . Add ( this , false ) ; // $ Alert
20
+ d . ContainsKey ( this ) ; // $ Alert
21
+ d [ this ] = false ; // $ Alert
22
+ d . Remove ( this ) ; // $ Alert
23
+ d . TryAdd ( this , false ) ; // $ Alert
24
+ d . TryGetValue ( this , out bool _ ) ; // $ Alert
25
+
26
+ var hs = new HashSet < Test > ( ) ;
27
+ hs . Add ( this ) ; // $ Alert
28
+ hs . Contains ( this ) ; // $ Alert
29
+ hs . Remove ( this ) ; // $ Alert
13
30
}
14
31
15
32
public override bool Equals ( object other )
Original file line number Diff line number Diff line change
1
+ #select
1
2
| HashedButNoHash.cs:9:15:9:18 | this access | This expression is hashed, but type 'Test' only defines Equals(...) not GetHashCode(). |
2
- | HashedButNoHash.cs:12:15:12:18 | this access | This expression is hashed, but type 'Test' only defines Equals(...) not GetHashCode(). |
3
+ | HashedButNoHash.cs:11:23:11:26 | this access | This expression is hashed, but type 'Test' only defines Equals(...) not GetHashCode(). |
4
+ | HashedButNoHash.cs:19:15:19:18 | this access | This expression is hashed, but type 'Test' only defines Equals(...) not GetHashCode(). |
5
+ | HashedButNoHash.cs:20:23:20:26 | this access | This expression is hashed, but type 'Test' only defines Equals(...) not GetHashCode(). |
6
+ testFailures
7
+ | HashedButNoHash.cs:10:27:10:36 | // ... | Missing result: Alert |
8
+ | HashedButNoHash.cs:12:25:12:34 | // ... | Missing result: Alert |
9
+ | HashedButNoHash.cs:13:25:13:34 | // ... | Missing result: Alert |
10
+ | HashedButNoHash.cs:21:26:21:35 | // ... | Missing result: Alert |
11
+ | HashedButNoHash.cs:22:25:22:34 | // ... | Missing result: Alert |
12
+ | HashedButNoHash.cs:23:32:23:41 | // ... | Missing result: Alert |
13
+ | HashedButNoHash.cs:24:42:24:51 | // ... | Missing result: Alert |
14
+ | HashedButNoHash.cs:27:23:27:32 | // ... | Missing result: Alert |
15
+ | HashedButNoHash.cs:28:28:28:37 | // ... | Missing result: Alert |
16
+ | HashedButNoHash.cs:29:26:29:35 | // ... | Missing result: Alert |
You can’t perform that action at this time.
0 commit comments