CodeQL queries 1.25
Skip to end of metadata
Go to start of metadata

Finds places where we add 'null' to a collection.

import csharp

from MethodCall call, Method add
where
  call.getTarget() = add.getAnUltimateImplementor*() and
  add.hasName("Add") and
  add
      .getDeclaringType()
      .getSourceDeclaration()
      .hasQualifiedName("System.Collections.Generic.ICollection<>") and
  call.getAnArgument() instanceof NullLiteral
select call