ScriptProjectAnalysisResult_Legacy AnalyzeProject(Project project, ScriptUpgradeAnalysisOptions options) { if (!project.IsLoaded()) { return(ScriptProjectAnalysisResult_Legacy.NonScriptProjectResult); } var projectInfo = MDKProjectProperties.Load(project.FullName, project.Name); if (!projectInfo.IsValid) { return(ScriptProjectAnalysisResult_Legacy.NonScriptProjectResult); } if (projectInfo.Options.Version < new Version(1, 2)) { return(new ScriptProjectAnalysisResult_Legacy(project, projectInfo, null, default, ImmutableArray <BadReference> .Empty, false));
ScriptProjectAnalysisResult AnalyzeProject(Project project, ScriptUpgradeAnalysisOptions options) { if (!project.IsLoaded()) { return(ScriptProjectAnalysisResult.NotAScriptProject); } var projectInfo = MDKProjectProperties.Load(project.FullName, project.Name); if (!projectInfo.IsValid) { return(ScriptProjectAnalysisResult.NotAScriptProject); } if (projectInfo.Options.Version < new Version(1, 2)) { return(ScriptProjectAnalysisResult.For(project, projectInfo).AsLegacyProject()); } return(ScriptProjectAnalysisResult.For(project, projectInfo)); }
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); }