Beispiel #1
0
 HealthAnalysis(Project project, MDKProjectProperties properties, HealthAnalysisOptions analysisOptions)
 {
     Project = project;
     try
     {
         FileName = project.FileName;
     }
     catch (NotImplementedException)
     {
         // Ignored. Ugly but necessary hack.
     }
     Properties      = properties;
     AnalysisOptions = analysisOptions;
     IsMDKProject    = properties != null;
     Problems        = new ReadOnlyCollection <HealthProblem>(_problems);
     if (!IsMDKProject)
     {
         _problems.Add(new HealthProblem(HealthCode.NotAnMDKProject, HealthSeverity.Critical, "This is not an MDK project."));
     }
 }
Beispiel #2
0
        static HealthAnalysis Analyze(Project project, HealthAnalysisOptions options)
        {
            if (!project.IsLoaded())
            {
                return(new HealthAnalysis(project, null, options));
            }
            var projectInfo = MDKProjectProperties.Load(project.FullName, project.Name);

            if (!projectInfo.IsValid && !(projectInfo.Options?.IsValid ?? false))
            {
                return(new HealthAnalysis(project, null, options));
            }

            var analysis = new HealthAnalysis(project, projectInfo, options);

            if (projectInfo.Options.Version < new Version(1, 2))
            {
                analysis._problems.Add(new HealthProblem(HealthCode.Outdated, HealthSeverity.Critical, "This project format is outdated."));
            }

            var whitelistFileName = Path.Combine(Path.GetDirectoryName(project.FullName), "mdk\\whitelist.cache");

            if (!projectInfo.Paths.IsValid)
            {
                analysis._problems.Add(new HealthProblem(HealthCode.MissingPathsFile, HealthSeverity.Critical, "Missing paths file"));
            }
            else
            {
                var installPath         = projectInfo.Paths.InstallPath.TrimEnd('/', '\\');
                var expectedInstallPath = options.InstallPath.TrimEnd('/', '\\');

                if (!string.Equals(installPath, expectedInstallPath, StringComparison.CurrentCultureIgnoreCase))
                {
                    analysis._problems.Add(new HealthProblem(HealthCode.BadInstallPath, HealthSeverity.Warning, "Invalid install path"));
                }

                var vrageRef = Path.Combine(projectInfo.Paths.GameBinPath, "vrage.dll");
                if (!File.Exists(vrageRef))
                {
                    analysis._problems.Add(new HealthProblem(HealthCode.BadGamePath, HealthSeverity.Critical, "Invalid game path"));
                }

                var outputPath = projectInfo.Paths.OutputPath.TrimEnd('/', '\\');
                if (!Directory.Exists(outputPath))
                {
                    analysis._problems.Add(new HealthProblem(HealthCode.BadOutputPath, HealthSeverity.Warning, "Invalid output path"));
                }

                var whitelistCacheFileName = Path.Combine(expectedInstallPath, "Analyzers\\whitelist.cache");
                if (File.Exists(whitelistCacheFileName))
                {
                    var cacheDate   = File.GetLastWriteTime(whitelistCacheFileName);
                    var currentDate = File.GetLastWriteTime(whitelistFileName);
                    if (cacheDate > currentDate)
                    {
                        analysis._problems.Add(new HealthProblem(HealthCode.OutdatedWhitelist, HealthSeverity.Warning, "The whitelist cache must be updated"));
                    }
                }
            }

            if (!File.Exists(whitelistFileName))
            {
                analysis._problems.Add(new HealthProblem(HealthCode.MissingWhitelist, HealthSeverity.Critical, "Missing Whitelist Cache"));
            }

            return(analysis);
        }
Beispiel #3
0
 /// <summary>
 /// Analyze an entire solution's worth of projects
 /// </summary>
 /// <param name="solution"></param>
 /// <param name="options"></param>
 /// <returns></returns>
 public static Task <HealthAnalysis[]> AnalyzeAsync(Solution solution, HealthAnalysisOptions options) => System.Threading.Tasks.Task.WhenAll(solution.Projects.Cast <Project>().Select(project => System.Threading.Tasks.Task.Run(() => Analyze(project, options))));
Beispiel #4
0
 /// <summary>
 /// Analyze an individual project
 /// </summary>
 /// <param name="project"></param>
 /// <param name="options"></param>
 /// <returns></returns>
 public static Task <HealthAnalysis> AnalyzeAsync(Project project, HealthAnalysisOptions options) => System.Threading.Tasks.Task.Run(() => Analyze(project, options));