From ffa1133002c892da8d58bc7b8fb30e3f6c67a0ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=AD=20Climent?= Date: Fri, 3 Jan 2025 00:38:00 +0100 Subject: [PATCH 1/2] Remove obsolete code --- .../InstallationOptions.cs | 241 ---------- src/UniGetUI.PackageEngine.Package/Package.cs | 415 ------------------ .../PackageDetails.cs | 50 --- ...iGetUI.PackageEngine.PackageClasses.csproj | 22 - .../UpgradablePackage.cs | 89 ---- 5 files changed, 817 deletions(-) delete mode 100644 src/UniGetUI.PackageEngine.Package/InstallationOptions.cs delete mode 100644 src/UniGetUI.PackageEngine.Package/Package.cs delete mode 100644 src/UniGetUI.PackageEngine.Package/PackageDetails.cs delete mode 100644 src/UniGetUI.PackageEngine.Package/UniGetUI.PackageEngine.PackageClasses.csproj delete mode 100644 src/UniGetUI.PackageEngine.Package/UpgradablePackage.cs diff --git a/src/UniGetUI.PackageEngine.Package/InstallationOptions.cs b/src/UniGetUI.PackageEngine.Package/InstallationOptions.cs deleted file mode 100644 index f18f6fc53..000000000 --- a/src/UniGetUI.PackageEngine.Package/InstallationOptions.cs +++ /dev/null @@ -1,241 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Text.Json; -using System.Threading.Tasks; -using UniGetUI.Core.Data; -using UniGetUI.Core.Language; -using UniGetUI.Core.Logging; -using UniGetUI.PackageEngine.Enums; -using UniGetUI.PackageEngine.Serializable; - -namespace UniGetUI.PackageEngine.PackageClasses -{ - - /// - /// This class represents the options in which a package must be installed, updated or uninstalled. - /// - public class InstallationOptions - { - public bool SkipHashCheck { get; set; } = false; - public bool InteractiveInstallation { get; set; } = false; - public bool RunAsAdministrator { get; set; } = false; - public string Version { get; set; } = ""; - public Architecture? Architecture { get; set; } = null; - public PackageScope? InstallationScope { get; set; } = null; - public List CustomParameters { get; set; } = new List(); - public bool RemoveDataOnUninstall { get; set; } = false; - public bool PreRelease { get; set; } = false; - public string CustomInstallLocation { get; set; } = ""; - - public Package Package { get; } - - private string _saveFileName = "Unknown.Unknown.InstallationOptions"; - - /// - /// Construct a new InstallationOptions object for a given package. The options will be - /// loaded from disk unless the reset parameter is set to true, in which case the options - /// will be the default ones. - /// - /// - /// - public InstallationOptions(Package package, bool reset = false) - { - Package = package; - _saveFileName = Package.Manager.Name.Replace(" ", "").Replace(".", "") + "." + Package.Id; - if (!reset) - { - LoadOptionsFromDisk(); - } - } - - /// - /// Returns a new InstallationOptions object from a given package. The options will be - /// loaded from the disk asynchronously. - /// - /// - /// - public static async Task FromPackageAsync(Package package) - { - InstallationOptions options = new(package, reset: true); - await options.LoadOptionsFromDiskAsync(); - return options; - } - - /// - /// Overload of the constructor that accepts an UpgradablePackage object. - /// - /// - /// - public InstallationOptions(UpgradablePackage package, bool reset = false) : this((Package)package, reset) - { } - - /// - /// Returns a new InstallationOptions object from a given SerializableInstallationOptions_v1 and a package. - /// - /// - /// - /// - public static InstallationOptions FromSerialized(SerializableInstallationOptions_v1 options, Package package) - { - InstallationOptions opt = new(package, reset: true); - opt.FromSerialized(options); - return opt; - } - - /// - /// Loads and applies the options from the given SerializableInstallationOptions_v1 object to the current object. - /// - /// - public void FromSerialized(SerializableInstallationOptions_v1 options) - { - SkipHashCheck = options.SkipHashCheck; - InteractiveInstallation = options.InteractiveInstallation; - RunAsAdministrator = options.RunAsAdministrator; - CustomInstallLocation = options.CustomInstallLocation; - Version = options.Version; - PreRelease = options.PreRelease; - if (options.Architecture != "" && CommonTranslations.InvertedArchNames.ContainsKey(options.Architecture)) - Architecture = CommonTranslations.InvertedArchNames[options.Architecture]; - if (options.InstallationScope != "" && CommonTranslations.InvertedScopeNames_NonLang.ContainsKey(options.InstallationScope)) - InstallationScope = CommonTranslations.InvertedScopeNames_NonLang[options.InstallationScope]; - CustomParameters = options.CustomParameters; - } - - /// - /// Returns a SerializableInstallationOptions_v1 object containing the options of the current instance. - /// - /// - public SerializableInstallationOptions_v1 Serialized() - { - SerializableInstallationOptions_v1 options = new(); - options.SkipHashCheck = SkipHashCheck; - options.InteractiveInstallation = InteractiveInstallation; - options.RunAsAdministrator = RunAsAdministrator; - options.CustomInstallLocation = CustomInstallLocation; - options.PreRelease = PreRelease; - options.Version = Version; - if (Architecture != null) - options.Architecture = CommonTranslations.ArchNames[Architecture.Value]; - if (InstallationScope != null) - options.InstallationScope = CommonTranslations.ScopeNames_NonLang[InstallationScope.Value]; - options.CustomParameters = CustomParameters; - return options; - } - - private FileInfo GetPackageOptionsFile() - { - string optionsFileName = Package.Manager.Name + "." + Package.Id + ".json"; - return new FileInfo(Path.Join(CoreData.UniGetUIInstallationOptionsDirectory, optionsFileName)); - } - - /// - /// Saves the current options to disk. - /// - public void SaveOptionsToDisk() - { - try - { - FileInfo optionsFile = GetPackageOptionsFile(); - if (optionsFile.Directory?.Exists == false) - optionsFile.Directory.Create(); - - using FileStream outputStream = optionsFile.OpenWrite(); - JsonSerializer.Serialize(outputStream, Serialized()); - } - catch (Exception ex) - { - Logger.Log(ex); - } - } - - /// - /// Saves the current options to disk, asynchronously. - /// - public async Task SaveOptionsToDiskAsync() - { - try - { - FileInfo optionsFile = GetPackageOptionsFile(); - if (optionsFile.Directory?.Exists == false) - optionsFile.Directory.Create(); - - await using FileStream outputStream = optionsFile.OpenWrite(); - await JsonSerializer.SerializeAsync(outputStream, Serialized()); - } - catch (Exception ex) - { - Logger.Log(ex); - } - } - - /// - /// Loads the options from disk, asynchronously. - /// - public void LoadOptionsFromDisk() - { - try - { - FileInfo optionsFile = GetPackageOptionsFile(); - if (!optionsFile.Exists) - return; - - using FileStream inputStream = optionsFile.OpenRead(); - SerializableInstallationOptions_v1 options = JsonSerializer.Deserialize(inputStream); - FromSerialized(options); - } - catch (Exception e) - { - Logger.Log(e); - } - } - - /// - /// Loads the options from disk. - /// - public async Task LoadOptionsFromDiskAsync() - { - FileInfo optionsFile = GetPackageOptionsFile(); - try - { - if (!optionsFile.Exists) - return; - - - await using FileStream inputStream = optionsFile.OpenRead(); - SerializableInstallationOptions_v1 options = await JsonSerializer.DeserializeAsync(inputStream); - FromSerialized(options); - } - catch (JsonException) - { - Logger.Log("An error occurred while parsing package " + optionsFile + ". The file will be overwritten"); - await File.WriteAllTextAsync(optionsFile.FullName, "{}"); - } - catch (Exception e) - { - Logger.Log("Loading installation options for file " + optionsFile + " have failed: "); - Logger.Log(e); - } - } - - /// - /// Returns a string representation of the current options. - /// - /// - public override string ToString() - { - string customparams = CustomParameters != null ? string.Join(",", CustomParameters) : "[]"; - return $""; - } - } -} diff --git a/src/UniGetUI.PackageEngine.Package/Package.cs b/src/UniGetUI.PackageEngine.Package/Package.cs deleted file mode 100644 index bcdc7798a..000000000 --- a/src/UniGetUI.PackageEngine.Package/Package.cs +++ /dev/null @@ -1,415 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.IO; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Text.Json; -using System.Text.Json.Nodes; -using System.Threading.Tasks; -using UniGetUI.Core.Data; -using UniGetUI.Core.Tools; -using UniGetUI.Interface.Enums; -using UniGetUI.Core.Logging; -using UniGetUI.Core.IconEngine; -using UniGetUI.PackageEngine.Enums; -using UniGetUI.PackageEngine.ManagerClasses.Manager; - -namespace UniGetUI.PackageEngine.PackageClasses -{ - public class Package : INotifyPropertyChanged - { - // Internal properties - private bool __is_checked = false; - public event PropertyChangedEventHandler? PropertyChanged; - private string __listed_icon_id; - private string __name_tooltip; - private PackageTag __tag; - private float __opacity; - private bool __show_icon_highlight; - private string __hash; - - public PackageTag Tag - { - get { return __tag; } - - set - { - __tag = value; - switch (__tag) - { - case PackageTag.Default: - ListedIconId = "install"; - ListIconShowHighlight = false; - ListedOpacity = 1; - ListedNameTooltip = Name; - break; - - case PackageTag.AlreadyInstalled: - ListedIconId = "installed"; - ListIconShowHighlight = true; - ListedOpacity = 1; - ListedNameTooltip = CoreTools.Translate("This package is already installed") + " - " + Name; - break; - - case PackageTag.IsUpgradable: - ListedIconId = "update"; - ListIconShowHighlight = true; - ListedOpacity = 1; - ListedNameTooltip = CoreTools.Translate("This package can be updated") + " - " + Name; - break; - - case PackageTag.Pinned: - ListedIconId = "pin_fill"; - ListIconShowHighlight = false; - ListedOpacity = 1; - ListedNameTooltip = CoreTools.Translate("Updates for this package are ignored") + " - " + Name; - break; - - case PackageTag.OnQueue: - ListedIconId = "sandclock"; - ListIconShowHighlight = false; - ListedOpacity = .5F; - ListedNameTooltip = CoreTools.Translate("This package is on the queue") + " - " + Name; - break; - - case PackageTag.BeingProcessed: - ListedIconId = "gears"; - ListIconShowHighlight = false; - ListedOpacity = .5F; - ListedNameTooltip = CoreTools.Translate("This package is being processed") + " - " + Name; - break; - - case PackageTag.Failed: - ListedIconId = "stop"; - ListIconShowHighlight = true; - ListedOpacity = 1; - ListedNameTooltip = CoreTools.Translate("An error occurred while processing this package") + " - " + Name; - break; - } - } - } - - // Public properties - public bool ListIconShowHighlight - { - get { return __show_icon_highlight; } - set { __show_icon_highlight = value; OnPropertyChanged(); } - } - - public bool IsChecked - { - get { return __is_checked; } - set { __is_checked = value; OnPropertyChanged(); } - } - - public string ListedIconId - { - set { __listed_icon_id = value; OnPropertyChanged(); } - get { return __listed_icon_id; } - } - - public string ListedNameTooltip - { - get { return __name_tooltip; } - set { __name_tooltip = value; OnPropertyChanged(); } - } - - public float ListedOpacity - { - get { return __opacity; } - set { __opacity = value; OnPropertyChanged(); } - } - - public string IsCheckedAsString { get { return IsChecked ? "True" : "False"; } } - public string Name { get; } - public string Id { get; set; } - public string Version { get; } - public float VersionAsFloat { get; } - public ManagerSource Source { get; set; } - public PackageManager Manager { get; } - public string UniqueId { get; } - public string NewVersion { get; set; } - public virtual bool IsUpgradable { get; } = false; - public PackageScope Scope { get; set; } - public string SourceAsString - { - get - { - if (Source != null) return Source.ToString(); - else return ""; - } - } - - /// - /// Construct a package with a given name, id, version, source and manager, and an optional scope. - /// - /// - /// - /// - /// - /// - /// - public Package(string name, string id, string version, ManagerSource source, PackageManager manager, PackageScope scope = PackageScope.Local) - { - Name = name; - Id = id; - Version = version; - Source = source; - Manager = manager; - Scope = scope; - UniqueId = $"{Manager.Properties.Name}\\{Id}\\{Version}"; - NewVersion = ""; - VersionAsFloat = GetFloatVersion(); - Tag = PackageTag.Default; - __hash = Manager.Name + "\\" + Source.Name + "\\" + Id; - } - - public string GetHash() - { - return __hash; - } - - - /// - /// Internal method - /// - /// - /// - public override bool Equals(object? obj) - { - if (!(obj is Package)) - return false; - else - return (obj as Package)?.GetHash() == GetHash(); - } - - /// - /// Load the package's normalized icon id, - /// - /// a string with the package's normalized icon id - public string GetIconId() - { - string iconId = Id.ToLower(); - if (Manager.Name == "Winget") - iconId = string.Join('.', iconId.Split(".")[1..]); - else if (Manager.Name == "Chocolatey") - iconId = iconId.Replace(".install", "").Replace(".portable", ""); - else if (Manager.Name == "Scoop") - iconId = iconId.Replace(".app", ""); - else if (Manager.Name == "vcpkg") - iconId = iconId.split(":")[0].Split("[")[0]; - return iconId; - } - - /// - /// Get the package's icon url. If the package has no icon, a fallback image is returned. - /// - /// An always-valid URI object - public Uri GetIconUrl() - { - string iconId = GetIconId(); - if (IconDatabase.Instance.GetIconUrlForId(iconId) != "") - return new Uri(IconDatabase.Instance.GetIconUrlForId(iconId)); - - return new Uri("ms-appx:///Assets/Images/package_color.png"); - } - - /// - /// Returns a float representation of the package's version for comparison purposes. - /// - /// A float value. Returns 0.0F if the version could not be parsed - public float GetFloatVersion() - { - string _ver = ""; - bool _dotAdded = false; - foreach (char _char in Version) - { - if (char.IsDigit(_char)) - _ver += _char; - else if (_char == '.') - { - if (!_dotAdded) - { - _ver += _char; - _dotAdded = true; - } - } - } - float res = 0.0F; - if (_ver != "" && _ver != ".") - try - { - return float.Parse(_ver); - } - catch { } - return res; - } - - /// - /// Adds the package to the ignored updates list. If no version is provided, all updates are ignored. - /// Calling this method will override older ignored updates. - /// - /// - /// - public async Task AddToIgnoredUpdatesAsync(string version = "*") - { - try - { - string IgnoredId = $"{Manager.Properties.Name.ToLower()}\\{Id}"; - JsonObject IgnoredUpdatesJson = JsonNode.Parse(await File.ReadAllTextAsync(CoreData.IgnoredUpdatesDatabaseFile)) as JsonObject; - if (IgnoredUpdatesJson.ContainsKey(IgnoredId)) - IgnoredUpdatesJson.Remove(IgnoredId); - IgnoredUpdatesJson.Add(IgnoredId, version); - await File.WriteAllTextAsync(CoreData.IgnoredUpdatesDatabaseFile, IgnoredUpdatesJson.ToString()); - // FIXME: Tools.App.MainWindow.NavigationPage.UpdatesPage.RemoveCorrespondingPackages(this); - - GetInstalledPackage()?.SetTag(PackageTag.Pinned); - } - catch (Exception ex) - { - Logger.Log(ex); - } - } - - /// - /// Removes the package from the ignored updates list, either if it is ignored for all updates or for a specific version only. - /// - /// - public async Task RemoveFromIgnoredUpdatesAsync() - { - try - { - - string IgnoredId = $"{Manager.Properties.Name.ToLower()}\\{Id}"; - JsonObject IgnoredUpdatesJson = JsonNode.Parse(await File.ReadAllTextAsync(CoreData.IgnoredUpdatesDatabaseFile)) as JsonObject; - if (IgnoredUpdatesJson.ContainsKey(IgnoredId)) - { - IgnoredUpdatesJson.Remove(IgnoredId); - await File.WriteAllTextAsync(CoreData.IgnoredUpdatesDatabaseFile, IgnoredUpdatesJson.ToString()); - } - - GetInstalledPackage()?.SetTag(PackageTag.Default); - } - catch (Exception ex) - { - Logger.Log(ex); - } - } - - /// - /// Returns true if the package's updates are ignored. If the version parameter - /// is passed it will be checked if that version is ignored. Please note that if - /// all updates are ignored, calling this method with a specific version will - /// still return true, although the passed version is not explicitly ignored. - /// - /// - /// - public async Task HasUpdatesIgnoredAsync(string Version = "*") - { - try - { - string IgnoredId = $"{Manager.Properties.Name.ToLower()}\\{Id}"; - JsonObject IgnoredUpdatesJson = JsonNode.Parse(await File.ReadAllTextAsync(CoreData.IgnoredUpdatesDatabaseFile)) as JsonObject; - if (IgnoredUpdatesJson.ContainsKey(IgnoredId) && (IgnoredUpdatesJson[IgnoredId].ToString() == "*" || IgnoredUpdatesJson[IgnoredId].ToString() == Version)) - return true; - else - return false; - } - catch (Exception ex) - { - Logger.Log(ex); - return false; - } - - } - - /// - /// Returns (as a string) the version for which a package has been ignored. When no versions - /// are ignored, an empty string will be returned; and when all versions are ignored an asterisk - /// will be returned. - /// - /// - public async Task GetIgnoredUpdatesVersionAsync() - { - try - { - string IgnoredId = $"{Manager.Properties.Name.ToLower()}\\{Id}"; - JsonObject IgnoredUpdatesJson = JsonNode.Parse(await File.ReadAllTextAsync(CoreData.IgnoredUpdatesDatabaseFile)) as JsonObject; - if (IgnoredUpdatesJson.ContainsKey(IgnoredId)) - return IgnoredUpdatesJson[IgnoredId].ToString(); - else - return ""; - } - catch (Exception ex) - { - Logger.Log(ex); - return ""; - } - } - - /// - /// Internal method to raise the PropertyChanged event. - /// - /// - protected void OnPropertyChanged([CallerMemberName] string name = null) - { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); - } - - /// - /// Returns the corresponding installed Package object. Will return null if not applicable - /// - /// a Package object if found, null if not - public Package? GetInstalledPackage() - { - throw new NotImplementedException(); - /* foreach (Package package in Tools.App.MainWindow.NavigationPage.InstalledPage.Packages) - if (package.Equals(this)) - return package; - return null; - */ - } - - /// - /// Returns the corresponding available Package object. Will return null if not applicable - /// - /// a Package object if found, null if not - public Package? GetAvailablePackage() - { - throw new NotImplementedException(); - /* - * foreach (Package package in Tools.App.MainWindow.NavigationPage.DiscoverPage.Packages) - if (package.Equals(this)) - return package; - return null; - */ - } - - /// - /// Returns the corresponding upgradable Package object. Will return null if not applicable - /// - /// a Package object if found, null if not - public Package? GetUpgradablePackage() - { - throw new NotImplementedException(); - /* - foreach (UpgradablePackage package in Tools.App.MainWindow.NavigationPage.UpdatesPage.Packages) - if (package.Equals(this)) - return package; - return null; - */ - } - - /// - /// Sets the package tag. You may as well use the Tag property. - /// This function is used for compatibility with the ? operator - /// - /// - public void SetTag(PackageTag tag) - { - Tag = tag; - } - - } -} diff --git a/src/UniGetUI.PackageEngine.Package/PackageDetails.cs b/src/UniGetUI.PackageEngine.Package/PackageDetails.cs deleted file mode 100644 index 76ea02fd9..000000000 --- a/src/UniGetUI.PackageEngine.Package/PackageDetails.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace UniGetUI.PackageEngine.PackageClasses -{ - /// - /// The properties of a given package. - /// - public class PackageDetails - { - public Package Package { get; } - public string Name { get; } - public string Id { get; } - public string Version { get; } - public string NewVersion { get; } - public ManagerSource Source { get; } - public string Description { get; set; } = ""; - public string Publisher { get; set; } = ""; - public string Author { get; set; } = ""; - public Uri HomepageUrl { get; set; } = null; - public string License { get; set; } = ""; - public Uri LicenseUrl { get; set; } = null; - public Uri InstallerUrl { get; set; } = null; - public string InstallerHash { get; set; } = ""; - public string InstallerType { get; set; } = ""; - public double InstallerSize { get; set; } = 0; // In Megabytes - public Uri ManifestUrl { get; set; } = null; - public string UpdateDate { get; set; } = ""; - public string ReleaseNotes { get; set; } = ""; - public Uri ReleaseNotesUrl { get; set; } = null; - public string[] Tags { get; set; } = new string[0]; - - public PackageDetails(Package package) - { - Package = package; - Name = package.Name; - Id = package.Id; - Version = package.Version; - Source = package.Source; - if (package is UpgradablePackage) - NewVersion = ((UpgradablePackage)package).NewVersion; - else - NewVersion = ""; - } - } - -} diff --git a/src/UniGetUI.PackageEngine.Package/UniGetUI.PackageEngine.PackageClasses.csproj b/src/UniGetUI.PackageEngine.Package/UniGetUI.PackageEngine.PackageClasses.csproj deleted file mode 100644 index 5444dc4e7..000000000 --- a/src/UniGetUI.PackageEngine.Package/UniGetUI.PackageEngine.PackageClasses.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - net8.0 - enable - enable - - - - - - - - - - - - - - - - diff --git a/src/UniGetUI.PackageEngine.Package/UpgradablePackage.cs b/src/UniGetUI.PackageEngine.Package/UpgradablePackage.cs deleted file mode 100644 index f64e1634e..000000000 --- a/src/UniGetUI.PackageEngine.Package/UpgradablePackage.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace UniGetUI.PackageEngine.PackageClasses -{ - - - public class UpgradablePackage : Package - { - // Public properties - public float NewVersionAsFloat { get; } - public override bool IsUpgradable { get; } = true; - - private string __hash; - - /// - /// Creates an UpgradablePackage object representing a package that can be upgraded; given its name, id, installed version, new version, source and manager, and an optional scope. - /// - /// - /// - /// - /// - /// - /// - /// - public UpgradablePackage(string name, string id, string installed_version, string new_version, ManagerSource source, PackageManager manager, PackageScope scope = PackageScope.Local) : base(name, id, installed_version, source, manager, scope) - { - NewVersion = new_version; - IsChecked = true; - NewVersionAsFloat = GetFloatNewVersion(); - - __hash = Manager.Name + "\\" + Source.Name + "\\" + Id + "\\" + Version + "->" + NewVersion; - } - public new string GetHash() - { - return __hash; - } - - /// - /// Returns a float value representing the new new version of the package, for comparison purposes. - /// - /// - public float GetFloatNewVersion() - { - string _ver = ""; - bool _dotAdded = false; - foreach (char _char in NewVersion) - { - if (char.IsDigit(_char)) - _ver += _char; - else if (_char == '.') - { - if (!_dotAdded) - { - _ver += _char; - _dotAdded = true; - } - } - } - float res = 0.0F; - if (_ver != "" && _ver != ".") - try - { - return float.Parse(_ver); - } - catch (Exception) - { - } - return res; - } - - /// - /// This version will check if the new version of the package is already present - /// on the InstalledPackages list, to prevent already installed updates from being updated again. - /// - /// - public bool NewVersionIsInstalled() - { - foreach (Package package in Tools.App.MainWindow.NavigationPage.InstalledPage.Packages) - if (package.Manager == Manager && package.Id == Id && package.Version == NewVersion && package.Source.Name == Source.Name) - return true; - return false; - } - } - -} From f9ae668fcb1961a0c04d8456fa4e3673d3444fa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=AD=20Climent?= Date: Fri, 3 Jan 2025 00:41:19 +0100 Subject: [PATCH 2/2] Remove more obsolete code --- src/UniGetUI.Core.Structs/Person.cs | 24 ---- .../UniGetUI.Core.Structs.csproj | 9 -- .../ManagerLogger.cs | 109 ------------------ ...niGetUI.PackageEngine.ManagerLogger.csproj | 32 ----- 4 files changed, 174 deletions(-) delete mode 100644 src/UniGetUI.Core.Structs/Person.cs delete mode 100644 src/UniGetUI.Core.Structs/UniGetUI.Core.Structs.csproj delete mode 100644 src/UniGetUI.PackageEngine.ManagerLogger/ManagerLogger.cs delete mode 100644 src/UniGetUI.PackageEngine.ManagerLogger/UniGetUI.PackageEngine.ManagerLogger.csproj diff --git a/src/UniGetUI.Core.Structs/Person.cs b/src/UniGetUI.Core.Structs/Person.cs deleted file mode 100644 index 813cc6dac..000000000 --- a/src/UniGetUI.Core.Structs/Person.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Collections.Specialized; - -namespace UniGetUI.Core.Structs -{ - public readonly struct Person - { - public readonly string Name; - public readonly Uri? ProfilePicture; - public readonly Uri? GitHubUrl; - public readonly bool HasPicture; - public readonly bool HasGitHubProfile; - public readonly string Language; - - public Person(string Name, Uri? ProfilePicture = null, Uri? GitHubUrl = null, string Language = "") - { - this.Name = Name; - this.ProfilePicture = ProfilePicture; - this.HasPicture = ProfilePicture != null; - this.GitHubUrl = GitHubUrl; - this.HasPicture = GitHubUrl != null; - this.Language = Language; - } - } -} diff --git a/src/UniGetUI.Core.Structs/UniGetUI.Core.Structs.csproj b/src/UniGetUI.Core.Structs/UniGetUI.Core.Structs.csproj deleted file mode 100644 index fa71b7ae6..000000000 --- a/src/UniGetUI.Core.Structs/UniGetUI.Core.Structs.csproj +++ /dev/null @@ -1,9 +0,0 @@ - - - - net8.0 - enable - enable - - - diff --git a/src/UniGetUI.PackageEngine.ManagerLogger/ManagerLogger.cs b/src/UniGetUI.PackageEngine.ManagerLogger/ManagerLogger.cs deleted file mode 100644 index e9f349a50..000000000 --- a/src/UniGetUI.PackageEngine.ManagerLogger/ManagerLogger.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System.Diagnostics; -using UniGetUI.PackageEngine.ManagerClasses.Manager; - -namespace UniGetUI.PackageEngine.ManagerLogger -{ - public class ManagerLogger - { - public enum OperationType - { - SearchPackages, - CheckUpdates, - ListInstalledPackages, - RefreshIndexes, - ListSources, - GetPackageDetails, - GetPackageVersions, - } - - public class OperationLog - { - ManagerLogger Logger; - OperationType Type; - - string Executable; - string Arguments; - int ReturnCode; - DateTime StartTime; - DateTime? EndTime; - List StdOut = new(); - List StdErr = new(); - bool isComplete = false; - bool isOpen = false; - - public OperationLog(ManagerLogger logger, OperationType type, string executable, string arguments) - { - Type = type; - Logger = logger; - Executable = executable; - Arguments = arguments; - StartTime = DateTime.Now; - isComplete = false; - isOpen = true; - } - - public void AddStdoutLine(string? line) - { - if (!isOpen) throw new Exception("Attempted to write log into an already-closed OperationLog"); - if (line != null) - StdOut.Add(line); - } - - public void AddStdoutLines(IEnumerable lines) - { - if (!isOpen) throw new Exception("Attempted to write log into an already-closed OperationLog"); - foreach (string line in lines) - StdOut.Add(line); - } - - public void AddStderrLine(string? line) - { - if (!isOpen) throw new Exception("Attempted to write log into an already-closed OperationLog"); - if (line != null) - StdErr.Add(line); - } - - public void AddStderrLines(IEnumerable lines) - { - if (!isOpen) throw new Exception("Attempted to write log into an already-closed OperationLog"); - foreach (string line in lines) - StdErr.Add(line); - } - - public void End() - { - EndTime = DateTime.Now; - isComplete = true; - isOpen = false; - Logger.LoadOperation(this); - } - } - - PackageManager Manager; - List Operations = new(); - - - public ManagerLogger(PackageManager manager) - { - Manager = manager; - } - - private void LoadOperation(OperationLog operation) - { - Operations.Add(operation); - } - - public OperationLog CreateOperationLog(OperationType type, Process process) - { - if (process.StartInfo == null) - throw new Exception("Process instance did not have a valid StartInfo value"); - - return new OperationLog(this, type, process.StartInfo.FileName, process.StartInfo.Arguments); - } - - public OperationLog CreateNativeOperation(OperationType type, string ExtraArgument = "N/A") - { - return new OperationLog(this, type, $"{Manager.Name} native operation", ExtraArgument); - } - } -} diff --git a/src/UniGetUI.PackageEngine.ManagerLogger/UniGetUI.PackageEngine.ManagerLogger.csproj b/src/UniGetUI.PackageEngine.ManagerLogger/UniGetUI.PackageEngine.ManagerLogger.csproj deleted file mode 100644 index 37e014b74..000000000 --- a/src/UniGetUI.PackageEngine.ManagerLogger/UniGetUI.PackageEngine.ManagerLogger.csproj +++ /dev/null @@ -1,32 +0,0 @@ - - - - net8.0-windows10.0.19041.0 - enable - win-x64 - win-$(Platform) - x64 - 10.0.19041.0 - 10.0.19041.0 - 8.0.204 - true - true -3.1.1.0 -3.1.1-beta1 - UniGetUI - Martí Climent and the contributors - Martí Climent -3.1.1-beta1 - 2025, Martí Climent - enable - - - - - - - - - - -