diff --git a/GodotEnv.Tests/src/features/godot/domain/GodotRepositoryTest.cs b/GodotEnv.Tests/src/features/godot/domain/GodotRepositoryTest.cs index 10a0ec8..010139f 100644 --- a/GodotEnv.Tests/src/features/godot/domain/GodotRepositoryTest.cs +++ b/GodotEnv.Tests/src/features/godot/domain/GodotRepositoryTest.cs @@ -15,7 +15,7 @@ namespace Chickensoft.GodotEnv.Tests.Features.Godot.Domain; public class GodotRepositoryTest { [Fact] public async Task AddOrUpdateGodotEnvVariable() { - var WORKING_DIR = "."; + var workingDir = "."; var godotVar = "GODOT"; var computer = new Mock(); @@ -29,7 +29,7 @@ public async Task AddOrUpdateGodotEnvVariable() { ? OSType.Windows : OSType.Unknown); - fileClient.Setup(fc => fc.AppDataDirectory).Returns(WORKING_DIR); + fileClient.Setup(fc => fc.AppDataDirectory).Returns(workingDir); // GodotBinPath fileClient.Setup(fc => fc.Combine(fileClient.Object.AppDataDirectory, Defaults.GODOT_PATH, Defaults.GODOT_BIN_NAME)) diff --git a/GodotEnv/Chickensoft.GodotEnv.csproj b/GodotEnv/Chickensoft.GodotEnv.csproj index e418d06..cf0c30d 100644 --- a/GodotEnv/Chickensoft.GodotEnv.csproj +++ b/GodotEnv/Chickensoft.GodotEnv.csproj @@ -9,6 +9,7 @@ godotenv enable true + NU1903 GodotEnv 2.6.0 @@ -42,17 +43,16 @@ - - + + - - - + + + - - + diff --git a/GodotEnv/src/common/clients/FileClient.cs b/GodotEnv/src/common/clients/FileClient.cs index 245249d..dc0e581 100644 --- a/GodotEnv/src/common/clients/FileClient.cs +++ b/GodotEnv/src/common/clients/FileClient.cs @@ -390,19 +390,19 @@ public string Sanitize(string path) => public string Combine(params string[] paths) => Files.Path.Combine(paths); public string DirectorySymlinkTarget(string symlinkPath) - => Files.DirectoryInfo.FromDirectoryName(symlinkPath).LinkTarget; + => Files.DirectoryInfo.New(symlinkPath).LinkTarget!; public string FileSymlinkTarget(string symlinkPath) - => Files.FileInfo.FromFileName(symlinkPath).LinkTarget; + => Files.FileInfo.New(symlinkPath).LinkTarget!; public void CreateDirectory(string path) => Files.Directory.CreateDirectory(path); public string GetParentDirectoryPath(string path) => - Files.Path.GetDirectoryName(path); + Files.Path.GetDirectoryName(path)!; public string GetParentDirectoryName(string path) => - Files.DirectoryInfo.FromDirectoryName(path).Name; + Files.DirectoryInfo.New(path).Name; public async Task CreateSymlink(string path, string pathToTarget) { // See what kind of symlink we're dealing with by checking the target. @@ -450,10 +450,10 @@ public async Task CreateSymlinkRecursively(string path, string pathToTarget) { } public bool IsDirectorySymlink(string path) - => Files.DirectoryInfo.FromDirectoryName(path).LinkTarget != null; + => Files.DirectoryInfo.New(path).LinkTarget != null; public bool IsFileSymlink(string path) - => Files.FileInfo.FromFileName(path).LinkTarget != null; + => Files.FileInfo.New(path).LinkTarget != null; public async Task DeleteDirectory(string path) { if (!DirectoryExists(path)) { return; } @@ -471,7 +471,7 @@ await ProcessRunner.RunElevatedOnWindows( if (OS == OSType.Windows) { var parentDirectory = GetParentDirectoryPath(path); - var directoryInfo = Files.DirectoryInfo.FromDirectoryName(path); + var directoryInfo = Files.DirectoryInfo.New(path); // Delete files inside directory using command prompt to prevent // C# permissions issues. @@ -536,7 +536,7 @@ public string GetRootedPath(string url, string basePath) { public bool DirectoryExists(string path) => Files.Directory.Exists(path); public IEnumerable GetSubdirectories(string dir) => - Files.DirectoryInfo.FromDirectoryName(dir).EnumerateDirectories(); + Files.DirectoryInfo.New(dir).EnumerateDirectories(); public T ReadJsonFile(string path) where T : notnull { var contents = Files.File.ReadAllText(path); @@ -599,7 +599,7 @@ public async Task> SearchRecursively( Action onDirectory, string indent = "" ) { - var dirInfo = Files.DirectoryInfo.FromDirectoryName(dir); + var dirInfo = Files.DirectoryInfo.New(dir); if (!dirInfo.Exists) { throw new DirectoryNotFoundException( $"Directory not found: {dirInfo.FullName}" diff --git a/GodotEnv/src/common/clients/ZipClient.cs b/GodotEnv/src/common/clients/ZipClient.cs index c43f0de..8097b13 100644 --- a/GodotEnv/src/common/clients/ZipClient.cs +++ b/GodotEnv/src/common/clients/ZipClient.cs @@ -56,7 +56,7 @@ ILog log continue; } - Files.Directory.CreateDirectory(Files.Path.GetDirectoryName(fileName)); + Files.Directory.CreateDirectory(Files.Path.GetDirectoryName(fileName)!); using (var inputStream = entry.Open()) using (var outputStream = Files.File.OpenWrite(fileName)) { diff --git a/GodotEnv/src/common/clients/ZipClientTerminal.cs b/GodotEnv/src/common/clients/ZipClientTerminal.cs index e7e3273..e5465da 100644 --- a/GodotEnv/src/common/clients/ZipClientTerminal.cs +++ b/GodotEnv/src/common/clients/ZipClientTerminal.cs @@ -23,7 +23,7 @@ public async Task ExtractToDirectory( IProgress progress, ILog log ) { - var parentDir = Files.Path.GetDirectoryName(destinationDirectoryName); + var parentDir = Files.Path.GetDirectoryName(destinationDirectoryName)!; Files.Directory.CreateDirectory(parentDir); var shell = Computer.CreateShell(parentDir); diff --git a/GodotEnv/src/common/utilities/ProcessRunner.cs b/GodotEnv/src/common/utilities/ProcessRunner.cs index 74a705f..2bd9289 100644 --- a/GodotEnv/src/common/utilities/ProcessRunner.cs +++ b/GodotEnv/src/common/utilities/ProcessRunner.cs @@ -2,10 +2,8 @@ namespace Chickensoft.GodotEnv.Common.Utilities; using System; using System.Diagnostics; -using System.Linq; using System.Reactive.Linq; using System.Runtime.InteropServices; -using System.Security.Principal; using System.Text; using System.Threading.Tasks; using CliWrap; @@ -102,8 +100,7 @@ public async Task RunElevatedOnWindows( // doesn't have admin rights bool shouldElevate = !UACHelper.UACHelper.IsElevated; - Process process = UACHelper.UACHelper.StartElevated(new ProcessStartInfo() - { + Process process = UACHelper.UACHelper.StartElevated(new ProcessStartInfo() { FileName = exe, Arguments = args, UseShellExecute = shouldElevate,