Click or drag to resize

Compilation Class



The compilation object is an immutable representation of a single invocation of the compiler. Although immutable, a compilation is also on-demand, and will realize and cache data as necessary. A compilation can produce a new compilation from existing compilation with the application of small deltas. In many cases, it is more efficient than creating a new compilation from scratch, as the new compilation can reuse information from the old compilation.
The compilation object is an immutable representation of a single invocation of the compiler. Although immutable, a compilation is also on-demand, and will realize and cache data as necessary. A compilation can produce a new compilation from existing compilation with the application of small deltas. In many cases, it is more efficient than creating a new compilation from scratch, as the new compilation can reuse information from the old compilation.
Inheritance Hierarchy

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

The Compilation type exposes the following members.

Properties
  NameDescription
Public propertyAssembly
The IAssemblySymbol that represents the assembly being created.
Public propertyAssemblyName
Simple assembly name, or null if not specified.
Protected propertyCommonAssembly
Protected propertyCommonDynamicType
Protected propertyCommonGlobalNamespace
Protected propertyCommonObjectType
Protected propertyCommonOptions
Protected propertyCommonScriptClass
Protected propertyCommonSourceModule
Protected propertyCommonSyntaxTrees
Public propertyDirectiveReferences
Unique metadata references specified via #r directive in the source code of this compilation.
Public propertyDynamicType
The TypeSymbol for the type 'dynamic' in this Compilation.
Public propertyExternalReferences
Metadata references passed to the compilation constructor.
Public propertyGlobalNamespace
The root namespace that contains all namespaces and types defined in source code or in referenced metadata, merged into a single namespace hierarchy.
Public propertyIsCaseSensitive
Returns true if this is a case sensitive compilation, false otherwise. Case sensitivity affects compilation features such as name lookup as well as choosing what names to emit when there are multiple different choices (for example between a virtual method and an override).
Public propertyLanguage
Gets the source language ("C#" or "Visual Basic").
Public propertyObjectType
The INamedTypeSymbol for the .NET System.Object type, which could have a TypeKind of Error if there was no COR Library in this Compilation.
Public propertyOptions
Gets the options the compilation was created with.
Public propertyReferencedAssemblyNames
Assembly identities of all assemblies directly referenced by this compilation.
Public propertyReferences
All metadata references -- references passed to the compilation constructor as well as references specified via #r directives.
Public propertyScriptClass
A symbol representing the implicit Script class. This is null if the class is not defined in the compilation.
Public propertyScriptCompilationInfo
Public propertySourceModule
Gets the IModuleSymbol for the module being created by compiling all of the source code.
Public propertySyntaxTrees
Gets the syntax trees (parsed from source code) that this compilation was created with.
Top
Methods
  NameDescription
