Пример #1
0
        private static void IndexSolutions(IEnumerable<string> solutionFilePaths)
        {
            var solutionGenerators = new List<SolutionGenerator>();
            var assemblyNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

            foreach (var path in solutionFilePaths)
            {
                using (Disposable.Timing("Loading " + path))
                {
                    var solutionGenerator = new SolutionGenerator(
                        path,
                        Paths.SolutionDestinationFolder);
                    solutionGenerators.Add(solutionGenerator);
                    foreach (var assemblyName in solutionGenerator.GetAssemblyNames())
                    {
                        assemblyNames.Add(assemblyName);
                    }
                }
            }

            foreach (var solutionGenerator in solutionGenerators)
            {
                using (Disposable.Timing("Generating " + solutionGenerator.ProjectFilePath))
                {
                    solutionGenerator.GlobalAssemblyList = assemblyNames;
                    solutionGenerator.Generate(solutionExplorerRoot: mergedSolutionExplorerRoot);
                }
            }
        }
Пример #2
0
 public ProjectGenerator SetSolutionGenerator(SolutionGenerator gen)
 {
     SolutionGenerator = gen;
     if (!this.ProjectDestinationFolder.StartsWith(gen.SolutionDestinationFolder))
         throw new InvalidDataException(String.Format("Solution destination folder mismatch = {0}", gen.SolutionDestinationFolder));
     return this;
 }
Пример #3
0
        private static void IndexSolutions(IEnumerable <string> solutionFilePaths, Dictionary <string, string> properties, Federation federation)
        {
            var assemblyNames = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            foreach (var path in solutionFilePaths)
            {
                using (Disposable.Timing("Reading assembly names from " + path))
                {
                    foreach (var assemblyName in AssemblyNameExtractor.GetAssemblyNames(path))
                    {
                        assemblyNames.Add(assemblyName);
                    }
                }
            }

            foreach (var path in solutionFilePaths)
            {
                using (Disposable.Timing("Generating " + path))
                {
                    using (var solutionGenerator = new SolutionGenerator(
                               path,
                               Paths.SolutionDestinationFolder,
                               properties: properties.ToImmutableDictionary(),
                               federation: federation))
                    {
                        solutionGenerator.GlobalAssemblyList = assemblyNames;
                        solutionGenerator.Generate(solutionExplorerRoot: mergedSolutionExplorerRoot);
                    }
                }

                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
            }
        }
Пример #4
0
        private IEnumerable <Tuple <string, string, string> > GetTypeForwardsImpl(string path, IReadOnlyDictionary <string, string> properties)
        {
            var      workspace = SolutionGenerator.CreateWorkspace(properties.ToImmutableDictionary());
            Solution solution;

            if (path.EndsWith(".sln"))
            {
                solution = workspace.OpenSolutionAsync(path).GetAwaiter().GetResult();
            }
            else
            {
                solution = workspace.OpenProjectAsync(path).GetAwaiter().GetResult().Solution;
            }

            var assemblies = solution.Projects.Select(p => p.OutputFilePath).ToList();

            foreach (var assemblyFile in assemblies)
            {
                if (File.Exists(assemblyFile))
                {
                    Log.Write("File exists: " + assemblyFile);
                }
                else
                {
                    Log.Write("File doesn't exist: " + assemblyFile);
                    continue;
                }

                foreach (Tuple <string, string, string> tuple in ReadTypeForwardsFromAssembly(assemblyFile))
                {
                    yield return(tuple);
                }
            }
        }
