From d6e0d271736eaf4ccce0f28d442bccb20c304769 Mon Sep 17 00:00:00 2001 From: Morten Aune Lyrstad <4653628+malware-dev@users.noreply.github.com> Date: Mon, 1 May 2023 11:47:19 +0200 Subject: [PATCH] Fixed a bunch of annoying 3rd party reference problems, and improved the project upgrade tool. --- .../.idea.Malware's Dev Kit/.idea/.gitignore | 13 ++ .../.idea/.idea.Malware's Dev Kit/.idea/.name | 1 + .../.idea/encodings.xml | 4 + .../.idea/indexLayout.xml | 8 + .../.idea.Malware's Dev Kit/.idea/vcs.xml | 6 + Source/MDK/MDK.csproj | 8 +- Source/MDK/Resources/Text.Designer.cs | 11 +- Source/MDK/Resources/Text.resx | 3 + .../Views/ProjectHealth/Fixes/BackupFix.cs | 24 +-- .../Fixes/BadDotNetVersionFix.cs | 35 ++++ .../ProjectHealth/Fixes/BadGamePathFix.cs | 7 +- .../ProjectHealth/Fixes/BadInstallPathFix.cs | 13 +- .../ProjectHealth/Fixes/BadOutputPathFix.cs | 6 +- .../ProjectHealth/Fixes/DeleteBinObjFix.cs | 39 +++++ Source/MDK/Views/ProjectHealth/Fixes/Fix.cs | 37 +++-- .../Fixes/MissingOrOutdatedWhitelistFix.cs | 4 +- .../Fixes/MissingPathsFileFix.cs | 9 +- .../Views/ProjectHealth/Fixes/OutdatedFix.cs | 15 +- .../ProjectHealth/ProjectHealthDialogModel.cs | 17 +- Source/MDK/app.config | 153 +----------------- Source/MDK/source.extension.vsixmanifest | 4 +- .../MDKAnalyzer/AnalyzerReleases.Shipped2.md | 3 + .../AnalyzerReleases.Unshipped2.md | 3 + Source/MDKAnalyzer/MDKAnalyzer.csproj | 1 + Source/MDKServices/HealthAnalysis.cs | 7 + Source/MDKServices/HealthCode.cs | 7 +- Source/MDKServices/MDKServices.csproj | 6 - Source/MDKServices/app.config | 37 +---- .../MDKWhitelistExtractor.csproj | 2 +- Source/Malware's Dev Kit - 22.sln | 114 ------------- Source/Malware's Dev Kit - 22.sln.DotSettings | 8 - 31 files changed, 235 insertions(+), 370 deletions(-) create mode 100644 Source/.idea/.idea.Malware's Dev Kit/.idea/.gitignore create mode 100644 Source/.idea/.idea.Malware's Dev Kit/.idea/.name create mode 100644 Source/.idea/.idea.Malware's Dev Kit/.idea/encodings.xml create mode 100644 Source/.idea/.idea.Malware's Dev Kit/.idea/indexLayout.xml create mode 100644 Source/.idea/.idea.Malware's Dev Kit/.idea/vcs.xml create mode 100644 Source/MDK/Views/ProjectHealth/Fixes/BadDotNetVersionFix.cs create mode 100644 Source/MDK/Views/ProjectHealth/Fixes/DeleteBinObjFix.cs create mode 100644 Source/MDKAnalyzer/AnalyzerReleases.Shipped2.md create mode 100644 Source/MDKAnalyzer/AnalyzerReleases.Unshipped2.md delete mode 100644 Source/Malware's Dev Kit - 22.sln delete mode 100644 Source/Malware's Dev Kit - 22.sln.DotSettings diff --git a/Source/.idea/.idea.Malware's Dev Kit/.idea/.gitignore b/Source/.idea/.idea.Malware's Dev Kit/.idea/.gitignore new file mode 100644 index 0000000..58b6405 --- /dev/null +++ b/Source/.idea/.idea.Malware's Dev Kit/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/projectSettingsUpdater.xml +/contentModel.xml +/.idea.Malware's Dev Kit.iml +/modules.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/Source/.idea/.idea.Malware's Dev Kit/.idea/.name b/Source/.idea/.idea.Malware's Dev Kit/.idea/.name new file mode 100644 index 0000000..8d834bd --- /dev/null +++ b/Source/.idea/.idea.Malware's Dev Kit/.idea/.name @@ -0,0 +1 @@ +Malware's Dev Kit \ No newline at end of file diff --git a/Source/.idea/.idea.Malware's Dev Kit/.idea/encodings.xml b/Source/.idea/.idea.Malware's Dev Kit/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/Source/.idea/.idea.Malware's Dev Kit/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Source/.idea/.idea.Malware's Dev Kit/.idea/indexLayout.xml b/Source/.idea/.idea.Malware's Dev Kit/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/Source/.idea/.idea.Malware's Dev Kit/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Source/.idea/.idea.Malware's Dev Kit/.idea/vcs.xml b/Source/.idea/.idea.Malware's Dev Kit/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/Source/.idea/.idea.Malware's Dev Kit/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Source/MDK/MDK.csproj b/Source/MDK/MDK.csproj index 6365216..a66d356 100644 --- a/Source/MDK/MDK.csproj +++ b/Source/MDK/MDK.csproj @@ -11,6 +11,9 @@ true + + 7.3 + Key.snk @@ -135,9 +138,11 @@ + + @@ -404,9 +409,6 @@ compile; build; native; contentfiles; analyzers; buildtransitive - - 17.5.22 - runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/Source/MDK/Resources/Text.Designer.cs b/Source/MDK/Resources/Text.Designer.cs index a0366cf..d85b958 100644 --- a/Source/MDK/Resources/Text.Designer.cs +++ b/Source/MDK/Resources/Text.Designer.cs @@ -19,7 +19,7 @@ namespace MDK.Resources { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Text { @@ -60,6 +60,15 @@ internal Text() { } } + /// + /// Looks up a localized string similar to Unable to specify .NET version 4.8 because the project has no such property.. + /// + internal static string BadDotNetVersionFix_Apply_NoTargetFrameworkProperty { + get { + return ResourceManager.GetString("BadDotNetVersionFix_Apply_NoTargetFrameworkProperty", resourceCulture); + } + } + /// /// Looks up a localized string similar to No MDK Projects. /// diff --git a/Source/MDK/Resources/Text.resx b/Source/MDK/Resources/Text.resx index 6ca68a2..0df1e2b 100644 --- a/Source/MDK/Resources/Text.resx +++ b/Source/MDK/Resources/Text.resx @@ -321,4 +321,7 @@ The upgrade process has been completed. It is recommended to restart Visual Studio in order to reload the extensions and analyzers. + + Unable to specify .NET version 4.8 because the project has no such property. + \ No newline at end of file diff --git a/Source/MDK/Views/ProjectHealth/Fixes/BackupFix.cs b/Source/MDK/Views/ProjectHealth/Fixes/BackupFix.cs index 54f588a..f1d0083 100644 --- a/Source/MDK/Views/ProjectHealth/Fixes/BackupFix.cs +++ b/Source/MDK/Views/ProjectHealth/Fixes/BackupFix.cs @@ -3,6 +3,7 @@ using System.IO.Compression; using System.Linq; using Malware.MDKServices; +using System.Threading.Tasks; namespace MDK.Views.ProjectHealth.Fixes { @@ -87,18 +88,21 @@ static bool NeedsBackup(HealthProblem healthProblem) public BackupFix() : base(0, HealthCode.Healthy) { } - public override void Apply(HealthAnalysis analysis, FixStatus status) + public override async Task ApplyAsync(HealthAnalysis analysis, FixStatus status) { status.Description = "Creating a backup in the parent folder..."; - var directory = Path.GetDirectoryName(analysis.FileName) ?? ".\\"; - if (!directory.EndsWith("\\")) - directory += "\\"; - var zipFileName = $"{Path.GetFileNameWithoutExtension(analysis.FileName)}_Backup_{DateTime.Now:yyyy-MM-dd-HHmmssfff}.zip"; - var tmpZipName = Path.Combine(Path.GetTempPath(), zipFileName); - ZipHelper.CreateFromDirectory(directory, tmpZipName, CompressionLevel.Fastest, false, path => OnlyInterestingFiles(directory, path)); - var backupDirectory = new DirectoryInfo(Path.Combine(directory, "..\\")); - File.Copy(tmpZipName, Path.Combine(backupDirectory.FullName, zipFileName)); - File.Delete(tmpZipName); + await Task.Run(() => + { + var directory = Path.GetDirectoryName(analysis.FileName) ?? ".\\"; + if (!directory.EndsWith("\\")) + directory += "\\"; + var zipFileName = $"{Path.GetFileNameWithoutExtension(analysis.FileName)}_Backup_{DateTime.Now:yyyy-MM-dd-HHmmssfff}.zip"; + var tmpZipName = Path.Combine(Path.GetTempPath(), zipFileName); + ZipHelper.CreateFromDirectory(directory, tmpZipName, CompressionLevel.Fastest, false, path => OnlyInterestingFiles(directory, path)); + var backupDirectory = new DirectoryInfo(Path.Combine(directory, "..\\")); + File.Copy(tmpZipName, Path.Combine(backupDirectory.FullName, zipFileName)); + File.Delete(tmpZipName); + }); status.Description = "Backup created"; } diff --git a/Source/MDK/Views/ProjectHealth/Fixes/BadDotNetVersionFix.cs b/Source/MDK/Views/ProjectHealth/Fixes/BadDotNetVersionFix.cs new file mode 100644 index 0000000..1e78405 --- /dev/null +++ b/Source/MDK/Views/ProjectHealth/Fixes/BadDotNetVersionFix.cs @@ -0,0 +1,35 @@ +using Malware.MDKServices; +using Microsoft.VisualStudio.Shell; +using System.Linq; +using System.Threading.Tasks; +using System.Xml.Linq; + +namespace MDK.Views.ProjectHealth.Fixes +{ + class BadDotNetVersionFix: Fix + { + const string Xmlns = "http://schemas.microsoft.com/developer/msbuild/2003"; + static readonly XName PropertyGroup = XName.Get("PropertyGroup", Xmlns); + static readonly XName TargetFrameworkVersion = XName.Get("TargetFrameworkVersion", Xmlns); + + public BadDotNetVersionFix(): base(2000, HealthCode.BadDotNetVersion) { } + + public override async Task ApplyAsync(HealthAnalysis analysis, FixStatus status) + { + await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); + status.Description = "Specifying .NET 4.8"; + var document = XDocument.Load(analysis.FileName); + var targetFrameworkElement = document.Root?.Elements(PropertyGroup).Select(e => e.Element(TargetFrameworkVersion)).FirstOrDefault(); + if (targetFrameworkElement?.Value.Trim() != "v4.8") + targetFrameworkElement.Value = "v4.8"; + { + var relativeGroup = document.Root.Elements(PropertyGroup).LastOrDefault(); + if (relativeGroup != null) + relativeGroup.AddAfterSelf(new XElement(PropertyGroup, new XElement(TargetFrameworkVersion, "v4.8"))); + else + document.Root.Add(new XElement(PropertyGroup, new XElement(TargetFrameworkVersion, "v4.8"))); + } + document.Save(analysis.FileName); + } + } +} \ No newline at end of file diff --git a/Source/MDK/Views/ProjectHealth/Fixes/BadGamePathFix.cs b/Source/MDK/Views/ProjectHealth/Fixes/BadGamePathFix.cs index ac72776..3f99f5d 100644 --- a/Source/MDK/Views/ProjectHealth/Fixes/BadGamePathFix.cs +++ b/Source/MDK/Views/ProjectHealth/Fixes/BadGamePathFix.cs @@ -1,6 +1,6 @@ using System.IO; using Malware.MDKServices; -using Malware.MDKUtilities; +using System.Threading.Tasks; namespace MDK.Views.ProjectHealth.Fixes { @@ -8,7 +8,7 @@ class BadGamePathFix : Fix { public BadGamePathFix() : base(3000, HealthCode.BadGamePath) { } - public override void Apply(HealthAnalysis analysis, FixStatus status) + public override Task ApplyAsync(HealthAnalysis analysis, FixStatus status) { status.Description = "Fixing bad game path"; var path = analysis.AnalysisOptions.DefaultGameBinPath; @@ -16,12 +16,13 @@ public override void Apply(HealthAnalysis analysis, FixStatus status) { status.Description = "Cannot find game path"; status.Failed = true; - return; + return Task.CompletedTask; } analysis.Properties.Paths.GameBinPath = path; analysis.Properties.Paths.Save(); status.Description = "Fixed bad game path"; + return Task.CompletedTask; } } } diff --git a/Source/MDK/Views/ProjectHealth/Fixes/BadInstallPathFix.cs b/Source/MDK/Views/ProjectHealth/Fixes/BadInstallPathFix.cs index 68a3c4a..714f1e2 100644 --- a/Source/MDK/Views/ProjectHealth/Fixes/BadInstallPathFix.cs +++ b/Source/MDK/Views/ProjectHealth/Fixes/BadInstallPathFix.cs @@ -1,22 +1,19 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using Malware.MDKServices; using System.Threading.Tasks; -using Malware.MDKServices; namespace MDK.Views.ProjectHealth.Fixes { class BadInstallPathFix: Fix { - public BadInstallPathFix() : base(3000, HealthCode.BadInstallPath) { } + public BadInstallPathFix(): base(3000, HealthCode.BadInstallPath) { } - public override void Apply(HealthAnalysis analysis, FixStatus status) + public override Task ApplyAsync(HealthAnalysis analysis, FixStatus status) { status.Description = "Fixing bad install path"; analysis.Properties.Paths.InstallPath = analysis.AnalysisOptions.InstallPath; analysis.Properties.Paths.Save(); status.Description = "Fixed bad install path"; + return Task.CompletedTask; } } -} +} \ No newline at end of file diff --git a/Source/MDK/Views/ProjectHealth/Fixes/BadOutputPathFix.cs b/Source/MDK/Views/ProjectHealth/Fixes/BadOutputPathFix.cs index d8c7e0d..b3950dd 100644 --- a/Source/MDK/Views/ProjectHealth/Fixes/BadOutputPathFix.cs +++ b/Source/MDK/Views/ProjectHealth/Fixes/BadOutputPathFix.cs @@ -1,5 +1,6 @@ using System.IO; using Malware.MDKServices; +using System.Threading.Tasks; namespace MDK.Views.ProjectHealth.Fixes { @@ -7,7 +8,7 @@ class BadOutputPathFix : Fix { public BadOutputPathFix() : base(3000, HealthCode.BadOutputPath) { } - public override void Apply(HealthAnalysis analysis, FixStatus status) + public override Task ApplyAsync(HealthAnalysis analysis, FixStatus status) { status.Description = "Fixing bad output path"; var path = analysis.AnalysisOptions.DefaultOutputPath; @@ -15,12 +16,13 @@ public override void Apply(HealthAnalysis analysis, FixStatus status) { status.Description = "Cannot find output path"; status.Failed = true; - return; + return Task.CompletedTask; } analysis.Properties.Paths.OutputPath = path; analysis.Properties.Paths.Save(); status.Description = "Fixed bad output path"; + return Task.CompletedTask; } } } diff --git a/Source/MDK/Views/ProjectHealth/Fixes/DeleteBinObjFix.cs b/Source/MDK/Views/ProjectHealth/Fixes/DeleteBinObjFix.cs new file mode 100644 index 0000000..ab64c83 --- /dev/null +++ b/Source/MDK/Views/ProjectHealth/Fixes/DeleteBinObjFix.cs @@ -0,0 +1,39 @@ +using Malware.MDKServices; +using System.IO; +using System.Threading.Tasks; + +namespace MDK.Views.ProjectHealth.Fixes +{ + class DeleteBinObjFix: Fix + { + public DeleteBinObjFix(): base(int.MaxValue) { } + + public override async Task ApplyAsync(HealthAnalysis analysis, FixStatus status) + { + status.Description = "Deleting bin/obj caches"; + await Task.Run(() => + { + var projectFolder = Path.GetDirectoryName(analysis.FileName)!; + var binFolder = Path.Combine(projectFolder, "bin"); + var objFolder = Path.Combine(projectFolder, "obj"); + try + { + Directory.Delete(binFolder, true); + } + catch + { + // Ignore this for now. + } + + try + { + Directory.Delete(objFolder, true); + } + catch + { + // Ignore this for now. + } + }); + } + } +} \ No newline at end of file diff --git a/Source/MDK/Views/ProjectHealth/Fixes/Fix.cs b/Source/MDK/Views/ProjectHealth/Fixes/Fix.cs index 1b89a52..d6dd9cb 100644 --- a/Source/MDK/Views/ProjectHealth/Fixes/Fix.cs +++ b/Source/MDK/Views/ProjectHealth/Fixes/Fix.cs @@ -1,10 +1,11 @@ -using System; +using Malware.MDKServices; +using MDK.Resources; +using System; using System.IO; using System.Linq; +using System.Threading.Tasks; using System.Xml; using System.Xml.Linq; -using Malware.MDKServices; -using MDK.Resources; namespace MDK.Views.ProjectHealth.Fixes { @@ -12,16 +13,33 @@ abstract class Fix { const string Xmlns = "http://schemas.microsoft.com/developer/msbuild/2003"; - protected Fix(int sortIndex, HealthCode code) + /// + /// Create a fix that is always applied. See + /// to make a healthcode violation specific fix. + /// + /// + /// + protected Fix(int sortIndex, bool needsLoadedProject = false): this(sortIndex, HealthCode.Healthy, needsLoadedProject) { } + + /// + /// Create a fix that is applied when a specific healthcode violation is detected. + /// See to make a fix that is always applied. + /// + /// + /// + /// + protected Fix(int sortIndex, HealthCode code, bool needsLoadedProject = false) { SortIndex = sortIndex; Code = code; + NeedsLoadedProject = needsLoadedProject; } public int SortIndex { get; } public HealthCode? Code { get; } + public bool NeedsLoadedProject { get; } - public abstract void Apply(HealthAnalysis analysis, FixStatus status); + public abstract Task ApplyAsync(HealthAnalysis analysis, FixStatus status); protected void Include(HealthAnalysis analysis, string fileName) { @@ -29,10 +47,7 @@ protected void Include(HealthAnalysis analysis, string fileName) XmlNameTable nameTable; using (var streamReader = File.OpenText(analysis.FileName)) { - var readerSettings = new XmlReaderSettings - { - IgnoreWhitespace = true - }; + var readerSettings = new XmlReaderSettings { IgnoreWhitespace = true }; var xmlReader = XmlReader.Create(streamReader, readerSettings); document = XDocument.Load(xmlReader); @@ -73,6 +88,6 @@ protected void Include(HealthAnalysis analysis, string fileName) document.Save(analysis.FileName); } - public virtual bool IsApplicableTo(HealthAnalysis project) => project.Problems.Any(p => p.Code == Code); + public virtual bool IsApplicableTo(HealthAnalysis project) => Code == HealthCode.Healthy || project.Problems.Any(p => p.Code == Code); } -} +} \ No newline at end of file diff --git a/Source/MDK/Views/ProjectHealth/Fixes/MissingOrOutdatedWhitelistFix.cs b/Source/MDK/Views/ProjectHealth/Fixes/MissingOrOutdatedWhitelistFix.cs index 3a13c44..535be58 100644 --- a/Source/MDK/Views/ProjectHealth/Fixes/MissingOrOutdatedWhitelistFix.cs +++ b/Source/MDK/Views/ProjectHealth/Fixes/MissingOrOutdatedWhitelistFix.cs @@ -2,6 +2,7 @@ using System.IO; using System.Linq; using Malware.MDKServices; +using System.Threading.Tasks; namespace MDK.Views.ProjectHealth.Fixes { @@ -9,7 +10,7 @@ class MissingOrOutdatedWhitelistFix : Fix { public MissingOrOutdatedWhitelistFix() : base(4000, HealthCode.MissingWhitelist) { } - public override void Apply(HealthAnalysis analysis, FixStatus status) + public override Task ApplyAsync(HealthAnalysis analysis, FixStatus status) { status.Description = "Restoring whitelist cache"; var sourceFileName = Path.Combine(analysis.Properties.Paths.InstallPath, "Analyzers\\whitelist.cache"); @@ -19,6 +20,7 @@ public override void Apply(HealthAnalysis analysis, FixStatus status) File.Copy(sourceFileName, targetFileName, true); Include(analysis, targetFileName); status.Description = "Restored whitelist cache"; + return Task.CompletedTask; } public override bool IsApplicableTo(HealthAnalysis project) => project.Problems.Any(p => p.Code == HealthCode.MissingWhitelist || p.Code == HealthCode.OutdatedWhitelist); diff --git a/Source/MDK/Views/ProjectHealth/Fixes/MissingPathsFileFix.cs b/Source/MDK/Views/ProjectHealth/Fixes/MissingPathsFileFix.cs index 17e37a0..7bbd3a2 100644 --- a/Source/MDK/Views/ProjectHealth/Fixes/MissingPathsFileFix.cs +++ b/Source/MDK/Views/ProjectHealth/Fixes/MissingPathsFileFix.cs @@ -1,9 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using Malware.MDKServices; using System.Threading.Tasks; -using Malware.MDKServices; namespace MDK.Views.ProjectHealth.Fixes { @@ -11,7 +7,7 @@ class MissingPathsFileFix: Fix { public MissingPathsFileFix() : base(2000, HealthCode.MissingPathsFile) { } - public override void Apply(HealthAnalysis analysis, FixStatus status) + public override Task ApplyAsync(HealthAnalysis analysis, FixStatus status) { status.Description = "Restoring missing paths file"; analysis.Properties.Paths.InstallPath = analysis.AnalysisOptions.InstallPath; @@ -23,6 +19,7 @@ public override void Apply(HealthAnalysis analysis, FixStatus status) analysis.Properties.Paths.AnalyzerReferences.Add(reference); analysis.Properties.Paths.Save(); status.Description = "Restored missing paths file"; + return Task.CompletedTask; } } } diff --git a/Source/MDK/Views/ProjectHealth/Fixes/OutdatedFix.cs b/Source/MDK/Views/ProjectHealth/Fixes/OutdatedFix.cs index 20d2b77..ac57b8d 100644 --- a/Source/MDK/Views/ProjectHealth/Fixes/OutdatedFix.cs +++ b/Source/MDK/Views/ProjectHealth/Fixes/OutdatedFix.cs @@ -1,20 +1,21 @@ -using System; -using Malware.MDKServices; +using Malware.MDKServices; using MDK.Resources; +using System; +using System.Threading.Tasks; namespace MDK.Views.ProjectHealth.Fixes { - class OutdatedFix : Fix + class OutdatedFix: Fix { - public OutdatedFix() : base(1000, HealthCode.Outdated) { } + public OutdatedFix(): base(1000, HealthCode.Outdated) { } - public override void Apply(HealthAnalysis analysis, FixStatus status) + public override async Task ApplyAsync(HealthAnalysis analysis, FixStatus status) { status.Description = "Upgrading outdated project format"; if (analysis.Properties.Options.Version < new Version(1, 2)) { var upgrader = new UpgradeFrom_1_1(); - upgrader.Upgrade(analysis); + await Task.Run(() => upgrader.Upgrade(analysis)); status.Description = "Project format updated"; return; } @@ -22,4 +23,4 @@ public override void Apply(HealthAnalysis analysis, FixStatus status) throw new InvalidOperationException(string.Format(Text.ProjectHealthDialogModel_Upgrade_BadUpgradeVersion, analysis.Properties.Options.Version)); } } -} +} \ No newline at end of file diff --git a/Source/MDK/Views/ProjectHealth/ProjectHealthDialogModel.cs b/Source/MDK/Views/ProjectHealth/ProjectHealthDialogModel.cs index bdd815a..d74cc04 100644 --- a/Source/MDK/Views/ProjectHealth/ProjectHealthDialogModel.cs +++ b/Source/MDK/Views/ProjectHealth/ProjectHealthDialogModel.cs @@ -26,9 +26,11 @@ public class ProjectHealthDialogModel: DialogViewModel new OutdatedFix(), new BadInstallPathFix(), new MissingPathsFileFix(), - new MissingOrOutdatedWhitelistFix(), new BadGamePathFix(), - new BadOutputPathFix() + new BadOutputPathFix(), + new BadDotNetVersionFix(), + new MissingOrOutdatedWhitelistFix(), + new DeleteBinObjFix() }.OrderBy(f => f.SortIndex).ToList(); string _okText = "Repair"; @@ -167,14 +169,21 @@ async void RunUpgrades() { var handle = project.Project.Unload(); var fixes = _fixes.Where(f => f.IsApplicableTo(project)); - foreach (var fix in fixes) + foreach (var fix in fixes.Where(f => !f.NeedsLoadedProject)) { var status = new FixStatus(); _fixStatuses.Add(status); - await Task.Run(() => fix.Apply(project, status)); + await fix.ApplyAsync(project, status); } await handle.ReloadAsync(); + + foreach (var fix in fixes.Where(f => f.NeedsLoadedProject)) + { + var status = new FixStatus(); + _fixStatuses.Add(status); + await fix.ApplyAsync(project, status); + } } _isCompleted = true; diff --git a/Source/MDK/app.config b/Source/MDK/app.config index c88133f..8a07a93 100644 --- a/Source/MDK/app.config +++ b/Source/MDK/app.config @@ -1,151 +1,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + \ No newline at end of file diff --git a/Source/MDK/source.extension.vsixmanifest b/Source/MDK/source.extension.vsixmanifest index 65cb7ec..8a4234c 100644 --- a/Source/MDK/source.extension.vsixmanifest +++ b/Source/MDK/source.extension.vsixmanifest @@ -1,7 +1,7 @@  - + MDK/SE A toolkit to help with ingame script (programmable block) development for Keen Software House's space sandbox Space Engineers. @@ -12,7 +12,7 @@ Space Engineers is trademarked to Keen Software House. This toolkit is fan-made, SpaceEngineers Space Engineers Programmable Block PB Ingame Script - + amd64 diff --git a/Source/MDKAnalyzer/AnalyzerReleases.Shipped2.md b/Source/MDKAnalyzer/AnalyzerReleases.Shipped2.md new file mode 100644 index 0000000..60b59dd --- /dev/null +++ b/Source/MDKAnalyzer/AnalyzerReleases.Shipped2.md @@ -0,0 +1,3 @@ +; Shipped analyzer releases +; https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md + diff --git a/Source/MDKAnalyzer/AnalyzerReleases.Unshipped2.md b/Source/MDKAnalyzer/AnalyzerReleases.Unshipped2.md new file mode 100644 index 0000000..b1b99aa --- /dev/null +++ b/Source/MDKAnalyzer/AnalyzerReleases.Unshipped2.md @@ -0,0 +1,3 @@ +; Unshipped analyzer release +; https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md + diff --git a/Source/MDKAnalyzer/MDKAnalyzer.csproj b/Source/MDKAnalyzer/MDKAnalyzer.csproj index a957ca9..9eb7215 100644 --- a/Source/MDKAnalyzer/MDKAnalyzer.csproj +++ b/Source/MDKAnalyzer/MDKAnalyzer.csproj @@ -73,6 +73,7 @@ + diff --git a/Source/MDKServices/HealthAnalysis.cs b/Source/MDKServices/HealthAnalysis.cs index 17a87f8..7640372 100644 --- a/Source/MDKServices/HealthAnalysis.cs +++ b/Source/MDKServices/HealthAnalysis.cs @@ -148,6 +148,13 @@ static HealthAnalysis AnalyzeCore(Project project, HealthAnalysisOptions options analysis._problems.Add(new HealthProblem(HealthCode.Outdated, HealthSeverity.Critical, "This project format is outdated")); } + var property = project.Properties.Item("TargetFrameworkMoniker"); + if (!(property.Value is string moniker) || moniker != ".NETFramework,Version=v4.8") + { + options.Echo?.Invoke($"{project.Name}: This project is not referencing .NET 4.8."); + analysis._problems.Add(new HealthProblem(HealthCode.BadDotNetVersion, HealthSeverity.Critical, "This project is not referencing .NET 4.8")); + } + var whitelistFileName = Path.Combine(Path.GetDirectoryName(project.FullName), "mdk\\whitelist.cache"); if (!projectInfo.Paths.IsValid) diff --git a/Source/MDKServices/HealthCode.cs b/Source/MDKServices/HealthCode.cs index bd5e586..2ed0934 100644 --- a/Source/MDKServices/HealthCode.cs +++ b/Source/MDKServices/HealthCode.cs @@ -48,6 +48,11 @@ public enum HealthCode /// /// The whitelist cache file is outdated. /// - OutdatedWhitelist + OutdatedWhitelist, + + /// + /// The project is not referencing the correct .NET version. + /// + BadDotNetVersion } } \ No newline at end of file diff --git a/Source/MDKServices/MDKServices.csproj b/Source/MDKServices/MDKServices.csproj index f114ccd..b245d5b 100644 --- a/Source/MDKServices/MDKServices.csproj +++ b/Source/MDKServices/MDKServices.csproj @@ -43,9 +43,6 @@ Key.snk - - ..\packages\Microsoft.VisualStudio.RemoteControl.16.3.44\lib\net45\Microsoft.VisualStudio.RemoteControl.dll - @@ -96,9 +93,6 @@ 17.5.33428.388 - - 17.5.22 -