public AnalysisPhaseResult LoadApplication(string companyAssembliesPattern, ApplicationDetails application) { try { var assembliesFolder = AssemblyPathFinder.GetAssembliesFolder(application.FullFolderPath); if (assembliesFolder == null) { return(AnalysisPhaseResult.CouldNotFindBinFolder); } var companyAssembliesInFolder = AssemblyPathFinder.GetCompanyAssemblies(companyAssembliesPattern, assembliesFolder); if (!companyAssembliesInFolder.Any()) { return(AnalysisPhaseResult.NoCompanyDllsFound); } AnalysisScope.ApplicationAssemblies = companyAssembliesInFolder; EmptyIndexes(); foreach (var companyAssembly in companyAssembliesInFolder) { var module = DecompilerService.GetModuleDefinition(assembliesFolder, companyAssembly); _modulesToAnalyze.Add(module); } foreach (var module in _modulesToAnalyze) { if (!_assembliesProcessed.Contains(module.Assembly.FullName)) { _assembliesProcessed.Add(module.Assembly.FullName); _assignmentGraphIndexer.IndexTriples(module); _methodIndexer.Load(module); } } _delegateIndexer.Load(_modulesToAnalyze); _methodIndexer.BuildMethodObjects(application.CsProjName); _typeService.Load(_modulesToAnalyze); return(AnalysisPhaseResult.Success); } catch (Exception ex) { _logOutput.LogError("Failed analyzing application. ", ex); return(AnalysisPhaseResult.Failed); } }
private List <ApplicationDetails> GetApplicationDetails(string solutionFolder, string solutionFilePath, string applicationsPattern) { var applicationFolders = AssemblyPathFinder.GetApplicationFolders(solutionFolder, applicationsPattern); var fileLines = File.ReadAllLines(solutionFilePath); var declaredApplications = new List <ApplicationDetails>(); foreach (var line in fileLines.Where(x => x.StartsWith("Project") && x.IndexOf("csproj") > -1)) { var afterEquals = line.Substring(line.IndexOf("=") + 1); int counter = 0; int startIndex = 0; int endIndex = 0; for (int i = 0; i < afterEquals.Length; i++) { var letter = afterEquals[i]; if (letter == '"') { counter++; if (counter == 3) { startIndex = i + 1; } else if (counter == 4) { endIndex = i - 1; } } } var targetText = afterEquals.Substring(startIndex, endIndex - startIndex + 1); int slashIndex = targetText.LastIndexOf("\\"); if (slashIndex > -1) { var folderName = targetText.Substring(0, slashIndex); if (folderName.IndexOf("\\") > -1) { folderName = folderName.Substring(folderName.LastIndexOf("\\")); } var projectName = targetText.Substring(slashIndex + 1).Replace(".csproj", ""); var appFolderMatch = applicationFolders.SingleOrDefault(x => x.Contains(folderName) && x.Contains(projectName)); if (!string.IsNullOrEmpty(appFolderMatch)) { var appDetails = new ApplicationDetails(); appDetails.CsProjName = projectName; appDetails.FolderName = folderName; appDetails.FullFolderPath = appFolderMatch; declaredApplications.Add(appDetails); } else { // for debugging } } } var deduplicatedFullList = declaredApplications.GroupBy(x => x.CsProjName).Select(x => x.First()).ToList(); return(deduplicatedFullList); }