-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
…the project upgrade tool.
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,28 @@ | ||
using System.IO; | ||
using Malware.MDKServices; | ||
using Malware.MDKUtilities; | ||
using System.Threading.Tasks; | ||
|
||
namespace MDK.Views.ProjectHealth.Fixes | ||
{ | ||
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; | ||
if (string.IsNullOrEmpty(path) || !Directory.Exists(path)) | ||
{ | ||
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; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,28 @@ | ||
using System.IO; | ||
using Malware.MDKServices; | ||
using System.Threading.Tasks; | ||
|
||
namespace MDK.Views.ProjectHealth.Fixes | ||
{ | ||
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; | ||
if (string.IsNullOrEmpty(path) || !Directory.Exists(path)) | ||
{ | ||
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; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
} | ||
}); | ||
} | ||
} | ||
} |