Click or drag to resize

Document Class



Represents a source code document that is part of a project. It provides access to the source text, parsed syntax tree and the corresponding semantic model.
Inheritance Hierarchy

Namespace:  Microsoft.CodeAnalysis
Assembly:  Microsoft.CodeAnalysis.Workspaces (in Microsoft.CodeAnalysis.Workspaces.dll) Version: 2.3.0-dev-56735-00. Commit Hash: <developer build>
Syntax
public class Document : TextDocument

The Document type exposes the following members.

Properties
  NameDescription
Public propertyFilePath
The path to the document file or null if there is no document file.
(Inherited from TextDocument.)
Public propertyFolders
The sequence of logical folders the document is contained in.
(Inherited from TextDocument.)
Public propertyId
The document's identifier. Many document instances may share the same ID, but only one document in a solution may have that ID.
(Inherited from TextDocument.)
Public propertyName
The name of the document.
(Inherited from TextDocument.)
Public propertyProject
The project this document belongs to.
(Inherited from TextDocument.)
Public propertySourceCodeKind
The kind of source code this document contains.
Public propertySupportsSemanticModel
true
if this Document supports providing data through the GetSemanticModelAsync(CancellationToken) method. If
false
then this method will return
null
instead.
Public propertySupportsSyntaxTree
true
if this Document supports providing data through the GetSyntaxTreeAsync(CancellationToken) and GetSyntaxRootAsync(CancellationToken) methods. If
false
then these methods will return
null
instead.
Top
Methods
  NameDescription
Public methodGetLinkedDocumentIds
Gets the list of DocumentIds that are linked to this Document. Documents are considered to be linked if they share the same FilePath. This DocumentId is excluded from the result.
Public methodGetOptionsAsync
Public methodGetSemanticModelAsync
Public methodGetSyntaxRootAsync
Public methodGetSyntaxTreeAsync
Public methodGetSyntaxVersionAsync
Public methodGetTextAsync (Inherited from TextDocument.)
Public methodGetTextChangesAsync
Public methodGetTextVersionAsync (Inherited from TextDocument.)
Public methodTryGetSemanticModel
Gets the current semantic model for this document if the model is already computed and still cached. In almost all cases, you should call GetSemanticModelAsync(CancellationToken), which will compute the semantic model if necessary.
Public methodTryGetSyntaxRoot
Gets the root node of the current syntax tree if the syntax tree has already been parsed and the tree is still cached. In almost all cases, you should call GetSyntaxRootAsync(CancellationToken) to fetch the root node, which will parse the document if necessary.
Public methodTryGetSyntaxTree
Get the current syntax tree for the document if the text is already loaded and the tree is already parsed. In almost all cases, you should call GetSyntaxTreeAsync(CancellationToken) to fetch the tree, which will parse the tree if it's not already parsed.
Public methodTryGetSyntaxVersion
Get the current syntax tree version for the document if the text is already loaded and the tree is already parsed. In almost all cases, you should call GetSyntaxVersionAsync(CancellationToken) to fetch the version, which will load the tree if it's not already available.
Public methodTryGetText
Get the current text for the document if it is already loaded and available.
(Inherited from TextDocument.)
Public methodTryGetTextVersion
Gets the version of the document's text if it is already loaded and available.
(Inherited from TextDocument.)
Public methodWithFilePath
Creates a new instance of this document updated to have the specified file path.
Public methodWithFolders
Public methodWithName
Creates a new instance of this document updated to have the specified name.
Public methodWithSourceCodeKind
Creates a new instance of this document updated to have the source code kind specified.
Public methodWithSyntaxRoot
Creates a new instance of this document updated to have a syntax tree rooted by the specified syntax node.
Public methodWithText
Creates a new instance of this document updated to have the text specified.
Top
See Also