Пример #5
0
        public void GenerateExternalReferences(HashSet <string> assemblyList)
        {
            var externalReferences = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);

            foreach (var project in solution.Projects)
            {
                var references = project.MetadataReferences
                                 .OfType <PortableExecutableReference>()
                                 .Where(m => File.Exists(m.FilePath) &&
                                        !assemblyList.Contains(Path.GetFileNameWithoutExtension(m.FilePath)) &&
                                        !IsPartOfSolution(Path.GetFileNameWithoutExtension(m.FilePath)) &&
                                        GetExternalAssemblyIndex(Path.GetFileNameWithoutExtension(m.FilePath)) == -1
                                        )
                                 .Select(m => Path.GetFullPath(m.FilePath));
                foreach (var reference in references)
                {
                    externalReferences[Path.GetFileNameWithoutExtension(reference)] = reference;
                }
            }

            foreach (var externalReference in externalReferences)
            {
                Log.Write(externalReference.Key, ConsoleColor.Magenta);
                var solutionGenerator = new SolutionGenerator(
                    externalReference.Value,
                    Paths.SolutionDestinationFolder,
                    pluginBlacklist: PluginBlacklist);
                solutionGenerator.Generate(assemblyList);
            }
        }
Пример #6
0
        private static void IndexSolutions(
            IEnumerable <string> solutionFilePaths,
            Dictionary <string, string> properties,
            Federation federation,
            Dictionary <string, string> serverPathMappings,
            IEnumerable <string> pluginBlacklist,
            bool doNotIncludeReferencedProjects = false)
        {
            var assemblyNames = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            foreach (var path in solutionFilePaths)
            {
                using (Disposable.Timing("Reading assembly names from " + path))
                {
                    foreach (var assemblyName in AssemblyNameExtractor.GetAssemblyNames(path))
                    {
                        assemblyNames.Add(assemblyName);
                    }
                }
            }

            var processedAssemblyList = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
            var typeForwards          = new Dictionary <ValueTuple <string, string>, string>();

            var domain = AppDomain.CreateDomain("TypeForwards");

            foreach (var path in solutionFilePaths)
            {
                using (Disposable.Timing($"Reading type forwards from {path}"))
                {
                    GetTypeForwards(path, properties, typeForwards, domain);
                }
            }
            AppDomain.Unload(domain);
            domain = null;

            foreach (var path in solutionFilePaths)
            {
                using (Disposable.Timing("Generating " + path))
                {
                    using (var solutionGenerator = new SolutionGenerator(
                               path,
                               Paths.SolutionDestinationFolder,
                               properties: properties.ToImmutableDictionary(),
                               federation: federation,
                               serverPathMappings: serverPathMappings,
                               pluginBlacklist: pluginBlacklist,
                               doNotIncludeReferencedProjects: doNotIncludeReferencedProjects,
                               typeForwards: typeForwards))
                    {
                        solutionGenerator.GlobalAssemblyList = assemblyNames;
                        solutionGenerator.Generate(processedAssemblyList, mergedSolutionExplorerRoot);
                    }
                }

                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
            }
        }
Пример #7
0
        private static void IndexSolutions(IEnumerable<string> solutionFilePaths)
        {
            var assemblyNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

            foreach (var path in solutionFilePaths)
            {
                using (Disposable.Timing("Reading assembly names from " + path))
                {
                    foreach (var assemblyName in AssemblyNameExtractor.GetAssemblyNames(path))
                    {
                        assemblyNames.Add(assemblyName);
                    }
                }
            }

            var federation = new Federation();
            foreach (var path in solutionFilePaths)
            {
                using (Disposable.Timing("Generating " + path))
                {
                    using (var solutionGenerator = new SolutionGenerator(
                        path,
                        Paths.SolutionDestinationFolder,
                        federation: federation))
                    {
                        solutionGenerator.GlobalAssemblyList = assemblyNames;
                        solutionGenerator.Generate(solutionExplorerRoot: mergedSolutionExplorerRoot);
                    }
                }

                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
            }
        }
 private void GenerateTypeScriptFile(string filePath)
 {
     if (File.Exists(filePath = NormalizeFilePath(filePath)))
     {
         AddOtherFileRelativeToProject(filePath);
         SolutionGenerator.AddTypeScriptFile(filePath);
     }
 }
