public Either <Exception, KeyValuePair <string, byte[]> > Build() { var compilation = CSharpCompilation.Create( AssemblyName, syntaxTrees: new[] { _syntaxTree }, references: ListReferences(), options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)); using (var memoryStream = new MemoryStream()) { var emitResult = compilation.Emit(memoryStream); return(emitResult.Success ? Right <Exception, KeyValuePair <string, byte[]> >(Make.Pair(AssemblyName, memoryStream.ToArray())) : Left((Exception) new AssemblyBuildException(emitResult.Diagnostics))); } }