Exemplo n.º 1
0
        public static int CheckProject(ProgamOptions options)
        {
            var fileSystem = new FileSystem();
            var globalReferencesRegistry = new ReferenceRegistry();
            string[] projectFileNames = new string[0];

            var severity = (ReportSeverity)Enum.Parse(typeof (ReportSeverity), options.Verbosity, true);

            if (!String.IsNullOrEmpty(options.GlobalReferencesFileName)
                && fileSystem.FileInfo.FromFileName(options.GlobalReferencesFileName).Exists)
            {
                globalReferencesRegistry = ReferenceRegistry.FromLinesInFile(options.GlobalReferencesFileName, fileSystem);
            }
            else if (options.GlobalReferences.Length > 0)
            {
                globalReferencesRegistry = ReferenceRegistry.FromReferenceNames(options.GlobalReferences);
            }

            if (!String.IsNullOrEmpty(options.ProjectFileNamesFile)
                && fileSystem.FileInfo.FromFileName(options.ProjectFileNamesFile).Exists)
            {
                projectFileNames = fileSystem.File.ReadAllLines(options.ProjectFileNamesFile);
            } 
            else if (options.ProjectFileNames.Length > 0)
            {
                projectFileNames = options.ProjectFileNames;
            }

            var externalLibrariesDirectoryName = options.ExternalLibrariesDirectoryName;

            var integrity = new ProjectIntegrity(globalReferencesRegistry, externalLibrariesDirectoryName);
            
            bool hasError = projectFileNames
                .Select(projectFileName =>
                    OutputReports(
                        integrity.Report(projectFileName),
                        OutputProjectFileName,
                        projectFileName, severity))
                .Aggregate(false, (current, reports) => current || reports.Any(r => !r.IsOk));

            if (!hasError && severity <= ReportSeverity.Error)
            {
                Console.WriteLine("[ Check ] All projects ok.");
            }

            return hasError ? ExitCode.Error : ExitCode.Ok;
        }
 public BinaryReferenceIsGlobalCheck(ReferenceRegistry globalReferencesRegistry)
 {
     this.globalReferences = globalReferencesRegistry.References;
 }
Exemplo n.º 3
0
 public ProjectIntegrityCheck(IFileSystem fileSystem, ReferenceRegistry wellknownReferencesRegistry, string libDirectory)
 {
     this.refGlobal = new BinaryReferenceIsGlobalCheck(wellknownReferencesRegistry);
     this.refExists = new ReferenceExistsCheck(fileSystem);
     this.refExternal = new BinaryReferenceInExternalLibrariesDirectoryCheck(libDirectory);
 }