Пример #9
0
 public ProjectGenerator(SolutionGenerator solutionGenerator, Project project) : this()
 {
     this.SolutionGenerator           = solutionGenerator;
     this.Project                     = project;
     this.ProjectFilePath             = project.FilePath ?? solutionGenerator.ProjectFilePath;
     this.DeclaredSymbols             = new Dictionary <ISymbol, string>();
     this.BaseMembers                 = new Dictionary <ISymbol, ISymbol>();
     this.ImplementedInterfaceMembers = new MultiDictionary <ISymbol, ISymbol>();
     this.assemblyAttributesFileName  = MetadataAsSource.GeneratedAssemblyAttributesFileName + (project.Language == LanguageNames.CSharp ? ".cs" : ".vb");
 }
Пример #10
0
 public ProjectGenerator(SolutionGenerator solutionGenerator, Project project) : this()
 {
     this.SolutionGenerator = solutionGenerator;
     this.Project = project;
     this.ProjectFilePath = project.FilePath ?? solutionGenerator.ProjectFilePath;
     this.DeclaredSymbols = new Dictionary<ISymbol, string>();
     this.BaseMembers = new Dictionary<ISymbol, ISymbol>();
     this.ImplementedInterfaceMembers = new MultiDictionary<ISymbol, ISymbol>();
     this.assemblyAttributesFileName = MetadataAsSource.GeneratedAssemblyAttributesFileName + (project.Language == LanguageNames.CSharp ? ".cs" : ".vb");
 }
Пример #11
0
        private static void IndexSolutions(IEnumerable <string> solutionFilePaths, ISet <string> excludedProjects, Dictionary <string, string> properties, Federation federation, Dictionary <string, string> serverPathMappings, IEnumerable <string> pluginBlacklist)
        {
            var assemblyNames = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            foreach (var path in solutionFilePaths)
            {
                using (Disposable.Timing("Reading assembly names from " + path))
                {
                    if (IsExludedProject(excludedProjects, path))
                    {
                        Log.Write("The project/solution is excluded: " + path, ConsoleColor.Yellow);
                        continue;
                    }

                    foreach (var assemblyName in AssemblyNameExtractor.GetAssemblyNames(path, excludedProjects))
                    {
                        assemblyNames.Add(assemblyName);
                        Log.Write("Assembly to process: " + assemblyName, ConsoleColor.Gray);
                    }
                }
            }

            var processedAssemblyList = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            foreach (var path in solutionFilePaths)
            {
                using (Disposable.Timing("Generating " + path))
                {
                    if (IsExludedProject(excludedProjects, path))
                    {
                        Log.Write("The project/solution is excluded: " + path, ConsoleColor.Yellow);
                        continue;
                    }

                    using (var solutionGenerator = new SolutionGenerator(
                               path,
                               Paths.SolutionDestinationFolder,
                               properties: properties.ToImmutableDictionary(),
                               federation: federation,
                               serverPathMappings: serverPathMappings,
                               pluginBlacklist: pluginBlacklist))
                    {
                        solutionGenerator.GlobalAssemblyList = assemblyNames;
                        solutionGenerator.Generate(processedAssemblyList, mergedSolutionExplorerRoot);
                    }
                }

                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
            }
        }
        private void GenerateTypeScriptFile(string filePath)
        {
            var projectSourceFolder = Path.GetDirectoryName(ProjectFilePath);

            if (!Path.IsPathRooted(filePath))
            {
                filePath = Path.Combine(Path.GetDirectoryName(ProjectFilePath), filePath);
            }

            SolutionGenerator.AddTypeScriptFile(filePath);

            var relativePath = Paths.MakeRelativeToFile(filePath, ProjectFilePath);

            relativePath = relativePath.Replace("..", "parent");
            OtherFiles.Add(relativePath);
        }
