Class MultiImplementationsParent

INTERNAL: Do not use.

An element that can have a child statement or expression, and where we have encountered multiple potential implementations at compile-time. For example, if we compile both A.cs

namespaces N {
  public class C {
    public int M() => 0;
  }
}

and later B.cs

namespaces N {
  public class C {
    public int M() => 1;
  }
}

then the method N.C.M has two implementations, returning 0 and 1, respectively.

The implementation used at run-time is in this case unknown (indeed, it could be a third implementation not encountered during compilation), so we make a guess for the “most likely” implementation in getBestChild().

Import path

import semmle.code.csharp.ExprOrStmtParent

Direct supertypes

Indirect supertypes

Predicates

getAnAutoImplementationFileInTopLevelType

Gets a file that contains an auto-implementation for this element, where t is the top-level type containing this element (that is, t is not a nested type).

getAnImplementationInTopLevelType

Gets a file that contains an implementation cfe for the ith child of this element, where t is the top-level type containing this element (that is, t is not a nested type).

getBestChild

Gets the i`th child of this element. Only the “best” child among all the possible run-time implementations is returned, namely the child considered most likely to be the actual run-time implementation.

getBestFile

Gets the file containing the “best” implementation of this element, that is, the file considered most likely to contain the actual run-time implementation.

Inherited predicates

fromLibrary

Holds if this element is from an assembly.

from Element
fromSource

Holds if this element is from source code.

from Element
getAChild

Gets a child of this element, if any.

from Element
getAChildExpr

Gets a child expression of this element, if any.

from ExprOrStmtParent
getAChildStmt

Gets a child statement of this element, if any.

from ExprOrStmtParent
getALocation

Gets a location of this element, including sources and assemblies.

from Element
getChild

Gets the ith child of this element (zero-based).

from ExprOrStmtParent
getChildExpr

Gets the ith child expression of this element (zero-based).

from ExprOrStmtParent
getChildStmt

Gets the ith child statement of this element (zero-based).

from ExprOrStmtParent
getFile

Gets the file containing this element.

from Element
getIndex

Gets the index of this element among its parent’s other children (zero-based).

from Element
getLanguage

Gets the “language” of this program element, as defined by the extension of the filename. For example, C# has language “cs”, and Visual Basic has language “vb”.

from Element
getLocation

Gets the location of this element. Where an element has locations in source and assemblies, choose the source location. If there are multiple assembly locations, choose only one.

from Element
getNumberOfChildren

Gets the number of children of this element.

from Element
getParent

Gets the parent of this element, if any.

from Element
toString

Gets a textual representation of this element.

from Element
toStringWithTypes

Gets the full textual representation of this element, including type information.

from Element

Charpred