static void CompileSourcesAndRun(string[] sources, string extension, CompiledResultDelegate resultDelegate) {
      TemporaryFile[] compiledAssemblyPaths = CompileSources(sources, extension);

      using (var host = new PeReader.DefaultHost()) {

        IAssembly[] loadedAssemblies = compiledAssemblyPaths.Select(pathToAssembly => {
          var assembly = host.LoadUnitFrom(pathToAssembly.Path) as IAssembly;
          Assert.IsNotNull(assembly);
          return assembly;
        }).ToArray();

        IAssembly mainAssembly = loadedAssemblies.Last();
        IAssembly[] referencedAssemblies = loadedAssemblies.Take(loadedAssemblies.Length - 1).ToArray();

        TestCompilerResults results = new TestCompilerResults(mainAssembly, referencedAssemblies, host);

        resultDelegate(results);
      }

      foreach (var tempFile in compiledAssemblyPaths) {
        tempFile.Dispose();
      }
    }
 static void CompileSourceAndRun(string source, string extension, CompiledResultDelegate resultDelegate) {
   CompileSourcesAndRun(new string[] { source }, extension, resultDelegate);
 }