Пример #13
0
        private IEnumerable <Tuple <string, string, string> > GetTypeForwardsImpl(string path, IReadOnlyDictionary <string, string> properties)
        {
            var      workspace = SolutionGenerator.CreateWorkspace(properties.ToImmutableDictionary());
            Solution solution;

            if (path.EndsWith(".sln"))
            {
                solution = workspace.OpenSolutionAsync(path).GetAwaiter().GetResult();
            }
            else
            {
                solution = workspace.OpenProjectAsync(path).GetAwaiter().GetResult().Solution;
            }

            var assemblies = solution.Projects.Select(p => p.OutputFilePath).ToList();

            foreach (var assemblyFile in assemblies)
            {
                if (File.Exists(assemblyFile))
                {
                    Log.Write("File exists: " + assemblyFile);
                }
                else
                {
                    Log.Write("File doesn't exist: " + assemblyFile);
                    continue;
                }

                var thisAssemblyName = Path.GetFileNameWithoutExtension(assemblyFile);
                using (var peReader = new PEReader(File.ReadAllBytes(assemblyFile).ToImmutableArray()))
                {
                    var reader = peReader.GetMetadataReader();
                    foreach (var exportedTypeHandle in reader.ExportedTypes)
                    {
                        var exportedType = reader.GetExportedType(exportedTypeHandle);
                        var result       = ProcessExportedType(exportedType, reader, thisAssemblyName);
                        if (result != null)
                        {
                            Log.Write(result.ToString());
                            yield return(result);
                        }
                    }
                }
            }
        }
        private void WriteReferences(StringBuilder sb)
        {
            sb.Append("<div class=\"folderTitle\">References</div>");
            sb.AppendLine("<div class=\"folder\">");

            var assemblyNames = new SortedSet <string>();

            foreach (var projectReference in Project.ProjectReferences.Select(p => Project.Solution.GetProject(p.ProjectId).AssemblyName))
            {
                assemblyNames.Add(projectReference);
            }

            foreach (var metadataReference in Project.MetadataReferences.Select(m => Path.GetFileNameWithoutExtension(m.Display)))
            {
                assemblyNames.Add(metadataReference);
            }

            foreach (var reference in ForwardedReferenceAssemblies)
            {
                assemblyNames.Add(reference);
            }

            var usedReferences = new HashSet <string>(this.UsedReferences, StringComparer.OrdinalIgnoreCase);

            foreach (var reference in assemblyNames)
            {
                var    externalIndex = this.SolutionGenerator.GetExternalAssemblyIndex(reference);
                string url           = "/#" + reference;
                if (externalIndex != -1)
                {
                    url = "@" + externalIndex.ToString() + "@#" + reference;
                    sb.AppendLine(Markup.GetProjectExplorerReference(url, reference));
                }
                else if ((SolutionGenerator.IsPartOfSolution(reference) || (reference?.Contains("->") ?? false)) && usedReferences.Contains(reference))
                {
                    sb.AppendLine(Markup.GetProjectExplorerReference(url, reference));
                }
                else
                {
                    sb.Append("<span class=\"referenceDisabled\">").Append(reference).AppendLine("</span>");
                }
            }

            sb.AppendLine("</div>");
        }
Пример #15
0
 public static void GenerateInvocation(CompilerInvocation invocation,
                                       IReadOnlyDictionary <string, string> serverPathMappings = null,
                                       HashSet <string> processedAssemblyList        = null,
                                       HashSet <string> assemblyNames                = null,
                                       Folder <ProjectSkeleton> solutionExplorerRoot = null)
 {
     try
     {
         if (invocation.Language == "TypeScript")
         {
             Log.Write("TypeScript invocation", ConsoleColor.Magenta);
             var typeScriptGenerator = new TypeScriptSupport();
             typeScriptGenerator.Generate(invocation.TypeScriptFiles, Paths.SolutionDestinationFolder);
         }
         else if (invocation.ProjectFilePath != "-")
         {
             Log.Write(invocation.ProjectFilePath, ConsoleColor.Cyan);
             var solutionGenerator = new SolutionGenerator(
                 invocation.ProjectFilePath,
                 invocation.CommandLineArguments,
                 invocation.OutputAssemblyPath,
                 invocation.SolutionRoot,
                 Paths.SolutionDestinationFolder,
                 invocation.ServerPath,
                 invocation.NetworkShare);
             solutionGenerator.ServerPathMappings = serverPathMappings;
             solutionGenerator.GlobalAssemblyList = assemblyNames;
             solutionGenerator.Generate(processedAssemblyList, solutionExplorerRoot);
         }
         else
         {
             Log.Write(invocation.OutputAssemblyPath, ConsoleColor.Magenta);
             var solutionGenerator = new SolutionGenerator(
                 invocation.OutputAssemblyPath,
                 Paths.SolutionDestinationFolder);
             solutionGenerator.Generate();
         }
     }
     catch (Exception ex)
     {
         Log.Exception(ex, "Generating invocation: " + invocation.ProjectFilePath + " - " + invocation.OutputAssemblyPath);
     }
 }
