forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHashedButNoHash.cs
More file actions
36 lines (31 loc) · 915 Bytes
/
HashedButNoHash.cs
File metadata and controls
36 lines (31 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System.Collections;
using System.Collections.Generic;
public class Test
{
public void M()
{
var h = new Hashtable();
h.Add(this, null); // $ Alert
h.Contains(this); // $ Alert
h.ContainsKey(this); // $ Alert
h[this] = null; // $ Alert
h.Remove(this); // $ Alert
var l = new List<Test>();
l.Add(this); // Good
var d = new Dictionary<Test, bool>();
d.Add(this, false); // $ Alert
d.ContainsKey(this); // $ Alert
d[this] = false; // $ Alert
d.Remove(this); // $ Alert
d.TryAdd(this, false); // $ Alert
d.TryGetValue(this, out bool _); // $ Alert
var hs = new HashSet<Test>();
hs.Add(this); // $ Alert
hs.Contains(this); // $ Alert
hs.Remove(this); // $ Alert
}
public override bool Equals(object other)
{
return false;
}
}