Ejemplo n.º 1
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();
            }
        }
Ejemplo n.º 2
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();
            }
        }
Ejemplo n.º 3
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();
            }
        }