Пример #16
0
        private static void IndexSolution(SolutionInfo solutionInfo, HashSet<string> assemblyList)
        {
            using (Disposable.Timing("Generating projects for " + Path.GetFileName(solutionInfo.SlnPath)))
            {
                bool needToCallAgain = false;

                // we need to call several times because it only processes projects one batch at a time
                // to avoid OutOfMemory on really large solutions
                do
                {
                    GC.Collect();
                    var solutionGenerator = new SolutionGenerator(
                        solutionInfo.SlnPath,
                        Paths.SolutionDestinationFolder,
                        solutionInfo.UrlRoot,
                        solutionInfo.MSBuildProperties != null ? solutionInfo.MSBuildProperties.ToImmutableDictionary() : null,
                        new Federation(Federation.FederatedIndexUrls));
                    needToCallAgain = solutionGenerator.Generate(assemblyList, mergedSolutionExplorerRoot);
                    solutionGenerator.GenerateResultsHtml(assemblyList);
                } while (needToCallAgain);
            }
        }
Пример #17
0
        public static void IndexSolutions(IEnumerable<string> solutionFilePaths, Dictionary<string, string> properties)
        {
            var assemblyNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

            foreach (var path in solutionFilePaths)
            {
                using (Disposable.Timing("Reading assembly names from " + path))
                {
                    foreach (var assemblyName in AssemblyNameExtractor.GetAssemblyNames(path))
                    {
                        assemblyNames.Add(assemblyName);
                    }
                }
            }

            var federation = new Federation();
            foreach (var path in solutionFilePaths)
            {
                using (Disposable.Timing("Generating " + path))
                {
                    using (var solutionGenerator = new SolutionGenerator(
                        path,
                        Paths.SolutionDestinationFolder,
                        properties: properties.ToImmutableDictionary(),
                        federation: federation))
                    {
                        solutionGenerator.GlobalAssemblyList = assemblyNames;
                        solutionGenerator.Generate(solutionExplorerRoot: mergedSolutionExplorerRoot);

                        if (Configuration.ProcessReferencies)
                            Extend.ExtendGenerator.TopReferencedAssemblies(solutionGenerator, federation, mergedSolutionExplorerRoot);
                    }
                }

                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
            }
        }
 public static void GenerateInvocation(CompilerInvocation invocation)
 {
     try
     {
         if (invocation.Language == "TypeScript")
         {
             Log.Write("TypeScript invocation", ConsoleColor.Magenta);
             var typeScriptGenerator = new TypeScriptSupport();
             typeScriptGenerator.Generate(invocation.TypeScriptFiles, Paths.SolutionDestinationFolder);
         }
         else if (invocation.ProjectFilePath != "-")
         {
             Log.Write(invocation.ProjectFilePath, ConsoleColor.Cyan);
             var solutionGenerator = new SolutionGenerator(
                 invocation.ProjectFilePath,
                 invocation.CommandLineArguments,
                 invocation.OutputAssemblyPath,
                 invocation.SolutionRoot,
                 Paths.SolutionDestinationFolder,
                 invocation.ServerPath,
                 invocation.NetworkShare);
             solutionGenerator.Generate();
         }
         else
         {
             Log.Write(invocation.OutputAssemblyPath, ConsoleColor.Magenta);
             var solutionGenerator = new SolutionGenerator(
                 invocation.OutputAssemblyPath,
                 Paths.SolutionDestinationFolder);
             solutionGenerator.Generate();
         }
     }
     catch (Exception ex)
     {
         Log.Exception(ex, "Generating invocation: " + invocation.ProjectFilePath + " - " + invocation.OutputAssemblyPath);
     }
 }
