diff --git a/PlatformKit.Windows/WinRegistrySearcher.cs b/PlatformKit.Windows/WinRegistrySearcher.cs index 03b0fa99..af10e1c3 100644 --- a/PlatformKit.Windows/WinRegistrySearcher.cs +++ b/PlatformKit.Windows/WinRegistrySearcher.cs @@ -16,9 +16,9 @@ namespace PlatformKit.Windows; public class WinRegistrySearcher : IWinRegistrySearcher { - private readonly ICommandRunner _commandRunner; + private readonly ICliCommandRunner _commandRunner; - public WinRegistrySearcher(ICommandRunner commandRunner) + public WinRegistrySearcher(ICliCommandRunner commandRunner) { _commandRunner = commandRunner; } diff --git a/PlatformKit.Windows/WindowsSystemInfoProvider.cs b/PlatformKit.Windows/WindowsSystemInfoProvider.cs index 6d9a1ecf..1144253f 100644 --- a/PlatformKit.Windows/WindowsSystemInfoProvider.cs +++ b/PlatformKit.Windows/WindowsSystemInfoProvider.cs @@ -33,9 +33,9 @@ namespace PlatformKit.Windows; public class WindowsSystemInfoProvider : IWindowsSystemInfoProvider { - private readonly ICommandRunner _commandRunner; + private readonly ICliCommandRunner _commandRunner; - public WindowsSystemInfoProvider(ICommandRunner commandRunner) + public WindowsSystemInfoProvider(ICliCommandRunner commandRunner) { _commandRunner = commandRunner; } @@ -64,7 +64,7 @@ public async Task GetWindowsSystemInfoAsync() NetworkCardModel lastNetworkCard = null; - ICommandBuilder commandBuilder = new CommandBuilder(new CmdCommandConfiguration()) + ICliCommandRunner commandBuilder = new CliCommandRunner(new CmdCommandConfiguration()) .WithArguments("systeminfo") .WithWorkingDirectory(Environment.SystemDirectory); diff --git a/PlatformKit/Platforms/DefaultPlatformProviderFactory.cs b/PlatformKit/Platforms/DefaultPlatformProviderFactory.cs index d8893c86..43ea8cf9 100644 --- a/PlatformKit/Platforms/DefaultPlatformProviderFactory.cs +++ b/PlatformKit/Platforms/DefaultPlatformProviderFactory.cs @@ -28,11 +28,11 @@ namespace PlatformKit { public class DefaultPlatformProviderFactory : IPlatformProviderFactory { - private readonly ICommandRunner _commandRunner; + private readonly ICliCommandRunner _commandRunner; private readonly ILinuxOsReleaseProvider _linuxOsReleaseSearcher; private readonly IWindowsSystemInfoProvider _windowsSystemInfoProvider; - public DefaultPlatformProviderFactory(ICommandRunner commandRunner, + public DefaultPlatformProviderFactory(ICliCommandRunner commandRunner, ILinuxOsReleaseProvider linuxOsReleaseSearcher, IWindowsSystemInfoProvider windowsSystemInfoProvider) { @@ -41,7 +41,7 @@ public DefaultPlatformProviderFactory(ICommandRunner commandRunner, _windowsSystemInfoProvider = windowsSystemInfoProvider; } - public static DefaultPlatformProviderFactory CreateFactory(ICommandRunner commandRunner, + public static DefaultPlatformProviderFactory CreateFactory(ICliCommandRunner commandRunner, ILinuxOsReleaseProvider linuxOsReleaseSearcher, IWindowsSystemInfoProvider windowsSystemInfoProvider) { return new DefaultPlatformProviderFactory(commandRunner, linuxOsReleaseSearcher, windowsSystemInfoProvider); diff --git a/PlatformKit/Platforms/Providers/AndroidPlatformProvider.cs b/PlatformKit/Platforms/Providers/AndroidPlatformProvider.cs index b939fae6..8f0752b8 100644 --- a/PlatformKit/Platforms/Providers/AndroidPlatformProvider.cs +++ b/PlatformKit/Platforms/Providers/AndroidPlatformProvider.cs @@ -10,7 +10,7 @@ This Source Code Form is subject to the terms of the Mozilla Public using System; using System.Runtime.InteropServices; using System.Threading.Tasks; - +using AlastairLundy.Extensions.Processes; using CliRunner; using CliRunner.Abstractions; using CliRunner.Builders; @@ -29,9 +29,9 @@ namespace PlatformKit.Providers { public class AndroidPlatformProvider : IAndroidPlatformProvider { - private readonly ICommandRunner _commandRunner; + private readonly ICliCommandRunner _commandRunner; - public AndroidPlatformProvider(ICommandRunner commandRunner) + public AndroidPlatformProvider(ICliCommandRunner commandRunner) { _commandRunner = commandRunner; } @@ -80,10 +80,10 @@ await GetDeviceNameAsync(), #endif private async Task GetProcessorArchitectureAsync() { - ICommandBuilder commandBuilder = new CommandBuilder("uname") + ICliCommandBuilder commandBuilder = new CliCommandBuilder("uname") .WithArguments("-m"); - Command command = commandBuilder.Build(); + CliCommand command = commandBuilder.Build(); BufferedProcessResult result = await _commandRunner.ExecuteBufferedAsync(command); @@ -122,10 +122,10 @@ private async Task GetDeviceNameAsync() #endif private async Task GetPlatformNameAsync() { - ICommandBuilder commandBuilder = new CommandBuilder("uname") + ICliCommandBuilder commandBuilder = new CliCommandBuilder("uname") .WithArguments("-o"); - Command command = commandBuilder.Build(); + CliCommand command = commandBuilder.Build(); BufferedProcessResult result = await _commandRunner.ExecuteBufferedAsync(command); @@ -147,10 +147,10 @@ private async Task GetPlatformVersionAsync() #endif private async Task GetPlatformKernelVersionAsync() { - ICommandBuilder commandBuilder = new CommandBuilder("uname") + ICliCommandBuilder commandBuilder = new CliCommandBuilder("uname") .WithArguments("-r"); - Command command = commandBuilder.Build(); + CliCommand command = commandBuilder.Build(); BufferedProcessResult result = await _commandRunner.ExecuteBufferedAsync(command); @@ -185,10 +185,10 @@ private async Task GetSdkLevelAsync() #endif private async Task GetPropValueAsync(string value) { - ICommandBuilder commandBuilder = new CommandBuilder("getprop") + ICliCommandBuilder commandBuilder = new CliCommandBuilder("getprop") .WithArguments($"ro.build.version.{value}"); - Command command = commandBuilder.Build(); + CliCommand command = commandBuilder.Build(); BufferedProcessResult result = await _commandRunner.ExecuteBufferedAsync(command); diff --git a/PlatformKit/Platforms/Providers/BSDPlatformProvider.cs b/PlatformKit/Platforms/Providers/BSDPlatformProvider.cs index f8a1b543..ae3bcb80 100644 --- a/PlatformKit/Platforms/Providers/BSDPlatformProvider.cs +++ b/PlatformKit/Platforms/Providers/BSDPlatformProvider.cs @@ -37,9 +37,9 @@ namespace PlatformKit.Providers { public class BSDPlatformProvider : UnixPlatformProvider { - private readonly ICommandRunner _commandRunner; + private readonly ICliCommandRunner _commandRunner; - public BSDPlatformProvider(ICommandRunner commandRunner) : base(commandRunner) + public BSDPlatformProvider(ICliCommandRunner commandRunner) : base(commandRunner) { _commandRunner = commandRunner; } @@ -74,7 +74,11 @@ private async Task GetOsNameAsync() { try { +#if NET6_0_OR_GREATER string[] lines = await File.ReadAllLinesAsync("/etc/freebsd-release"); +#else + string[] lines = await FilePolyfill.ReadAllLinesAsync("/etc/freebsd-release"); +#endif string result = lines.First(x => x.Contains("name=", StringComparison.CurrentCultureIgnoreCase)) diff --git a/PlatformKit/Platforms/Providers/DarwinPlatformProvider.cs b/PlatformKit/Platforms/Providers/DarwinPlatformProvider.cs index b1c6f424..f7afe7a2 100644 --- a/PlatformKit/Platforms/Providers/DarwinPlatformProvider.cs +++ b/PlatformKit/Platforms/Providers/DarwinPlatformProvider.cs @@ -12,7 +12,7 @@ This Source Code Form is subject to the terms of the Mozilla Public using System.Linq; using System.Runtime.InteropServices; using System.Threading.Tasks; - +using AlastairLundy.Extensions.Processes; using CliRunner; using CliRunner.Abstractions; using CliRunner.Builders; @@ -39,9 +39,9 @@ namespace PlatformKit.Providers [SuppressMessage("Interoperability", "CA1416:Validate platform compatibility")] public class DarwinPlatformProvider : UnixPlatformProvider, IDarwinPlatformProvider { - private readonly ICommandRunner _commandRunner; + private readonly ICliCommandRunner _commandRunner; - public DarwinPlatformProvider(ICommandRunner commandRunner) : base(commandRunner) + public DarwinPlatformProvider(ICliCommandRunner commandRunner) : base(commandRunner) { _commandRunner = commandRunner; } @@ -104,10 +104,10 @@ private async Task GetDarwinVersionAsync() { if (OperatingSystem.IsMacOS() == true || OperatingSystem.IsMacCatalyst() == true) { - ICommandBuilder commandBuilder = new CommandBuilder("/usr/bin/uname") + ICliCommandBuilder commandBuilder = new CliCommandBuilder("/usr/bin/uname") .WithArguments($"-m"); - Command command = commandBuilder.Build(); + CliCommand command = commandBuilder.Build(); BufferedProcessResult result = await _commandRunner.ExecuteBufferedAsync(command); @@ -176,9 +176,9 @@ private string GetOsName() #endif private async Task GetSwVersInfoAsync() { - ICommandBuilder commandBuilder = new CommandBuilder("/usr/bin/sw_vers"); + ICliCommandBuilder commandBuilder = new CliCommandBuilder("/usr/bin/sw_vers"); - Command command = commandBuilder.Build(); + CliCommand command = commandBuilder.Build(); BufferedProcessResult result = await _commandRunner.ExecuteBufferedAsync(command); @@ -219,7 +219,7 @@ private async Task GetOsVersionAsync() { if (OperatingSystem.IsMacOS() || OperatingSystem.IsMacCatalyst()) { - ICommandBuilder commandBuilder = new CommandBuilder("/usr/bin/uname") + ICliCommandRunner commandBuilder = new CliCommandBuilder("/usr/bin/uname") .WithArguments($"-v"); Command command = commandBuilder.Build(); diff --git a/PlatformKit/Platforms/Providers/LinuxPlatformProvider.cs b/PlatformKit/Platforms/Providers/LinuxPlatformProvider.cs index 38aebef8..be99cdd5 100644 --- a/PlatformKit/Platforms/Providers/LinuxPlatformProvider.cs +++ b/PlatformKit/Platforms/Providers/LinuxPlatformProvider.cs @@ -32,10 +32,10 @@ namespace PlatformKit.Providers { public class LinuxPlatformProvider : UnixPlatformProvider, ILinuxPlatformProvider { - private readonly ICommandRunner _commandRunner; + private readonly ICliCommandRunner _commandRunner; private readonly ILinuxOsReleaseProvider _linuxOsReleaseSearcher; - public LinuxPlatformProvider(ICommandRunner commandRunner, + public LinuxPlatformProvider(ICliCommandRunner commandRunner, ILinuxOsReleaseProvider linuxOsReleaseSearcher) : base(commandRunner) { diff --git a/PlatformKit/Platforms/Providers/UnixPlatformProvider.cs b/PlatformKit/Platforms/Providers/UnixPlatformProvider.cs index 9eba4e7e..59ba8288 100644 --- a/PlatformKit/Platforms/Providers/UnixPlatformProvider.cs +++ b/PlatformKit/Platforms/Providers/UnixPlatformProvider.cs @@ -12,7 +12,7 @@ This Source Code Form is subject to the terms of the Mozilla Public using System.Linq; using System.Runtime.InteropServices; using System.Threading.Tasks; - +using AlastairLundy.Extensions.Processes; using CliRunner; using CliRunner.Abstractions; using CliRunner.Builders; @@ -31,9 +31,9 @@ namespace PlatformKit.Providers { public class UnixPlatformProvider : IUnixPlatformProvider { - private readonly ICommandRunner _commandRunner; + private readonly ICliCommandRunner _commandRunner; - public UnixPlatformProvider(ICommandRunner commandRunner) + public UnixPlatformProvider(ICliCommandRunner commandRunner) { _commandRunner = commandRunner; } @@ -70,11 +70,11 @@ protected async Task GetUnameValueAsync(string argument) throw new PlatformNotSupportedException(Resources.Exceptions_PlatformNotSupported_FreeBsdOnly); } - ICommandBuilder commandBuilder = new CommandBuilder("uname") + ICliCommandBuilder commandBuilder = new CliCommandBuilder("uname") .WithArguments(argument) .WithWorkingDirectory(Environment.CurrentDirectory); - Command command = commandBuilder.Build(); + CliCommand command = commandBuilder.Build(); BufferedProcessResult result = await _commandRunner.ExecuteBufferedAsync(command); diff --git a/PlatformKit/Platforms/Providers/WindowsPlatformProvider.cs b/PlatformKit/Platforms/Providers/WindowsPlatformProvider.cs index c1e09514..1c3468b9 100644 --- a/PlatformKit/Platforms/Providers/WindowsPlatformProvider.cs +++ b/PlatformKit/Platforms/Providers/WindowsPlatformProvider.cs @@ -15,8 +15,6 @@ This Source Code Form is subject to the terms of the Mozilla Public using CliRunner.Builders; using CliRunner.Builders.Abstractions; using PlatformKit.Internal.Localizations; -using PlatformKit.Specializations.Windows; -using PlatformKit.Specializations.Windows.Abstractions; using PlatformKit.Specifics; using PlatformKit.Specifics.Abstractions; @@ -33,10 +31,10 @@ namespace PlatformKit.Providers { public class WindowsPlatformProvider : IWindowsPlatformProvider { - private readonly ICommandRunner _commandRunner; + private readonly ICliCommandRunner _commandRunner; private readonly IWindowsSystemInfoProvider _windowsSystemInfoProvider; - public WindowsPlatformProvider(ICommandRunner commandRunner, IWindowsSystemInfoProvider windowsSystemInfoProvider) + public WindowsPlatformProvider(ICliCommandRunner commandRunner, IWindowsSystemInfoProvider windowsSystemInfoProvider) { _commandRunner = commandRunner; _windowsSystemInfoProvider = windowsSystemInfoProvider; @@ -96,10 +94,10 @@ private async Task GetProcessorArchitectureAsync() throw new PlatformNotSupportedException(Resources.Exceptions_PlatformNotSupported_WindowsOnly); } - ICommandBuilder commandBuilder = new CommandBuilder("echo") + ICliCommandBuilder commandBuilder = new CliCommandBuilder("echo") .WithArguments("%PROCESSOR_ARCHITECTURE%"); - Command command = commandBuilder.Build(); + CliCommand command = commandBuilder.Build(); var result = await _commandRunner.ExecuteBufferedAsync(command); diff --git a/PlatformKit/Platforms/Specifics/WindowsPlatform.cs b/PlatformKit/Platforms/Specifics/WindowsPlatform.cs index 2b16f09a..a4914efe 100644 --- a/PlatformKit/Platforms/Specifics/WindowsPlatform.cs +++ b/PlatformKit/Platforms/Specifics/WindowsPlatform.cs @@ -10,8 +10,6 @@ This Source Code Form is subject to the terms of the Mozilla Public using System; using System.Runtime.InteropServices; -using PlatformKit.Specializations.Windows; - // ReSharper disable ConvertToPrimaryConstructor namespace PlatformKit.Specifics; diff --git a/PlatformKit/Specializations/Mac/MacSystemProfilerInfoProvider.cs b/PlatformKit/Specializations/Mac/MacSystemProfilerInfoProvider.cs index aa78d931..0537e195 100644 --- a/PlatformKit/Specializations/Mac/MacSystemProfilerInfoProvider.cs +++ b/PlatformKit/Specializations/Mac/MacSystemProfilerInfoProvider.cs @@ -10,7 +10,7 @@ This Source Code Form is subject to the terms of the Mozilla Public using System; using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; - +using AlastairLundy.Extensions.Processes; using CliRunner; using CliRunner.Abstractions; using CliRunner.Builders; @@ -30,9 +30,9 @@ namespace PlatformKit.Specializations.Mac; public class MacSystemProfilerInfoProvider : IMacSystemProfilerInfoProvider { - private readonly ICommandRunner _commandRunner; + private readonly ICliCommandRunner _commandRunner; - public MacSystemProfilerInfoProvider(ICommandRunner commandRunner) + public MacSystemProfilerInfoProvider(ICliCommandRunner commandRunner) { _commandRunner = commandRunner; } @@ -124,12 +124,12 @@ public async Task GetMacSystemProfilerValue(MacSystemProfilerDataType ma throw new PlatformNotSupportedException(Resources.Exceptions_PlatformNotSupported_MacOnly); } - ICommandBuilder commandBuilder = new CommandBuilder("/usr/bin/system_profiler") + ICliCommandBuilder commandBuilder = new CliCommandBuilder("/usr/bin/system_profiler") .WithArguments("SP" + macSystemProfilerDataType) .WithWorkingDirectory("/usr/bin/") .WithValidation(ProcessResultValidation.None); - Command command = commandBuilder.Build(); + CliCommand command = commandBuilder.Build(); BufferedProcessResult result = await _commandRunner.ExecuteBufferedAsync(command);