Skip to content

Commit 4b02198

Browse files
committed
C#: Only consider calling GetHashCode on byte, sbyte, short, ushort and int as useless.
1 parent a6ec8b6 commit 4b02198

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

csharp/ql/src/Useless code/IntGetHashCode.ql

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,12 @@ import semmle.code.csharp.frameworks.System
1616
from MethodCall mc, IntegralType t
1717
where
1818
mc.getTarget() instanceof GetHashCodeMethod and
19-
t = mc.getQualifier().getType()
19+
t = mc.getQualifier().getType() and
20+
(
21+
t instanceof ByteType or
22+
t instanceof SByteType or
23+
t instanceof ShortType or
24+
t instanceof UShortType or
25+
t instanceof IntType
26+
)
2027
select mc, "Calling GetHashCode() on type " + t.toStringWithTypes() + " is redundant."

0 commit comments

Comments
 (0)