Пример #19
0
 public static void GenerateInvocation(CompilerInvocation invocation)
 {
     try
     {
         if (invocation.Language == "TypeScript")
         {
             Log.Write("TypeScript invocation", ConsoleColor.Magenta);
             var typeScriptGenerator = new TypeScriptSupport();
             typeScriptGenerator.Generate(invocation.TypeScriptFiles);
         }
         else if (invocation.ProjectFilePath != "-")
         {
             Log.Write(invocation.ProjectFilePath, ConsoleColor.Cyan);
             var solutionGenerator = new SolutionGenerator(
                 invocation.ProjectFilePath,
                 invocation.CommandLineArguments,
                 invocation.OutputAssemblyPath,
                 invocation.SolutionRoot,
                 Paths.SolutionDestinationFolder,
                 invocation.ServerPath,
                 invocation.NetworkShare);
             solutionGenerator.Generate();
         }
         else
         {
             Log.Write(invocation.OutputAssemblyPath, ConsoleColor.Magenta);
             var solutionGenerator = new SolutionGenerator(
                 invocation.OutputAssemblyPath,
                 Paths.SolutionDestinationFolder);
             solutionGenerator.Generate();
         }
     }
     catch (Exception ex)
     {
         Log.Exception(ex, "Generating invocation: " + invocation.ProjectFilePath + " - " + invocation.OutputAssemblyPath);
     }
 }
Пример #20
0
        private static void IndexSolutions(IEnumerable<string> solutionFilePaths, Dictionary<string, string> properties, Federation federation, Dictionary<string, string> serverPathMappings)
        {
            var assemblyNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

            foreach (var path in solutionFilePaths)
            {
                using (Disposable.Timing("Reading assembly names from " + path))
                {
                    foreach (var assemblyName in AssemblyNameExtractor.GetAssemblyNames(path))
                    {
                        assemblyNames.Add(assemblyName);
                    }
                }
            }

            foreach (var path in solutionFilePaths)
            {
                using (Disposable.Timing("Generating " + path))
                {
                    using (var solutionGenerator = new SolutionGenerator(
                        path,
                        Paths.SolutionDestinationFolder,
                        properties: properties.ToImmutableDictionary(),
                        federation: federation,
                        serverPathMappings: serverPathMappings))
                    {
                        solutionGenerator.GlobalAssemblyList = assemblyNames;
                        solutionGenerator.Generate(solutionExplorerRoot: mergedSolutionExplorerRoot);
                    }
                }

                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
            }
        }
