SemanticModel.LookupBaseMembers(Int32, String) Method

Definition

Gets the available base type members in the context of the specified location. Akin to calling LookupSymbols(Int32, INamespaceOrTypeSymbol, String, Boolean) with the container set to the immediate base type of the type in which position occurs. However, the accessibility rules are different: protected members of the base type will be visible.

Consider the following example:

public class Base { protected void M() { } }

public class Derived : Base { void Test(Base b) { b.M(); // Error - cannot access protected member. base.M(); } }

Protected members of an instance of another type are only accessible if the instance is known to be "this" instance (as indicated by the "base" keyword).

public System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.ISymbol> LookupBaseMembers (int position, string name = default);
public System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.ISymbol> LookupBaseMembers (int position, string? name = default);
member this.LookupBaseMembers : int * string -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.ISymbol>
Public Function LookupBaseMembers (position As Integer, Optional name As String = Nothing) As ImmutableArray(Of ISymbol)

Parameters

position
Int32

The character position for determining the enclosing declaration scope and accessibility.

name
String

The name of the symbol to find. If null is specified then symbols with any names are returned.

Returns

A list of symbols that were found. If no symbols were found, an empty list is returned.

Remarks

The "position" is used to determine what variables are visible and accessible.

Non-reduced extension methods are considered, but reduced extension methods are not.

Applies to