Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TRIM Support #3108

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/UniGetUI.Core.Settings.Tests/SettingsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void TestListSettings(string SettingName, string[] ls1Array, int[] ls2Arr
Assert.Equal("this is now a test case", Settings.GetListItem<string>(SettingName, 3));
Assert.Null(Settings.GetListItem<string>(SettingName, 4));

Assert.Equal(Settings.GetListItem<string>(SettingName, 0), JsonSerializer.Deserialize<List<string>>(File.ReadAllText(Path.Join(CoreData.UniGetUIDataDirectory, $"{SettingName}.json")))[0]);
Assert.Equal(Settings.GetListItem<string>(SettingName, 0), JsonSerializer.Deserialize<List<string>>(File.ReadAllText(Path.Join(CoreData.UniGetUIDataDirectory, $"{SettingName}.json")), CoreData.SerializingOptions)[0]);

Settings.ClearList(SettingName);
Assert.Empty(Settings.GetList<object>(SettingName) ?? ["this shouldn't be null; something's wrong"]);
Expand Down Expand Up @@ -168,7 +168,7 @@ public void TestDictionarySettings(string SettingName, string[] keyArray, int[]
Settings.SetDictionaryItem(randStr, "key", 12);
Assert.Equal(12, Settings.GetDictionaryItem<string, int>(randStr, "key"));
Settings.SetDictionary(SettingName, test);
Assert.Equal(JsonSerializer.Serialize(test), File.ReadAllLines(Path.Join(CoreData.UniGetUIDataDirectory, $"{SettingName}.json"))[0]);
Assert.Equal(JsonSerializer.Serialize(test, CoreData.SerializingOptions), File.ReadAllText(Path.Join(CoreData.UniGetUIDataDirectory, $"{SettingName}.json")));
Assert.Equal(test[keyArray[0]]?.sub.count, Settings.GetDictionary<string, SerializableTest?>(SettingName)?[keyArray[0]]?.sub.count);
Assert.Equal(test[keyArray[1]]?.sub.count, Settings.GetDictionaryItem<string, SerializableTest?>(SettingName, keyArray[1])?.sub.count);
Settings.SetDictionaryItem(SettingName, keyArray[0], test[keyArray[1]]);
Expand Down Expand Up @@ -199,8 +199,8 @@ public void TestDictionarySettings(string SettingName, string[] keyArray, int[]
Assert.True(Settings.DictionaryContainsValue<string, SerializableTest?>(SettingName, test[keyArray[2]]));

Assert.Equal(
JsonSerializer.Serialize(Settings.GetDictionary<string, SerializableTest>(SettingName)),
File.ReadAllLines(Path.Join(CoreData.UniGetUIDataDirectory, $"{SettingName}.json"))[0]
JsonSerializer.Serialize(Settings.GetDictionary<string, SerializableTest>(SettingName), CoreData.SerializingOptions),
File.ReadAllText(Path.Join(CoreData.UniGetUIDataDirectory, $"{SettingName}.json"))
);

Settings.ClearDictionary(SettingName); // Cleanup
Expand Down
4 changes: 2 additions & 2 deletions src/UniGetUI.Core.Settings/SettingsEngine_Dictionaries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{
try
{
if (dictionarySettings.TryGetValue(setting, out Dictionary<object, object>? result))

Check warning on line 20 in src/UniGetUI.Core.Settings/SettingsEngine_Dictionaries.cs

View workflow job for this annotation

GitHub Actions / test-codebase

Argument of type 'Dictionary<object, object>' cannot be used as an output of type 'Dictionary<object, object?>' for parameter 'value' in 'bool ConcurrentDictionary<string, Dictionary<object, object?>>.TryGetValue(string key, out Dictionary<object, object?> value)' due to differences in the nullability of reference types.

Check warning on line 20 in src/UniGetUI.Core.Settings/SettingsEngine_Dictionaries.cs

View workflow job for this annotation

GitHub Actions / test-codebase

Argument of type 'Dictionary<object, object>' cannot be used as an output of type 'Dictionary<object, object?>' for parameter 'value' in 'bool ConcurrentDictionary<string, Dictionary<object, object?>>.TryGetValue(string key, out Dictionary<object, object?> value)' due to differences in the nullability of reference types.
{
// If the setting was cached
return result.ToDictionary(
Expand All @@ -42,7 +42,7 @@
{
if (result != "")
{
Dictionary<K, V>? item = JsonSerializer.Deserialize<Dictionary<K, V>>(result);
Dictionary<K, V>? item = JsonSerializer.Deserialize<Dictionary<K, V>>(result, CoreData.SerializingOptions);
if (item is not null)
{
value = item;
Expand Down Expand Up @@ -88,7 +88,7 @@
var file = Path.Join(CoreData.UniGetUIDataDirectory, $"{setting}.json");
try
{
if (value.Any()) File.WriteAllText(file, JsonSerializer.Serialize(value));
if (value.Any()) File.WriteAllText(file, JsonSerializer.Serialize(value, CoreData.SerializingOptions));
else if (File.Exists(file)) File.Delete(file);
}
catch (Exception e)
Expand Down
4 changes: 2 additions & 2 deletions src/UniGetUI.Core.Settings/SettingsEngine_Lists.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static partial class Settings
{
if (result != "")
{
List<T>? item = JsonSerializer.Deserialize<List<T>>(result);
List<T>? item = JsonSerializer.Deserialize<List<T>>(result, CoreData.SerializingOptions);
if (item is not null)
{
value = item;
Expand Down Expand Up @@ -76,7 +76,7 @@ public static void SetList<T>(string setting, List<T> value)
var file = Path.Join(CoreData.UniGetUIDataDirectory, $"{setting}.json");
try
{
if (value.Any()) File.WriteAllText(file, JsonSerializer.Serialize(value));
if (value.Any()) File.WriteAllText(file, JsonSerializer.Serialize(value, CoreData.SerializingOptions));
else if (File.Exists(file)) File.Delete(file);
}
catch (Exception e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace UniGetUI.PackageEngine.PackageClasses
{
public class ImportedPackage : Package
public partial class ImportedPackage : Package
{
/// <summary>
/// Construct an invalid package with a given name, id, version, source and manager, and an optional scope.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace UniGetUI.PackageEngine.PackageClasses
{
public class InvalidImportedPackage : IPackage, INotifyPropertyChanged
public partial class InvalidImportedPackage : IPackage, INotifyPropertyChanged
{
public IPackageDetails Details { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace UniGetUI.PackageEngine.PackageClasses
{
public class Package : IPackage
public partial class Package : IPackage
{
// Internal properties
private bool __is_checked;
Expand Down
4 changes: 2 additions & 2 deletions src/UniGetUI/Controls/LocalIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace UniGetUI.Interface.Widgets
{
public class LocalIcon : FontIcon
public partial class LocalIcon : FontIcon
{
public static FontFamily font = (FontFamily)Application.Current.Resources["SymbolFont"];

Expand All @@ -25,7 +25,7 @@ public LocalIcon(IconType icon) : this()
}
}

public class LocalIconSource : FontIconSource
public partial class LocalIconSource : FontIconSource
{
public static FontFamily font = (FontFamily)Application.Current.Resources["SymbolFont"];

Expand Down
82 changes: 41 additions & 41 deletions src/UniGetUI/Controls/MenuForPackage.cs
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using UniGetUI.Core.Tools;
using UniGetUI.Interface.Enums;

namespace UniGetUI.Interface.Widgets
{
public class BetterMenu : MenuFlyout
{
private readonly Style menuyStyle = (Style)Application.Current.Resources["BetterContextMenu"];
public BetterMenu()
{
MenuFlyoutPresenterStyle = menuyStyle;
}
}

public class BetterMenuItem : MenuFlyoutItem
{
private readonly Style menuStyle = (Style)Application.Current.Resources["BetterMenuItem"];

public IconType IconName
{
set
{
var icon = new LocalIcon(value);
icon.FontSize = 24;
Icon = icon;
}
}

public new string Text
{
set => base.Text = CoreTools.Translate(value);
}

public BetterMenuItem()
{
Style = menuStyle;
}
}
}
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using UniGetUI.Core.Tools;
using UniGetUI.Interface.Enums;
namespace UniGetUI.Interface.Widgets
{
public partial class BetterMenu : MenuFlyout
{
private readonly Style menuyStyle = (Style)Application.Current.Resources["BetterContextMenu"];
public BetterMenu()
{
MenuFlyoutPresenterStyle = menuyStyle;
}
}
public partial class BetterMenuItem : MenuFlyoutItem
{
private readonly Style menuStyle = (Style)Application.Current.Resources["BetterMenuItem"];
public IconType IconName
{
set
{
var icon = new LocalIcon(value);
icon.FontSize = 24;
Icon = icon;
}
}
public new string Text
{
set => base.Text = CoreTools.Translate(value);
}
public BetterMenuItem()
{
Style = menuStyle;
}
}
}
2 changes: 1 addition & 1 deletion src/UniGetUI/Controls/ObservablePackageCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace UniGetUI.PackageEngine.PackageClasses
/// <summary>
/// A special ObservableCollection designed to work with Package objects
/// </summary>
public class ObservablePackageCollection : SortableObservableCollection<PackageWrapper>
public partial class ObservablePackageCollection : SortableObservableCollection<PackageWrapper>
{
public enum Sorter
{
Expand Down
6 changes: 3 additions & 3 deletions src/UniGetUI/Controls/OperationWidgets/PackageOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ protected override void PostProcessEndAction()
}
}

public class InstallPackageOperation : PackageOperation
public partial class InstallPackageOperation : PackageOperation
{

public InstallPackageOperation(
Expand Down Expand Up @@ -306,7 +306,7 @@ protected override async Task Initialize()
}
}

public class UpdatePackageOperation : PackageOperation
public partial class UpdatePackageOperation : PackageOperation
{

public UpdatePackageOperation(
Expand Down Expand Up @@ -391,7 +391,7 @@ protected override async Task Initialize()
}
}

public class UninstallPackageOperation : PackageOperation
public partial class UninstallPackageOperation : PackageOperation
{

public UninstallPackageOperation(
Expand Down
4 changes: 2 additions & 2 deletions src/UniGetUI/Controls/OperationWidgets/SourceOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected override void PostProcessEndAction()
}
}

public class AddSourceOperation : SourceOperation
public partial class AddSourceOperation : SourceOperation
{

public event EventHandler<EventArgs>? OperationSucceeded;
Expand Down Expand Up @@ -197,7 +197,7 @@ protected override async Task Initialize()
}
}

public class RemoveSourceOperation : SourceOperation
public partial class RemoveSourceOperation : SourceOperation
{

public event EventHandler<EventArgs>? OperationSucceeded;
Expand Down
2 changes: 1 addition & 1 deletion src/UniGetUI/Controls/PackageItemContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace UniGetUI.Interface.Widgets
{
public class PackageItemContainer : ItemContainer
public partial class PackageItemContainer : ItemContainer
{
public IPackage? Package { get; set; }
public PackageWrapper Wrapper { get; set; } = null!;
Expand Down
2 changes: 1 addition & 1 deletion src/UniGetUI/Controls/PackageWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace UniGetUI.PackageEngine.PackageClasses
/// <summary>
/// A wrapper for packages to be able to show in ItemCollections
/// </summary>
public class PackageWrapper : IIndexableListItem, INotifyPropertyChanged, IDisposable
public partial class PackageWrapper : IIndexableListItem, INotifyPropertyChanged, IDisposable
{
private static readonly ConcurrentDictionary<long, Uri?> CachedPackageIcons = new();

Expand Down
2 changes: 1 addition & 1 deletion src/UniGetUI/Controls/SettingsWidgets/ButtonCard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace UniGetUI.Interface.Widgets
{
public sealed class ButtonCard : SettingsCard
public sealed partial class ButtonCard : SettingsCard
{
private readonly Button _button = new();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace UniGetUI.Interface.Widgets
{
public sealed class CheckboxButtonCard : SettingsCard
public sealed partial class CheckboxButtonCard : SettingsCard
{
public CheckBox CheckBox;
public Button Button;
Expand Down
2 changes: 1 addition & 1 deletion src/UniGetUI/Controls/SettingsWidgets/CheckboxCard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace UniGetUI.Interface.Widgets
{
public sealed class CheckboxCard : SettingsCard
public sealed partial class CheckboxCard : SettingsCard
{
public CheckBox _checkbox;
private bool IS_INVERTED;
Expand Down
2 changes: 1 addition & 1 deletion src/UniGetUI/Controls/SettingsWidgets/ComboboxCard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace UniGetUI.Interface.Widgets
{
public sealed class ComboboxCard : SettingsCard
public sealed partial class ComboboxCard : SettingsCard
{
private readonly ComboBox _combobox = new();
private readonly ObservableCollection<string> _elements = new();
Expand Down
2 changes: 1 addition & 1 deletion src/UniGetUI/Controls/SettingsWidgets/SettingsEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace UniGetUI.Interface.Widgets
{
public sealed class SettingsEntry : SettingsExpander
public sealed partial class SettingsEntry : SettingsExpander
{
private readonly InfoBar infoBar;
private readonly Button RestartButton;
Expand Down
2 changes: 1 addition & 1 deletion src/UniGetUI/Controls/SettingsWidgets/TextboxCard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace UniGetUI.Interface.Widgets
{
public sealed class TextboxCard : SettingsCard
public sealed partial class TextboxCard : SettingsCard
{
private readonly TextBox _textbox = new();
private readonly HyperlinkButton _helpbutton = new();
Expand Down
2 changes: 1 addition & 1 deletion src/UniGetUI/Pages/DialogPages/DesktopShortcuts.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void SaveChangesAndClose()
}
}

public class ShortcutEntry : INotifyPropertyChanged
public partial class ShortcutEntry : INotifyPropertyChanged
{
public event EventHandler<EventArgs>? OnReset;

Expand Down
2 changes: 1 addition & 1 deletion src/UniGetUI/Pages/LogPages/ManagerLogsPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace UniGetUI.Interface.Pages.LogPage
{
public class ManagerLogsPage : BaseLogPage
public partial class ManagerLogsPage : BaseLogPage
{

public ManagerLogsPage() : base(true)
Expand Down
2 changes: 1 addition & 1 deletion src/UniGetUI/Pages/LogPages/OperationHistoryPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace UniGetUI.Interface.Pages.LogPage
{
public class OperationHistoryPage : BaseLogPage
public partial class OperationHistoryPage : BaseLogPage
{
public OperationHistoryPage() : base(false)
{
Expand Down
4 changes: 2 additions & 2 deletions src/UniGetUI/Pages/LogPages/UniGetUILogPage.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using Microsoft.UI.Xaml.Documents;
using Microsoft.UI.Xaml.Documents;
using Microsoft.UI.Xaml.Media;
using UniGetUI.Core.Logging;
using UniGetUI.Core.Tools;

namespace UniGetUI.Interface.Pages.LogPage
{
public sealed class UniGetUILogPage : BaseLogPage
public sealed partial class UniGetUILogPage : BaseLogPage
{
public UniGetUILogPage() : base(true)
{
Expand Down
2 changes: 1 addition & 1 deletion src/UniGetUI/Pages/SoftwarePages/DiscoverSoftwarePage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace UniGetUI.Interface.SoftwarePages
{
public class DiscoverSoftwarePage : AbstractPackagesPage
public partial class DiscoverSoftwarePage : AbstractPackagesPage
{
private BetterMenuItem? MenuAsAdmin;
private BetterMenuItem? MenuInteractive;
Expand Down
2 changes: 1 addition & 1 deletion src/UniGetUI/Pages/SoftwarePages/InstalledPackagesPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace UniGetUI.Interface.SoftwarePages
{
public class InstalledPackagesPage : AbstractPackagesPage
public partial class InstalledPackagesPage : AbstractPackagesPage
{
private bool HasDoneBackup;

Expand Down
2 changes: 1 addition & 1 deletion src/UniGetUI/Pages/SoftwarePages/PackageBundlesPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

namespace UniGetUI.Interface.SoftwarePages
{
public class PackageBundlesPage : AbstractPackagesPage
public partial class PackageBundlesPage : AbstractPackagesPage
{
private BetterMenuItem? MenuInstallOptions;
private BetterMenuItem? MenuInstall;
Expand Down
2 changes: 1 addition & 1 deletion src/UniGetUI/Pages/SoftwarePages/SoftwareUpdatesPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace UniGetUI.Interface.SoftwarePages
{
public class SoftwareUpdatesPage : AbstractPackagesPage
public partial class SoftwareUpdatesPage : AbstractPackagesPage
{
private BetterMenuItem? MenuAsAdmin;
private BetterMenuItem? MenuInteractive;
Expand Down
Loading
Loading