Пример #21
0
        private static void IndexSolutions(
            IEnumerable <string> solutionFilePaths,
            Dictionary <string, string> properties,
            Federation federation,
            Dictionary <string, string> serverPathMappings,
            IEnumerable <string> pluginBlacklist,
            bool doNotIncludeReferencedProjects = false)
        {
            var assemblyNames = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            foreach (var path in solutionFilePaths)
            {
                using (Disposable.Timing("Reading assembly names from " + path))
                {
                    foreach (var assemblyName in GetAssemblyNames(path))
                    {
                        assemblyNames.Add(assemblyName);
                    }
                }
            }

            var processedAssemblyList = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
            var typeForwards          = new Dictionary <ValueTuple <string, string>, string>();

            var domain = AppDomain.CreateDomain("TypeForwards");

            foreach (var path in solutionFilePaths)
            {
                if (
                    path.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) ||
                    path.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)
                    )
                {
                    continue;
                }
                using (Disposable.Timing($"Reading type forwards from {path}"))
                {
                    GetTypeForwards(path, properties, typeForwards, domain);
                }
            }
            AppDomain.Unload(domain);
            domain = null;

            foreach (var path in solutionFilePaths)
            {
                using (Disposable.Timing("Generating " + path))
                {
                    if (path.EndsWith(".binlog", StringComparison.OrdinalIgnoreCase) ||
                        path.EndsWith(".buildlog", StringComparison.OrdinalIgnoreCase))
                    {
                        var invocations = BinLogCompilerInvocationsReader.ExtractInvocations(path);
                        foreach (var invocation in invocations)
                        {
                            if (Path.GetFileName(invocation.ProjectDirectory) == "ref")
                            {
                                Log.Write($"Skipping Ref Assembly project {invocation.ProjectFilePath}");
                                continue;
                            }

                            if (Path.GetFileName(Path.GetDirectoryName(invocation.ProjectDirectory)) == "cycle-breakers")
                            {
                                Log.Write($"Skipping Wpf Cycle-Breaker project {invocation.ProjectFilePath}");
                                continue;
                            }
                            Log.Write($"Indexing Project: {invocation.ProjectFilePath}");
                            GenerateFromBuildLog.GenerateInvocation(
                                invocation,
                                serverPathMappings,
                                processedAssemblyList,
                                assemblyNames,
                                mergedSolutionExplorerRoot,
                                typeForwards);
                        }

                        continue;
                    }

                    using (var solutionGenerator = new SolutionGenerator(
                               path,
                               Paths.SolutionDestinationFolder,
                               properties: properties.ToImmutableDictionary(),
                               federation: federation,
                               serverPathMappings: serverPathMappings,
                               pluginBlacklist: pluginBlacklist,
                               doNotIncludeReferencedProjects: doNotIncludeReferencedProjects,
                               typeForwards: typeForwards))
                    {
                        solutionGenerator.GlobalAssemblyList = assemblyNames;
                        solutionGenerator.Generate(processedAssemblyList, mergedSolutionExplorerRoot);
                    }
                }

                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
            }
        }
Пример #22
0
        private static void IndexSolutions(
            IEnumerable <string> solutionFilePaths,
            Dictionary <string, string> properties,
            Federation federation,
            Dictionary <string, string> serverPathMappings,
            IEnumerable <string> pluginBlacklist,
            bool doNotIncludeReferencedProjects = false)
        {
            var assemblyNames = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            foreach (var path in solutionFilePaths)
            {
                using (Disposable.Timing("Reading assembly names from " + path))
                {
                    foreach (var assemblyName in GetAssemblyNames(path))
                    {
                        assemblyNames.Add(assemblyName);
                    }
                }
            }

            var processedAssemblyList = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            foreach (var path in solutionFilePaths)
            {
                using (Disposable.Timing("Generating " + path))
                {
                    if (path.EndsWith(".binlog", StringComparison.OrdinalIgnoreCase) ||
                        path.EndsWith(".buildlog", StringComparison.OrdinalIgnoreCase))
                    {
                        var invocations = BinLogCompilerInvocationsReader.ExtractInvocations(path);
                        foreach (var invocation in invocations)
                        {
                            GenerateFromBuildLog.GenerateInvocation(
                                invocation,
                                serverPathMappings,
                                processedAssemblyList,
                                assemblyNames,
                                mergedSolutionExplorerRoot);
                        }

                        continue;
                    }

                    using (var solutionGenerator = new SolutionGenerator(
                               path,
                               Paths.SolutionDestinationFolder,
                               hostingPrefix: "/tools/game-scripts/",
                               properties: properties.ToImmutableDictionary(),
                               federation: federation,
                               serverPathMappings: serverPathMappings,
                               pluginBlacklist: pluginBlacklist,
                               doNotIncludeReferencedProjects: doNotIncludeReferencedProjects))
                    {
                        solutionGenerator.GlobalAssemblyList = assemblyNames;
                        solutionGenerator.Generate(processedAssemblyList, mergedSolutionExplorerRoot);
                    }
                }

                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
            }
        }