Public methodAddReferences(IEnumerableT)
Public methodAddReferences(MetadataReference)
Creates a new compilation with additional metadata references.
Public methodAddSyntaxTrees(IEnumerableT)
Public methodAddSyntaxTrees(SyntaxTree)
Creates a new compilation with additional syntax trees.
Protected methodAppendDefaultVersionResource
Protected methodStatic memberCheckTupleElementLocations
Protected methodStatic memberCheckTupleElementNames
Check that if any names are provided, and their number matches the expected cardinality. Returns a normalized version of the element names (empty array if all the names are null).
Public methodClone
Creates a new compilation equivalent to this one with different symbol instances.
Protected methodCommonAddSyntaxTrees
Protected methodCommonBindScriptClass
Resolves a symbol that represents script container (Script class). Uses the full name of the container class stored in ScriptClassName to find the symbol.
Protected methodCommonClone
Protected methodCommonContainsSyntaxTree
Protected methodCommonCreateAnonymousTypeSymbol
Protected methodCommonCreateArrayTypeSymbol
Protected methodCommonCreateErrorNamespaceSymbol
Protected methodCommonCreateErrorTypeSymbol
Protected methodCommonCreatePointerTypeSymbol
Protected methodCommonCreateTupleTypeSymbol(INamedTypeSymbol, ImmutableArrayString, ImmutableArrayLocation)
Protected methodCommonCreateTupleTypeSymbol(ImmutableArrayITypeSymbol, ImmutableArrayString, ImmutableArrayLocation)
Protected methodCommonGetAssemblyOrModuleSymbol
Protected methodCommonGetCompilationNamespace
Protected methodCommonGetEntryPoint
Protected methodCommonGetSemanticModel
Protected methodCommonGetSpecialType
Protected methodCommonGetTypeByMetadataName
Protected methodCommonRemoveAllSyntaxTrees
Protected methodCommonRemoveSyntaxTrees
Protected methodCommonReplaceSyntaxTree
Protected methodCommonWithAssemblyName
Protected methodCommonWithOptions
Protected methodCommonWithReferences
Protected methodCommonWithScriptCompilationInfo
Public methodContainsSymbolsWithName
Public methodContainsSyntaxTree
Returns true if this compilation contains the specified tree. False otherwise.
Public methodCreateAnonymousTypeSymbol
Returns a new anonymous type symbol with the given member types member names. Anonymous type members will be readonly by default. Writable properties are supported in VB and can be created by passing in
false
in the appropriate locations in memberIsReadOnly. Source locations can also be provided through memberLocations
Public methodCreateArrayTypeSymbol
Returns a new ArrayTypeSymbol representing an array type tied to the base types of the COR Library in this Compilation.
Public methodCreateDefaultWin32Resources
Create a stream filled with default win32 resources.
Public methodCreateErrorNamespaceSymbol
Returns a new INamespaceSymbol representing an error (missing) namespace with the given name.
Public methodCreateErrorTypeSymbol
Returns a new INamedTypeSymbol representing an error type with the given name and arity in the given optional container.
Public methodCreatePointerTypeSymbol
Returns a new PointerTypeSymbol representing a pointer type tied to a type in this Compilation.
Public methodCreateTupleTypeSymbol(INamedTypeSymbol, ImmutableArrayString, ImmutableArrayLocation)
Returns a new INamedTypeSymbol with the given underlying type and (optional) element names.
Public methodCreateTupleTypeSymbol(ImmutableArrayITypeSymbol, ImmutableArrayString, ImmutableArrayLocation)
Returns a new INamedTypeSymbol with the given element types and (optional) element names.
Public methodEmit(Stream, Stream, Stream, Stream, IEnumerableT, Void, ResourceDescription)
Public methodEmit(Stream, Stream, Stream, Stream, IEnumerableT, Void, ResourceDescription, EmitOptions)
Public methodEmit(Stream, Stream, Stream, Stream, IEnumerableT, Void, ResourceDescription, EmitOptions, IMethodSymbol, Stream)
Public methodEmitDifference(EmitBaseline, IEnumerableT, Void, SemanticEdit, Stream, Stream, Stream)
Public methodEmitDifference(EmitBaseline, IEnumerableT, Void, SemanticEdit, FuncT, TResult, Boolean, ISymbol, Boolean)
Public methodGetAssemblyOrModuleSymbol
Gets the IAssemblySymbol or IModuleSymbol for a metadata reference used to create this compilation.
Public methodGetCompilationNamespace
Gets the corresponding compilation namespace for the specified module or assembly namespace.
Public methodGetDeclarationDiagnostics
Gets the diagnostics produced during symbol declaration.
Public methodGetDiagnostics
Gets all the diagnostics for the compilation, including syntax, declaration, and binding. Does not include any diagnostics that might be produced during emit, see EmitResult.
Public methodGetEntryPoint
Returns the Main method that will serves as the entry point of the assembly, if it is executable (and not a script).
Public methodGetMetadataReference
Gets the MetadataReference that corresponds to the assembly symbol.
Public methodGetMethodBodyDiagnostics
Gets the diagnostics produced during the analysis of method bodies and field initializers.
Public methodGetParseDiagnostics
Gets the diagnostics produced during the parsing stage.
Public methodStatic memberGetRequiredLanguageVersion
Returns the required language version found in a Diagnostic, if any is found. Returns null if none is found.
Public methodGetSemanticModel
Gets a new SemanticModel for the specified syntax tree.
Public methodGetSpecialType
Get the symbol for the predefined type from the Cor Library referenced by this compilation.
Public methodGetSymbolsWithName
Public methodGetTypeByMetadataName
Gets the type within the compilation's assembly and all referenced assemblies (other than those that can only be referenced via an extern alias) using its canonical CLR metadata name.
Public methodGetUnreferencedAssemblyIdentities
Given a Diagnostic reporting unreferenced AssemblyIdentitys, returns the actual AssemblyIdentity instances that were not referenced.
Public methodRemoveAllReferences
Creates a new compilation without any metadata references.
Public methodRemoveAllSyntaxTrees
Creates a new compilation without any syntax trees. Preserves metadata info for use with trees added later.
Public methodRemoveReferences(IEnumerableT)
Public methodRemoveReferences(MetadataReference)
Creates a new compilation without the specified metadata references.
Public methodRemoveSyntaxTrees(IEnumerableT)
Public methodRemoveSyntaxTrees(SyntaxTree)
Creates a new compilation without the specified syntax trees. Preserves metadata info for use with trees added later.
Public methodReplaceReference
Creates a new compilation with an old metadata reference replaced with a new metadata reference.
Public methodReplaceSyntaxTree
Creates a new compilation with an old syntax tree replaced with a new syntax tree. Reuses metadata from old compilation object.
Protected methodStatic memberSyntaxTreeCommonFeatures
Public methodToMetadataReference
Creates a metadata reference for this compilation.
Public methodWithAssemblyName
Creates a compilation with the specified assembly name.
Public methodWithOptions
Creates a new compilation with the specified compilation options.
Public methodWithReferences(IEnumerableT)
Public methodWithReferences(MetadataReference)
Creates a new compilation with the specified references.
Public methodWithScriptCompilationInfo
Top
Extension Methods
  NameDescription
Public Extension MethodAliasImports
Gets the compilation AliasImports property.
(Defined by VisualBasicExtensions.)
Public Extension MethodClassifyConversion(ITypeSymbol, ITypeSymbol)Overloaded.
Determines what kind of conversion there is between the specified types.
(Defined by VisualBasicExtensions.)
Public Extension MethodClassifyConversion(ITypeSymbol, ITypeSymbol)Overloaded. (Defined by CSharpExtensions.)
Public Extension MethodEmit (Defined by FileSystemExtensions.)
Public Extension MethodGetSpecialType
Gets the special type symbol in current compilation.
(Defined by VisualBasicExtensions.)
Public Extension MethodMemberImports
Gets the compilation MemberImports property.
(Defined by VisualBasicExtensions.)
Public Extension MethodRootNamespace
Gets the compilation RootNamespace property.
(Defined by VisualBasicExtensions.)
Public Extension MethodWithAnalyzers(ImmutableArrayDiagnosticAnalyzer, CompilationWithAnalyzersOptions)Overloaded.
Returns a new compilation with attached diagnostic analyzers.
(Defined by DiagnosticAnalyzerExtensions.)
Public Extension MethodWithAnalyzers(ImmutableArrayDiagnosticAnalyzer, AnalyzerOptions, CancellationToken)Overloaded.
Returns a new compilation with attached diagnostic analyzers.
(Defined by DiagnosticAnalyzerExtensions.)
Top
See Also