# CodeCompiler class

Namespace: [Grasshopper2.Expressions](https://developer.rhino3d.com/api/gh2/namespace/grasshopper2.expressions.md) · Assembly: [Grasshopper2](https://developer.rhino3d.com/api/gh2/assembly/grasshopper2.md)

```cs
public sealed class CodeCompiler
```

Compiler utility class for C# and VB compilation. Although you can technically re-use the same CodeCompiler instance to compile consecutive bits of source, we highly recommend creating a new instance for every new compile job. This class leverages the Roslyn compiler behind the scenes.

## Constructors

- [CodeCompiler](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codecompiler/ctor.md): Create a new code compiler with standard framework, RhinoCommon, Eto, Grasshopper, GrasshopperIO and MathNet assembly references.

## Properties

- [AllowConcurrent](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codecompiler/allowconcurrent.md): Gets or sets whether the compiler is allowed to run concurrently.
- [AllowOverflow](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codecompiler/allowoverflow.md): Gets or sets whether integer over and underflow exceptions are handled.
- [AllowUnsafe](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codecompiler/allowunsafe.md): Gets or sets whether unsafe code blocks are allowed.
- [GenerateInMemory](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codecompiler/generateinmemory.md): Gets whether the assembly ought to be compiled in memory. This returns true when [CodeCompiler.OutputPath](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codecompiler/outputpath.md) is not set.
- [GetCachedAssembly](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codecompiler/getcachedassembly.md): Gets the assembly that was cached during the most recent compilation. This field may be null if no compilation has occured, if the most recent compilation failed, or it the most recent compilation generated an assembly on the disk.
- [GetCachedErrors](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codecompiler/getcachederrors.md): Gets the collection of compiler warnings cached during the most recent compilation.
- [GetCachedSemanticModels](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codecompiler/getcachedsemanticmodels.md): Gets the collection of semantic models (one for every syntax tree) that were cached during the most recent compilation. This property may yield an empty array if no compilation has occured yet, or if the most recent compilation failed.
- [GetCachedSyntaxTrees](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codecompiler/getcachedsyntaxtrees.md): Gets the collection of syntax trees that were cached during the most recent compilation. This property may yield an empty array if no compilation has occured yet.
- [GetCachedWarnings](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codecompiler/getcachedwarnings.md): Gets the collection of compiler warnings cached during the most recent compilation.
- [IncludeDebugData](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codecompiler/includedebugdata.md): Gets or sets whether to generate debug level code.
- [Name](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codecompiler/name.md): Gets or sets the name of the assembly.
- [OutputPath](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codecompiler/outputpath.md): Gets or sets the assembly output path.
- [ReferenceCount](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codecompiler/referencecount.md): Gets the number of referenced assemblies.
- [StandardAssemblies](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codecompiler/standardassemblies.md): (static) Enumerate over all assembly locations which are included by default in a compiled assembly.
- [StandardReferences](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codecompiler/standardreferences.md): (static) Enumerate over all assembly references which are included by default in a compiled assembly.

## Methods

- [AddReferenceAssembly](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codecompiler/addreferenceassembly.md): Add an assembly location to be referenced in the build.
- [CompileCSharpCode](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codecompiler/compilecsharpcode.md): (5 overloads) Compile C# code into an assembly. Note: this method *always* returns null if the assembly was written to disc rather than generated in memory.
