/// <summary> /// Builds the assembly. /// </summary> protected virtual Assembly BuildAssembly(CSharpCompilation compilation) { using (var ms = new MemoryStream()) { var result = compilation.Emit(ms); if (result.Success) { var assembly = AssemblyLoader.LoadRaw(ms.ToArray()); assemblyCache.AddAssembly(assembly, compilation.ToMetadataReference()); return(assembly); } else { throw new Exception("The compilation failed! This is most probably bug in the DotVVM framework.\r\n\r\n" + string.Join("\r\n", result.Diagnostics) + "\r\n\r\n" + compilation.SyntaxTrees[0].GetRoot().NormalizeWhitespace() + "\r\n\r\n" + "References: " + string.Join("\r\n", compilation.ReferencedAssemblyNames.Select(n => n.Name))); } } }