Пример #23
0
        private static void IndexSolutions(
            IEnumerable <string> solutionFilePaths,
            IReadOnlyDictionary <string, string> properties,
            Federation federation,
            IReadOnlyDictionary <string, string> serverPathMappings,
            IEnumerable <string> pluginBlacklist,
            bool doNotIncludeReferencedProjects = false,
            string rootPath = null)
        {
            var assemblyNames = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            foreach (var path in solutionFilePaths)
            {
                using (Disposable.Timing("Reading assembly names from " + path))
                {
                    foreach (var assemblyName in GetAssemblyNames(path))
                    {
                        assemblyNames.Add(assemblyName);
                    }
                }
            }

            var processedAssemblyList = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            foreach (var path in solutionFilePaths)
            {
                var solutionFolder = mergedSolutionExplorerRoot;

                if (rootPath is object)
                {
                    var relativePath = Paths.MakeRelativeToFolder(Path.GetDirectoryName(path), rootPath);
                    var segments     = relativePath.Split(new[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);

                    foreach (var segment in segments)
                    {
                        solutionFolder = solutionFolder.GetOrCreateFolder(segment);
                    }
                }

                using (Disposable.Timing("Generating " + path))
                {
                    if (path.EndsWith(".binlog", StringComparison.OrdinalIgnoreCase) ||
                        path.EndsWith(".buildlog", StringComparison.OrdinalIgnoreCase))
                    {
                        var invocations = BinLogCompilerInvocationsReader.ExtractInvocations(path);
                        foreach (var invocation in invocations)
                        {
                            GenerateFromBuildLog.GenerateInvocation(
                                invocation,
                                serverPathMappings,
                                processedAssemblyList,
                                assemblyNames,
                                solutionFolder);
                        }

                        continue;
                    }

                    using (var solutionGenerator = new SolutionGenerator(
                               path,
                               Paths.SolutionDestinationFolder,
                               properties: properties.ToImmutableDictionary(),
                               federation: federation,
                               serverPathMappings: serverPathMappings,
                               pluginBlacklist: pluginBlacklist,
                               doNotIncludeReferencedProjects: doNotIncludeReferencedProjects))
                    {
                        solutionGenerator.GlobalAssemblyList = assemblyNames;
                        solutionGenerator.Generate(processedAssemblyList, solutionFolder);
                    }
                }

                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
            }
        }
Пример #24
0
        public void GenerateExternalReferences(HashSet<string> assemblyList)
        {
            var externalReferences = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

            //Extend.ExtendGenerator.ExternalReferencesPrepare(this, assemblyList);

            foreach (var project in solution.Projects)
            {
                var references = project.MetadataReferences
                    .OfType<PortableExecutableReference>()
                    .Where(m => File.Exists(m.FilePath))
                    .Where(m => !assemblyList.Contains(Path.GetFileNameWithoutExtension(m.FilePath)))
                    .Where(m => !IsPartOfSolution(Path.GetFileNameWithoutExtension(m.FilePath)))
                    .Where(m => GetExternalAssemblyIndex(Path.GetFileNameWithoutExtension(m.FilePath)) == -1)
                    .Select(m => Path.GetFullPath(m.FilePath));

                foreach (var reference in references)
                {
                    externalReferences[Path.GetFileNameWithoutExtension(reference)] = reference;
                }
            }

            foreach (var externalReference in externalReferences)
            {
                Log.Write(externalReference.Key, ConsoleColor.Magenta);
                var solutionGenerator = new SolutionGenerator(
                    externalReference.Value,
                    Paths.SolutionDestinationFolder);

                solutionGenerator.Generate(assemblyList);

                Extend.ExtendGenerator.ExternalReferences(solutionGenerator, assemblyList);
            }
        }