Freigeben über


IImportScope Interface

Definition

Represents the set of symbols that are imported to a particular position in a source file. Each import has a reference to the location the import directive was declared at. For the IAliasSymbol import, the location can be found using either Locations or DeclaringSyntaxReferences on the IAliasSymbol itself. For Imports or XmlNamespaces the location is found through DeclaringSyntaxReference or DeclaringSyntaxReference respectively.

public interface IImportScope
type IImportScope = interface
Public Interface IImportScope

Remarks

  • Scopes returned will always have at least one non-empty property value in them.
  • Symbols may be imported, but may not necessarily be available at that location (for example, an alias symbol hidden by another symbol).
  • In C# there will be an IImportScope for every containing namespace-declarations that include any import directives. There will also be an IImportScope for the containing compilation-unit if it includes any import directives or if there are global import directives pulled in from other files.
  • In Visual Basic there will commonly be one or two IImportScopes returned for any position. This will commonly be a scope for the containing compilation unit if it includes any import directives. As well as a scope representing any imports specified at the project level.
  • Elements of any property have no defined order. Even if they represent items from a single document, they are not guaranteed to be returned in any specific file-oriented order.
  • There is no guarantee that the same scope instances will be returned from successive calls to GetImportScopes(Int32, CancellationToken).

Properties

Name Description
Aliases

Aliases defined at this level of the chain. This corresponds to using X = TypeOrNamespace; in C# or Imports X = TypeOrNamespace in Visual Basic. This will include global aliases if present for both languages.

ExternAliases

Extern aliases defined at this level of the chain. This corresponds to extern alias X; in C#. It will be empty in Visual Basic.

Imports

Types or namespaces imported at this level of the chain. This corresponds to using Namespace; or using static Type; in C#, or Imports TypeOrNamespace in Visual Basic. This will include global namespace or type imports for both languages.

XmlNamespaces

Xml namespaces imported at this level of the chain. This corresponds to Imports <xmlns:prefix = "name"> in Visual Basic. It will be empty in C#.

Applies to