diff --git a/Wabbajack.App.Test/BasicUITests.cs b/Wabbajack.App.Test/BasicUITests.cs new file mode 100644 index 00000000..d4875603 --- /dev/null +++ b/Wabbajack.App.Test/BasicUITests.cs @@ -0,0 +1,24 @@ +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Threading; +using Xunit; + +namespace Wabbajack.App.Test +{ + public class BasicUITests + { + + [StaFact] + public async Task CanCompileASimpleModlist() + { + + SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher)); + var window = new MainWindow(); + window.Show(); + await Task.Delay(1000); + + window.Close(); + Assert.True(true); + } + } +} diff --git a/Wabbajack.App.Test/Wabbajack.App.Test.csproj b/Wabbajack.App.Test/Wabbajack.App.Test.csproj new file mode 100644 index 00000000..9bf46b85 --- /dev/null +++ b/Wabbajack.App.Test/Wabbajack.App.Test.csproj @@ -0,0 +1,20 @@ + + + + netcoreapp3.1 + + false + + + + + + + + + + + + + + diff --git a/Wabbajack.Common/Json.cs b/Wabbajack.Common/Json.cs index 7ac5e2de..c40a4685 100644 --- a/Wabbajack.Common/Json.cs +++ b/Wabbajack.Common/Json.cs @@ -42,11 +42,11 @@ namespace Wabbajack.Common }); } - public static T FromJSON(this string filename, + public static T FromJSON(this AbsolutePath filename, TypeNameHandling handling = TypeNameHandling.All, TypeNameAssemblyFormatHandling format = TypeNameAssemblyFormatHandling.Full) { - return JsonConvert.DeserializeObject(File.ReadAllText(filename), + return JsonConvert.DeserializeObject(filename.ReadAllText(), new JsonSerializerSettings {TypeNameHandling = handling, TypeNameAssemblyFormatHandling = format, Converters = Converters diff --git a/Wabbajack.Common/Paths.cs b/Wabbajack.Common/Paths.cs index 6590638b..bd7ee73f 100644 --- a/Wabbajack.Common/Paths.cs +++ b/Wabbajack.Common/Paths.cs @@ -218,6 +218,7 @@ namespace Wabbajack.Common public static explicit operator AbsolutePath(string path) { + if (string.IsNullOrEmpty(path)) return default; return !Path.IsPathRooted(path) ? ((RelativePath)path).RelativeToEntryPoint() : new AbsolutePath(path); } diff --git a/Wabbajack.Lib/zEditIntegration.cs b/Wabbajack.Lib/zEditIntegration.cs index 7fd66e73..5cce2cb5 100644 --- a/Wabbajack.Lib/zEditIntegration.cs +++ b/Wabbajack.Lib/zEditIntegration.cs @@ -17,11 +17,11 @@ namespace Wabbajack.Lib { private static MO2Compiler _mo2Compiler; - public static string FindzEditPath(ACompiler compiler) + public static AbsolutePath FindzEditPath(ACompiler compiler) { _mo2Compiler = (MO2Compiler) compiler; var executables = _mo2Compiler.MO2Ini.customExecutables; - if (executables.size == null) return null; + if (executables.size == null) return default; foreach (var idx in Enumerable.Range(1, int.Parse(executables.size))) { @@ -29,10 +29,10 @@ namespace Wabbajack.Lib if (path == null) continue; if (path.EndsWith("zEdit.exe")) - return Path.GetDirectoryName(path); + return (AbsolutePath)path; } - return null; + return default; } public class IncludeZEditPatches : ACompilationStep @@ -52,9 +52,8 @@ namespace Wabbajack.Lib return; } - var merges = Directory.EnumerateFiles(Path.Combine(zEditPath, "profiles"), - DirectoryEnumerationOptions.Files | DirectoryEnumerationOptions.Recursive) - .Where(f => f.EndsWith("\\merges.json")) + var merges = zEditPath.Combine("profiles").EnumerateFiles() + .Where(f => f.FileName == (RelativePath)"merges.json") .SelectMany(f => f.FromJSON>()) .GroupBy(f => (f.name, f.filename)); diff --git a/Wabbajack.sln b/Wabbajack.sln index 1c53697c..cf50ad1c 100644 --- a/Wabbajack.sln +++ b/Wabbajack.sln @@ -40,6 +40,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wabbajack.Launcher", "Wabba EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wabbajack.Common.Test", "Wabbajack.Common.Test\Wabbajack.Common.Test.csproj", "{BA8A3E49-60D2-4BA2-B285-CB09FFDB6D32}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wabbajack.App.Test", "Wabbajack.App.Test\Wabbajack.App.Test.csproj", "{44E30B97-D4A8-40A6-81D5-5CAB1F3D45CB}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -139,6 +141,14 @@ Global {BA8A3E49-60D2-4BA2-B285-CB09FFDB6D32}.Release|x64.ActiveCfg = Release|x64 {BA8A3E49-60D2-4BA2-B285-CB09FFDB6D32}.Release|x64.Build.0 = Release|x64 {BA8A3E49-60D2-4BA2-B285-CB09FFDB6D32}.Debug|Any CPU.Build.0 = Debug|x64 + {44E30B97-D4A8-40A6-81D5-5CAB1F3D45CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {44E30B97-D4A8-40A6-81D5-5CAB1F3D45CB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {44E30B97-D4A8-40A6-81D5-5CAB1F3D45CB}.Debug|x64.ActiveCfg = Debug|Any CPU + {44E30B97-D4A8-40A6-81D5-5CAB1F3D45CB}.Debug|x64.Build.0 = Debug|Any CPU + {44E30B97-D4A8-40A6-81D5-5CAB1F3D45CB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {44E30B97-D4A8-40A6-81D5-5CAB1F3D45CB}.Release|Any CPU.Build.0 = Release|Any CPU + {44E30B97-D4A8-40A6-81D5-5CAB1F3D45CB}.Release|x64.ActiveCfg = Release|Any CPU + {44E30B97-D4A8-40A6-81D5-5CAB1F3D45CB}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Wabbajack/Settings.cs b/Wabbajack/Settings.cs index 5fc4a01b..19b69d54 100644 --- a/Wabbajack/Settings.cs +++ b/Wabbajack/Settings.cs @@ -35,7 +35,7 @@ namespace Wabbajack } // Version check - settings = JsonConvert.DeserializeObject(Consts.SettingsFile.ReadAllText()); + settings = Consts.SettingsFile.FromJSON(); if (settings.Version == Consts.SettingsVersion) return true;