Module Generics

Provides support for generic types and methods.

The classes UnboundGeneric* represent the unbound form of the generic, whereas ConstructedGeneric* represent the constructed generic where type arguments have been supplied and are bound to the type parameters.

There is a one-to-many relationship between an unbound generic (UnboundGenric*) and its constructed generics (ConstructedGeneric*).

Generics can be partially constructed if they are unbound generics contained within constructed generic types. The predicate getSourceDeclaration refers to the ultimate UnboundGeneric type/method as defined in the source code.

Import path

semmle.code.csharp.Generics

Imports

Location

Provides the Location class to give a location for each program element.

Namespace

Provides classes for namespaces.

Classes

ConstructedClass

A constructed (bound) class. (See the comments on ConstructedType for more information.)

ConstructedDelegateType

A constructed (bound) delegate type. (See the comments on ConstructedType for more information.)

ConstructedGeneric

A declaration constructed from an UnboundGeneric by supplying type arguments.

ConstructedInterface

A C# constructed (bound) interface. (See the comments on ConstructedType for more information.)

ConstructedLocalFunction

A constructed generic local function, for example the target f<int> of the function call f(5) on line 4 in

ConstructedMethod

A constructed (bound) method, for example the target M<int> of the call on line 5 in

ConstructedStruct

A constructed (bound) struct. (See the comments on ConstructedType for more information.)

ConstructedType

A constructed (bound) type. This is a generic type for which actual type arguments have been supplied, for example G<int> or the G<T> in class Other<T> { G<T> g; }. Constructed types can be divided further into those that are open (for example G1<T> or G2<T,T,U,int>), in the sense that one or more of their type arguments is a type parameter, versus those that are closed (for example G1<int> or G2<long,long,float,int>). We do not currently distinguish the two in this library.

Generic

A generic declaration. Either an unbound generic (UnboundGeneric) or a constructed generic (ConstructedGeneric).

NonConstructedMethod

A method that is not constructed. That is, either a method that is not a generic method or an unbound generic method (UnboundGenericMethod).

TypeParameter

A type parameter, for example T in List<T>.

TypeParameterConstraints

A set of type parameter constraints.

UnboundGeneric

A generic declaration that can have type parameters.

UnboundGenericClass

An unbound generic class, for example

UnboundGenericDelegateType

An unbound generic delegate type. (See the comments on UnboundGenericType for more information.)

UnboundGenericInterface

An unbound generic interface, for example

UnboundGenericMethod

An unbound generic method. This is a generic method whose signature involves formal type parameters, For example M<T> on line 2 in

UnboundGenericStruct

An unbound generic struct. (See the comments on UnboundGenericType for more information.)

UnboundGenericType

An unbound generic type. This is a generic type with type parameters (for example List<T>) or elided type parameters (for example List<>).

UnboundLocalFunction

An unbound generic local function, for example f on line 3 in