ScriptProjectAnalysisResult(Project project, MDKProjectProperties projectProperties) { Project = project; ProjectProperties = projectProperties; IsScriptProject = true; IsValid = true; }
/// <summary> /// Creates a new instance of <see cref="ScriptProjectAnalysisResult_Legacy"/> /// </summary> /// <param name="project"></param> /// <param name="projectProperties">Basic information about the analyzed project</param> /// <param name="propsDocument">The source XML document of the MDK props file</param> /// <param name="whitelist">Whitelist verification results</param> /// <param name="badReferences">A list of bad file- or assembly references</param> /// <param name="hasValidGamePath"></param> public ScriptProjectAnalysisResult_Legacy(EnvDTE.Project project, MDKProjectProperties projectProperties, XDocument propsDocument, WhitelistReference whitelist, ImmutableArray <BadReference> badReferences, bool hasValidGamePath) { Project = project; ProjectProperties = projectProperties; PropsDocument = propsDocument; BadReferences = badReferences; Whitelist = whitelist; IsScriptProject = projectProperties != null; HasValidGamePath = hasValidGamePath; IsValid = BadReferences.Length == 0 && whitelist.IsValid && hasValidGamePath; }
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));
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.")); } }
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); }
public static ScriptProjectAnalysisResult For(Project project, MDKProjectProperties projectInfo) { return(new ScriptProjectAnalysisResult(project, projectInfo)); }