Exemplo n.º 1
0
        public override bool Execute()
        {
#if DEBUG
            if (System.Environment.GetEnvironmentVariable("DEBUG_SCAN_LIBS_TASK") == "1")
            {
                System.Diagnostics.Debugger.Launch();
            }
#endif

            string[]      libFiles      = this.GetLibs();
            var           functionNames = new HashSet <string>(System.StringComparer.OrdinalIgnoreCase);
            StringBuilder libLines      = new StringBuilder();
            foreach (var lib in libFiles)
            {
                var importInfos = LibScraper.GetImportInfos(lib);
                foreach (var importInfo in importInfos)
                {
                    string procName = importInfo.ProcName;
                    if (!functionNames.Contains(procName))
                    {
                        if (libLines.Length == 0)
                        {
                            libLines.AppendLine("--with-librarypath");
                        }

                        var dllName = Path.GetFileNameWithoutExtension(importInfo.Dll);

                        libLines.AppendLine($"{procName}={dllName}");
                        functionNames.Add(procName);
                    }
                }
            }

            if (libLines.Length != 0)
            {
                var dir = Path.GetDirectoryName(this.WithLibsRsp);
                Directory.CreateDirectory(dir);

                File.WriteAllText(this.WithLibsRsp, libLines.ToString());
            }
            else
            {
                if (File.Exists(this.WithLibsRsp))
                {
                    File.Delete(this.WithLibsRsp);
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        public void Returns_Expected_Infos(string libPath, IEnumerable <ImportInfo> expectedImportInfos)
        {
            var infos = LibScraper.GetImportInfos(libPath);

            Assert.Equal(expectedImportInfos, infos);
        }