Udostępnij za pośrednictwem


Compilation.IsSymbolAccessibleWithin(ISymbol, ISymbol, ITypeSymbol) Method

Definition

Checks if symbol is accessible from within within. An optional qualifier of type throughType is used to resolve protected access for instance members. All symbols are required to be from this compilation or some assembly referenced (References) by this compilation. within is required to be an INamedTypeSymbol or IAssemblySymbol.

public bool IsSymbolAccessibleWithin (Microsoft.CodeAnalysis.ISymbol symbol, Microsoft.CodeAnalysis.ISymbol within, Microsoft.CodeAnalysis.ITypeSymbol throughType = default);
public bool IsSymbolAccessibleWithin (Microsoft.CodeAnalysis.ISymbol symbol, Microsoft.CodeAnalysis.ISymbol within, Microsoft.CodeAnalysis.ITypeSymbol? throughType = default);
member this.IsSymbolAccessibleWithin : Microsoft.CodeAnalysis.ISymbol * Microsoft.CodeAnalysis.ISymbol * Microsoft.CodeAnalysis.ITypeSymbol -> bool
Public Function IsSymbolAccessibleWithin (symbol As ISymbol, within As ISymbol, Optional throughType As ITypeSymbol = Nothing) As Boolean

Parameters

symbol
ISymbol
within
ISymbol
throughType
ITypeSymbol

Returns

Remarks

Submissions can reference symbols from previous submissions and their referenced assemblies, even though those references are missing from References. See https://github.com/dotnet/roslyn/issues/27356. This implementation works around that by permitting symbols from previous submissions as well.

It is advised to avoid the use of this API within the compilers, as the compilers have additional requirements for access checking that are not satisfied by this implementation, including the avoidance of infinite recursion that could result from the use of the ISymbol APIs here, the detection of use-site diagnostics, and additional returned details (from the compiler's internal APIs) that are helpful for more precisely diagnosing reasons for accessibility failure.

Applies to