C#: Only consider calling GetHashCode on byte, sbyte, short, ushort and int as useless.

This commit is contained in:
Michael Nebel
2025-03-13 13:32:22 +01:00
parent a6ec8b6a25
commit 4b02198652

View File

@@ -16,5 +16,12 @@ import semmle.code.csharp.frameworks.System
from MethodCall mc, IntegralType t
where
mc.getTarget() instanceof GetHashCodeMethod and
t = mc.getQualifier().getType()
t = mc.getQualifier().getType() and
(
t instanceof ByteType or
t instanceof SByteType or
t instanceof ShortType or
t instanceof UShortType or
t instanceof IntType
)
select mc, "Calling GetHashCode() on type " + t.toStringWithTypes() + " is redundant."