public static Result <IProject> GetOrCreateProjectFromVisualStudioSolution(string slnAbsolutePath, string outputDirectory, string outputFileName) { var ndependProjectPath = FileNameConventions.BuildNDependProjectFilePath(outputDirectory, outputFileName); if (File.Exists(ndependProjectPath)) { return(Result.Success(GetProjectFromNDependFile(ndependProjectPath))); } var ndependServicesProvider = new NDependServicesProvider(); List <IAbsoluteFilePath> assemblies = GetAssembliesFromSolution(slnAbsolutePath, ndependServicesProvider); if (!assemblies.Any()) { return(Result.Failure <IProject>("Could not find any assemblies for the solution. Please make sure that the solution is built before running the CodeAnalyzer")); } var projectManager = ndependServicesProvider.ProjectManager; var project = projectManager.CreateBlankProject( ndependProjectPath.ToAbsoluteFilePath(), outputFileName); project.CodeToAnalyze.SetApplicationAssemblies(assemblies); projectManager.SaveProject(project); return(Result.Success(project)); }
private static void HandleDesignSmells( ICodeBase codeBase, string outputDirectory, string outputFileName, ILogger logger) { List <DesignSmell> designSmells = new DesignSmellsDetection(logger).Detect(codeBase).ToList(); var designSmellsOutputFile = FileNameConventions.BuildDesignSmellsOutputFile(outputDirectory, outputFileName); DesignSmellsJsonWriter.Export(designSmells, designSmellsOutputFile); }
private static void HandleStructuralRelations( ICodeBase analysisResultCodeBase, string outputDirectory, string outputFileName, ILogger logger) { var relations = new StructuralRelationsBuilder(logger).GetStructuralRelations(analysisResultCodeBase); var structuralRelationsOutputFile = FileNameConventions.BuildStructuralRelationsOutputFile(outputDirectory, outputFileName); StructuralRelationCsvWriter.Export(relations, structuralRelationsOutputFile); }
private static void MainSub(string topLevelFolder, string outputDirectory) { outputDirectory = EnsureAbsolutePath(outputDirectory); var slnFiles = GetAllVisualStudioSolutionsInFolder(topLevelFolder); foreach (var slnFile in slnFiles) { var outputFileName = FileNameConventions.BuildOutputFileName(topLevelFolder, slnFile); HandleProject(slnFile, outputDirectory, outputFileName); } Console.WriteLine("Finished running the analysis. Press any key to exit..."); Console.ReadKey(); }