public ICompiledItem[] Compile(CompilationItem item, IEnumerable<string> references)
        {
            var compiledItems = new List<RoslynCompiledItem>();

            var requiredReferences =
                item.Project.MetadataReferences.Union(
                    references.Select(r => MetadataReference.CreateFromFile(r))).ToList();
            requiredReferences.Add(GetAuditDllReference());

            string newDllName = PathHelper.GetCoverageDllName(item.Project.Name);
            CSharpCompilation compiledDll = Compile(newDllName, item.SyntaxTrees, requiredReferences.ToArray());

            compiledItems.Add(new RoslynCompiledItem(item.Project, compiledDll));

            foreach (var compiledItem in compiledItems)
                compiledItem.EmitAndSave();

            return compiledItems.ToArray();
        }
        private void Compile(CompilationItem item, IEnumerable<CompilationItem> allItems, List<RoslynCompiledItem> currentlyCompiledItems, MetadataReference auditReference)
        {
            if (currentlyCompiledItems.Any(c => c.Project == item.Project))
                return;

            foreach (ProjectReference projectReference in item.Project.ProjectReferences)
            {
                CompilationItem referencedItem = allItems.Single(i => i.Project.Id == projectReference.ProjectId);
                Compile(referencedItem, allItems, currentlyCompiledItems, auditReference);
            }

            MetadataReference[] projectReferences = GetProjectReferences(item.Project, currentlyCompiledItems);
            MetadataReference[] auditReferences = { auditReference };
            MetadataReference[] requiredReferences = projectReferences.Union(item.Project.MetadataReferences).Union(auditReferences).ToArray();

            string newDllName = PathHelper.GetCoverageDllName(item.Project.Name);
            CSharpCompilation compilation = Compile(newDllName, item.SyntaxTrees, requiredReferences);

            currentlyCompiledItems.Add(new RoslynCompiledItem(item.Project, compilation));
        }