diff --git a/.gitattributes b/.gitattributes
index fb2ccc79f0..1b8a169a6c 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1 +1,2 @@
-src/UniGetUI.PackageEngine.Managers.Chocolatey/choco-cli/** linguist-vendored
\ No newline at end of file
+src/UniGetUI.PackageEngine.Managers.Chocolatey/choco-cli/** linguist-vendored
+.githooks/* text eol=lf
\ No newline at end of file
diff --git a/.githooks/pre-commit b/.githooks/pre-commit
new file mode 100644
index 0000000000..45f6cfe32c
--- /dev/null
+++ b/.githooks/pre-commit
@@ -0,0 +1,38 @@
+#!/usr/bin/env sh
+
+set -eu
+
+repo_root=$(git rev-parse --show-toplevel)
+cd "$repo_root"
+
+staged_files=$(git diff --cached --name-only --diff-filter=ACMR -- src | grep -E '\.(cs|csproj|props|targets|editorconfig|json|sln|slnx)$' || true)
+
+if [ -z "$staged_files" ]; then
+ exit 0
+fi
+
+unstaged_files=$(git diff --name-only -- $staged_files || true)
+if [ -n "$unstaged_files" ]; then
+ echo "pre-commit: relevant files have unstaged changes."
+ echo "Stage or stash them before committing so dotnet format does not rewrite mixed content."
+ printf '%s\n' "$unstaged_files"
+ exit 1
+fi
+
+if ! command -v dotnet >/dev/null 2>&1; then
+ echo "pre-commit: dotnet CLI not found; skipping whitespace formatting."
+ exit 0
+fi
+
+echo "pre-commit: running dotnet format whitespace on staged src files"
+
+# shellcheck disable=SC2086
+dotnet format whitespace src --folder --verbosity minimal --include $staged_files
+
+if ! git diff --quiet -- $staged_files; then
+ git add -- $staged_files
+ echo "pre-commit: formatting updates were staged. Review them and run git commit again."
+ exit 1
+fi
+
+exit 0
\ No newline at end of file
diff --git a/.github/workflows/dotnet-test.yml b/.github/workflows/dotnet-test.yml
index 1a63e7928f..e2c0e3a610 100644
--- a/.github/workflows/dotnet-test.yml
+++ b/.github/workflows/dotnet-test.yml
@@ -5,7 +5,10 @@ on:
paths:
- '**.cs'
- '**.csproj'
+ - '**.props'
+ - '**.targets'
- '**.sln'
+ - 'src/.editorconfig'
- '.github/workflows/dotnet-test.yml'
pull_request:
@@ -13,7 +16,10 @@ on:
paths:
- '**.cs'
- '**.csproj'
+ - '**.props'
+ - '**.targets'
- '**.sln'
+ - 'src/.editorconfig'
- '.github/workflows/dotnet-test.yml'
workflow_dispatch:
@@ -47,6 +53,13 @@ jobs:
working-directory: src
run: dotnet restore UniGetUI.sln
+ - name: Check whitespace formatting
+ run: dotnet format whitespace src --folder --verify-no-changes --verbosity minimal
+
+ - name: Check code style formatting
+ working-directory: src
+ run: dotnet format style UniGetUI.sln --no-restore --verify-no-changes --verbosity minimal
+
- name: Run Tests
working-directory: src
run: dotnet test UniGetUI.sln --no-restore --verbosity q --nologo
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 4b907cc984..e7e59745a4 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -38,6 +38,14 @@ Before reading: All of the rules below are guidelines, which means that they sho
- Draft pull requests should be properly identified as [draft pull requests](https://github.blog/2019-02-14-introducing-draft-pull-requests/) to avoid confusion.
- When modifying/coding, please follow the guidelines below:
+## Formatting:
+ - Run `pwsh ./scripts/install-git-hooks.ps1` once after cloning to enable the repository pre-commit hook.
+- The pre-commit hook runs `dotnet format whitespace src --folder` on staged files under `src` when the `dotnet` CLI is available, and stops the commit if it had to rewrite files so you can review the changes and commit again.
+ - CI enforces whitespace formatting with `dotnet format whitespace src --folder --verify-no-changes` and code-style verification with `dotnet format style src/UniGetUI.sln --no-restore --verify-no-changes` in `.github/workflows/dotnet-test.yml`.
+ - The pre-commit hook intentionally does not run `dotnet format style` because solution loading makes it take roughly the same time for one staged C# file as for the full solution.
+ - If you want to check the same style rules locally before pushing, run `dotnet format style src/UniGetUI.sln --no-restore --verify-no-changes` from the repository root.
+ - If you want to prepare a dedicated formatting-only commit, run `dotnet format whitespace src --folder` from the repository root.
+
## Coding:
- As a repository standard, every function and variable name should use camelCase.
- Correct usage: `updatesCount = 0`, `def searchForUpdates(packageManager):`
diff --git a/scripts/install-git-hooks.ps1 b/scripts/install-git-hooks.ps1
new file mode 100644
index 0000000000..54cdc94511
--- /dev/null
+++ b/scripts/install-git-hooks.ps1
@@ -0,0 +1,8 @@
+$ErrorActionPreference = 'Stop'
+
+$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
+
+git -C $repoRoot config core.hooksPath .githooks
+
+Write-Host 'Configured git hooks path to .githooks' -ForegroundColor Green
+Write-Host 'The pre-commit hook will run dotnet format whitespace on staged files under src.' -ForegroundColor Green
\ No newline at end of file
diff --git a/src/.editorconfig b/src/.editorconfig
index 8c85072a5f..c2a8f3bef2 100644
--- a/src/.editorconfig
+++ b/src/.editorconfig
@@ -280,7 +280,7 @@ dotnet_diagnostic.CA2246.severity = warning
dotnet_diagnostic.CA2249.severity = warning
# IDE0005: Remove unnecessary usings
-dotnet_diagnostic.IDE0005.severity = warning
+dotnet_diagnostic.IDE0005.severity = suggestion
# IDE0011: Curly braces to surround blocks of code
dotnet_diagnostic.IDE0011.severity = warning
@@ -343,6 +343,15 @@ dotnet_diagnostic.IDE0200.severity = warning
dotnet_style_allow_multiple_blank_lines_experimental = false
dotnet_diagnostic.IDE2000.severity = warning
+# WinUI code-behind relies on XAML-wired event handlers that Roslyn cannot
+# reliably see as C# references.
+[UniGetUI/**.cs]
+dotnet_diagnostic.IDE0051.severity = suggestion
+dotnet_diagnostic.IDE0060.severity = suggestion
+
+[UniGetUI/Controls/SourceManager.xaml.cs]
+dotnet_diagnostic.IDE0044.severity = suggestion
+
###### End of EditorConfig from dotnet/aspnetcore repository
### Our rules
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 2cea04fc32..42c53f52c4 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -17,9 +17,16 @@
- true
- $(PortableTargetFramework);$(WindowsTargetFramework)
- $(PortableTargetFramework)
+ true
+ $(PortableTargetFramework);$(WindowsTargetFramework)
+ $(PortableTargetFramework)
@@ -31,7 +38,10 @@
10.0.26100.56
true
win-x64;win-arm64
- win-$(Platform)
+ win-$(Platform)
diff --git a/src/ExternalLibraries.Clipboard/ExternalLibraries.Clipboard.csproj b/src/ExternalLibraries.Clipboard/ExternalLibraries.Clipboard.csproj
index 1c504771f0..317faf91f8 100644
--- a/src/ExternalLibraries.Clipboard/ExternalLibraries.Clipboard.csproj
+++ b/src/ExternalLibraries.Clipboard/ExternalLibraries.Clipboard.csproj
@@ -1,10 +1,6 @@
-
-
- $(WindowsTargetFramework)
-
-
-
-
-
+
+ $(WindowsTargetFramework)
+
+
diff --git a/src/ExternalLibraries.FilePickers/Classes/FileOpenDialogRCW.cs b/src/ExternalLibraries.FilePickers/Classes/FileOpenDialogRCW.cs
index b54f8c31b1..83181b7830 100644
--- a/src/ExternalLibraries.FilePickers/Classes/FileOpenDialogRCW.cs
+++ b/src/ExternalLibraries.FilePickers/Classes/FileOpenDialogRCW.cs
@@ -1,14 +1,14 @@
-using System.Runtime.InteropServices;
+using System.Runtime.InteropServices;
using ExternalLibraries.Pickers.Guids;
namespace ExternalLibraries.Pickers.Classes;
// ---------------------------------------------------
// .NET classes representing runtime callable wrappers
-[ComImport,
-ClassInterface(ClassInterfaceType.None),
-TypeLibType(TypeLibTypeFlags.FCanCreate),
-Guid(CLSIDGuid.FileOpenDialog)]
-internal class FileOpenDialogRCW
-{
-}
\ No newline at end of file
+[
+ ComImport,
+ ClassInterface(ClassInterfaceType.None),
+ TypeLibType(TypeLibTypeFlags.FCanCreate),
+ Guid(CLSIDGuid.FileOpenDialog)
+]
+internal class FileOpenDialogRCW { }
diff --git a/src/ExternalLibraries.FilePickers/Classes/FileSaveDialogRCW.cs b/src/ExternalLibraries.FilePickers/Classes/FileSaveDialogRCW.cs
index 96a69092fe..ffd05fda99 100644
--- a/src/ExternalLibraries.FilePickers/Classes/FileSaveDialogRCW.cs
+++ b/src/ExternalLibraries.FilePickers/Classes/FileSaveDialogRCW.cs
@@ -1,14 +1,14 @@
-using System.Runtime.InteropServices;
+using System.Runtime.InteropServices;
using ExternalLibraries.Pickers.Guids;
namespace ExternalLibraries.Pickers.Classes;
// ---------------------------------------------------
// .NET classes representing runtime callable wrappers
-[ComImport,
-ClassInterface(ClassInterfaceType.None),
-TypeLibType(TypeLibTypeFlags.FCanCreate),
-Guid(CLSIDGuid.FileSaveDialog)]
-internal class FileSaveDialogRCW
-{
-}
+[
+ ComImport,
+ ClassInterface(ClassInterfaceType.None),
+ TypeLibType(TypeLibTypeFlags.FCanCreate),
+ Guid(CLSIDGuid.FileSaveDialog)
+]
+internal class FileSaveDialogRCW { }
diff --git a/src/ExternalLibraries.FilePickers/Classes/Helper.cs b/src/ExternalLibraries.FilePickers/Classes/Helper.cs
index 56a6a379a7..bd040acba1 100644
--- a/src/ExternalLibraries.FilePickers/Classes/Helper.cs
+++ b/src/ExternalLibraries.FilePickers/Classes/Helper.cs
@@ -1,4 +1,4 @@
-using System.Runtime.InteropServices;
+using System.Runtime.InteropServices;
using ExternalLibraries.Pickers.Enums;
using ExternalLibraries.Pickers.Interfaces;
using ExternalLibraries.Pickers.Structures;
@@ -24,7 +24,9 @@ internal static string ShowOpen(nint windowHandle, FOS fos, List? typeFi
if (typeFilters is not null)
{
typeFilters.Insert(0, string.Join("; ", typeFilters));
- COMDLG_FILTERSPEC[] filterSpecs = typeFilters.Select(f => new COMDLG_FILTERSPEC(f)).ToArray();
+ COMDLG_FILTERSPEC[] filterSpecs = typeFilters
+ .Select(f => new COMDLG_FILTERSPEC(f))
+ .ToArray();
dialog.SetFileTypes((uint)filterSpecs.Length, filterSpecs);
}
@@ -46,7 +48,12 @@ internal static string ShowOpen(nint windowHandle, FOS fos, List? typeFi
}
}
- internal static string ShowSave(nint windowHandle, FOS fos, List? typeFilters = null, string name = "")
+ internal static string ShowSave(
+ nint windowHandle,
+ FOS fos,
+ List? typeFilters = null,
+ string name = ""
+ )
{
FileSaveDialog dialog = new();
try
@@ -55,7 +62,9 @@ internal static string ShowSave(nint windowHandle, FOS fos, List? typeFi
if (typeFilters is not null)
{
- COMDLG_FILTERSPEC[] filterSpecs = typeFilters.Select(f => new COMDLG_FILTERSPEC(f)).ToArray();
+ COMDLG_FILTERSPEC[] filterSpecs = typeFilters
+ .Select(f => new COMDLG_FILTERSPEC(f))
+ .ToArray();
dialog.SetFileTypes((uint)filterSpecs.Length, filterSpecs);
}
@@ -78,7 +87,7 @@ internal static string ShowSave(nint windowHandle, FOS fos, List? typeFi
if (fileExtension.Length > 0 && fileExtension[0] == '*')
fileExtension = fileExtension.TrimStart('*');
- return path.Contains(fileExtension)? path: path + fileExtension;
+ return path.Contains(fileExtension) ? path : path + fileExtension;
}
finally
{
diff --git a/src/ExternalLibraries.FilePickers/Enums/FDAP.cs b/src/ExternalLibraries.FilePickers/Enums/FDAP.cs
index c6347e9328..ff698114e1 100644
--- a/src/ExternalLibraries.FilePickers/Enums/FDAP.cs
+++ b/src/ExternalLibraries.FilePickers/Enums/FDAP.cs
@@ -1,4 +1,4 @@
-namespace ExternalLibraries.Pickers.Enums;
+namespace ExternalLibraries.Pickers.Enums;
// https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-fdap
internal enum FDAP
diff --git a/src/ExternalLibraries.FilePickers/Enums/FDE_OVERWRITE_RESPONSE.cs b/src/ExternalLibraries.FilePickers/Enums/FDE_OVERWRITE_RESPONSE.cs
index 011f2bdaa0..4056b0558e 100644
--- a/src/ExternalLibraries.FilePickers/Enums/FDE_OVERWRITE_RESPONSE.cs
+++ b/src/ExternalLibraries.FilePickers/Enums/FDE_OVERWRITE_RESPONSE.cs
@@ -1,9 +1,9 @@
-namespace ExternalLibraries.Pickers.Enums;
+namespace ExternalLibraries.Pickers.Enums;
// https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-fde_overwrite_response
internal enum FDE_OVERWRITE_RESPONSE
{
FDEOR_DEFAULT = 0x00000000,
FDEOR_ACCEPT = 0x00000001,
- FDEOR_REFUSE = 0x00000002
+ FDEOR_REFUSE = 0x00000002,
}
diff --git a/src/ExternalLibraries.FilePickers/Enums/FDE_SHAREVIOLATION_RESPONSE.cs b/src/ExternalLibraries.FilePickers/Enums/FDE_SHAREVIOLATION_RESPONSE.cs
index 71fb59290f..0c7cb4dbe7 100644
--- a/src/ExternalLibraries.FilePickers/Enums/FDE_SHAREVIOLATION_RESPONSE.cs
+++ b/src/ExternalLibraries.FilePickers/Enums/FDE_SHAREVIOLATION_RESPONSE.cs
@@ -1,9 +1,9 @@
-namespace ExternalLibraries.Pickers.Enums;
+namespace ExternalLibraries.Pickers.Enums;
// https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-fde_shareviolation_response
internal enum FDE_SHAREVIOLATION_RESPONSE
{
FDESVR_DEFAULT = 0x00000000,
FDESVR_ACCEPT = 0x00000001,
- FDESVR_REFUSE = 0x00000002
+ FDESVR_REFUSE = 0x00000002,
}
diff --git a/src/ExternalLibraries.FilePickers/Enums/FOS.cs b/src/ExternalLibraries.FilePickers/Enums/FOS.cs
index 5504ea162d..3bfb7aa97e 100644
--- a/src/ExternalLibraries.FilePickers/Enums/FOS.cs
+++ b/src/ExternalLibraries.FilePickers/Enums/FOS.cs
@@ -1,4 +1,4 @@
-namespace ExternalLibraries.Pickers.Enums;
+namespace ExternalLibraries.Pickers.Enums;
[Flags]
// https://learn.microsoft.com/ru-ru/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptions
@@ -23,5 +23,5 @@ internal enum FOS : uint
FOS_NODEREFERENCELINKS = 0x00100000,
FOS_DONTADDTORECENT = 0x02000000,
FOS_FORCESHOWHIDDEN = 0x10000000,
- FOS_DEFAULTNOMINIMODE = 0x20000000
+ FOS_DEFAULTNOMINIMODE = 0x20000000,
}
diff --git a/src/ExternalLibraries.FilePickers/Enums/HRESULT.cs b/src/ExternalLibraries.FilePickers/Enums/HRESULT.cs
index 2bbc83dbff..3bec281c97 100644
--- a/src/ExternalLibraries.FilePickers/Enums/HRESULT.cs
+++ b/src/ExternalLibraries.FilePickers/Enums/HRESULT.cs
@@ -1,4 +1,4 @@
-namespace ExternalLibraries.Pickers.Enums;
+namespace ExternalLibraries.Pickers.Enums;
internal enum HRESULT : long
{
@@ -6,5 +6,5 @@ internal enum HRESULT : long
S_OK = 0x0000,
E_INVALIDARG = 0x80070057,
E_OUTOFMEMORY = 0x8007000E,
- ERROR_CANCELLED = 0x800704C7
+ ERROR_CANCELLED = 0x800704C7,
}
diff --git a/src/ExternalLibraries.FilePickers/Enums/SIGDN.cs b/src/ExternalLibraries.FilePickers/Enums/SIGDN.cs
index 0b2456d0d9..40037cb880 100644
--- a/src/ExternalLibraries.FilePickers/Enums/SIGDN.cs
+++ b/src/ExternalLibraries.FilePickers/Enums/SIGDN.cs
@@ -1,15 +1,15 @@
-namespace ExternalLibraries.Pickers.Enums;
+namespace ExternalLibraries.Pickers.Enums;
// https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-sigdn
internal enum SIGDN : uint
{
- SIGDN_NORMALDISPLAY = 0x00000000, // SHGDN_NORMAL
- SIGDN_PARENTRELATIVEPARSING = 0x80018001, // SHGDN_INFOLDER | SHGDN_FORPARSING
- SIGDN_DESKTOPABSOLUTEPARSING = 0x80028000, // SHGDN_FORPARSING
- SIGDN_PARENTRELATIVEEDITING = 0x80031001, // SHGDN_INFOLDER | SHGDN_FOREDITING
- SIGDN_DESKTOPABSOLUTEEDITING = 0x8004c000, // SHGDN_FORPARSING | SHGDN_FORADDRESSBAR
- SIGDN_FILESYSPATH = 0x80058000, // SHGDN_FORPARSING
- SIGDN_URL = 0x80068000, // SHGDN_FORPARSING
- SIGDN_PARENTRELATIVEFORADDRESSBAR = 0x8007c001, // SHGDN_INFOLDER | SHGDN_FORPARSING | SHGDN_FORADDRESSBAR
- SIGDN_PARENTRELATIVE = 0x80080001 // SHGDN_INFOLDER
+ SIGDN_NORMALDISPLAY = 0x00000000, // SHGDN_NORMAL
+ SIGDN_PARENTRELATIVEPARSING = 0x80018001, // SHGDN_INFOLDER | SHGDN_FORPARSING
+ SIGDN_DESKTOPABSOLUTEPARSING = 0x80028000, // SHGDN_FORPARSING
+ SIGDN_PARENTRELATIVEEDITING = 0x80031001, // SHGDN_INFOLDER | SHGDN_FOREDITING
+ SIGDN_DESKTOPABSOLUTEEDITING = 0x8004c000, // SHGDN_FORPARSING | SHGDN_FORADDRESSBAR
+ SIGDN_FILESYSPATH = 0x80058000, // SHGDN_FORPARSING
+ SIGDN_URL = 0x80068000, // SHGDN_FORPARSING
+ SIGDN_PARENTRELATIVEFORADDRESSBAR = 0x8007c001, // SHGDN_INFOLDER | SHGDN_FORPARSING | SHGDN_FORADDRESSBAR
+ SIGDN_PARENTRELATIVE = 0x80080001, // SHGDN_INFOLDER
}
diff --git a/src/ExternalLibraries.FilePickers/ExternalLibraries.FilePickers.csproj b/src/ExternalLibraries.FilePickers/ExternalLibraries.FilePickers.csproj
index 1c504771f0..317faf91f8 100644
--- a/src/ExternalLibraries.FilePickers/ExternalLibraries.FilePickers.csproj
+++ b/src/ExternalLibraries.FilePickers/ExternalLibraries.FilePickers.csproj
@@ -1,10 +1,6 @@
-
-
- $(WindowsTargetFramework)
-
-
-
-
-
+
+ $(WindowsTargetFramework)
+
+
diff --git a/src/ExternalLibraries.FilePickers/FileOpenPicker.cs b/src/ExternalLibraries.FilePickers/FileOpenPicker.cs
index 0f86c05da6..365e393a40 100644
--- a/src/ExternalLibraries.FilePickers/FileOpenPicker.cs
+++ b/src/ExternalLibraries.FilePickers/FileOpenPicker.cs
@@ -1,4 +1,4 @@
-using ExternalLibraries.Pickers.Classes;
+using ExternalLibraries.Pickers.Classes;
using ExternalLibraries.Pickers.Enums;
namespace ExternalLibraries.Pickers;
diff --git a/src/ExternalLibraries.FilePickers/FileSavePicker.cs b/src/ExternalLibraries.FilePickers/FileSavePicker.cs
index 1059728807..917ad60647 100644
--- a/src/ExternalLibraries.FilePickers/FileSavePicker.cs
+++ b/src/ExternalLibraries.FilePickers/FileSavePicker.cs
@@ -1,4 +1,4 @@
-using ExternalLibraries.Pickers.Classes;
+using ExternalLibraries.Pickers.Classes;
using ExternalLibraries.Pickers.Enums;
namespace ExternalLibraries.Pickers;
diff --git a/src/ExternalLibraries.FilePickers/FolderPicker.cs b/src/ExternalLibraries.FilePickers/FolderPicker.cs
index 0642f9e2a4..f241217237 100644
--- a/src/ExternalLibraries.FilePickers/FolderPicker.cs
+++ b/src/ExternalLibraries.FilePickers/FolderPicker.cs
@@ -1,4 +1,4 @@
-using ExternalLibraries.Pickers.Classes;
+using ExternalLibraries.Pickers.Classes;
using ExternalLibraries.Pickers.Enums;
namespace ExternalLibraries.Pickers;
diff --git a/src/ExternalLibraries.FilePickers/Guids/CLSIDGuid.cs b/src/ExternalLibraries.FilePickers/Guids/CLSIDGuid.cs
index 228f4ed353..0e42f31158 100644
--- a/src/ExternalLibraries.FilePickers/Guids/CLSIDGuid.cs
+++ b/src/ExternalLibraries.FilePickers/Guids/CLSIDGuid.cs
@@ -1,4 +1,4 @@
-namespace ExternalLibraries.Pickers.Guids;
+namespace ExternalLibraries.Pickers.Guids;
internal static class CLSIDGuid
{
diff --git a/src/ExternalLibraries.FilePickers/Guids/IIDGuid.cs b/src/ExternalLibraries.FilePickers/Guids/IIDGuid.cs
index a0f1878073..22e824da89 100644
--- a/src/ExternalLibraries.FilePickers/Guids/IIDGuid.cs
+++ b/src/ExternalLibraries.FilePickers/Guids/IIDGuid.cs
@@ -1,4 +1,4 @@
-namespace ExternalLibraries.Pickers.Guids;
+namespace ExternalLibraries.Pickers.Guids;
internal static class IIDGuid
{
diff --git a/src/ExternalLibraries.FilePickers/Guids/KFIDGuid.cs b/src/ExternalLibraries.FilePickers/Guids/KFIDGuid.cs
index b51f3740d8..a959a87c68 100644
--- a/src/ExternalLibraries.FilePickers/Guids/KFIDGuid.cs
+++ b/src/ExternalLibraries.FilePickers/Guids/KFIDGuid.cs
@@ -1,4 +1,4 @@
-namespace ExternalLibraries.Pickers.Guids;
+namespace ExternalLibraries.Pickers.Guids;
internal static class KFIDGuid
{
diff --git a/src/ExternalLibraries.FilePickers/Interfaces/FileOpenDialog.cs b/src/ExternalLibraries.FilePickers/Interfaces/FileOpenDialog.cs
index 9cddb1024f..2284c73339 100644
--- a/src/ExternalLibraries.FilePickers/Interfaces/FileOpenDialog.cs
+++ b/src/ExternalLibraries.FilePickers/Interfaces/FileOpenDialog.cs
@@ -1,17 +1,13 @@
-using System.Runtime.InteropServices;
+using System.Runtime.InteropServices;
using ExternalLibraries.Pickers.Classes;
using ExternalLibraries.Pickers.Guids;
namespace ExternalLibraries.Pickers.Interfaces;
// ---------------------------------------------------------
-// Coclass interfaces - designed to "look like" the object
-// in the API, so that the 'new' operator can be used in a
+// Coclass interfaces - designed to "look like" the object
+// in the API, so that the 'new' operator can be used in a
// straightforward way. Behind the scenes, the C# compiler
// morphs all 'new CoClass()' calls to 'new CoClassWrapper()'
-[ComImport,
-Guid(IIDGuid.IFileOpenDialog),
-CoClass(typeof(FileOpenDialogRCW))]
-internal interface FileOpenDialog : IFileOpenDialog
-{
-}
\ No newline at end of file
+[ComImport, Guid(IIDGuid.IFileOpenDialog), CoClass(typeof(FileOpenDialogRCW))]
+internal interface FileOpenDialog : IFileOpenDialog { }
diff --git a/src/ExternalLibraries.FilePickers/Interfaces/FileSaveDialog.cs b/src/ExternalLibraries.FilePickers/Interfaces/FileSaveDialog.cs
index 2f76d7e805..1f8240d100 100644
--- a/src/ExternalLibraries.FilePickers/Interfaces/FileSaveDialog.cs
+++ b/src/ExternalLibraries.FilePickers/Interfaces/FileSaveDialog.cs
@@ -1,17 +1,13 @@
-using System.Runtime.InteropServices;
+using System.Runtime.InteropServices;
using ExternalLibraries.Pickers.Classes;
using ExternalLibraries.Pickers.Guids;
namespace ExternalLibraries.Pickers.Interfaces;
// ---------------------------------------------------------
-// Coclass interfaces - designed to "look like" the object
-// in the API, so that the 'new' operator can be used in a
+// Coclass interfaces - designed to "look like" the object
+// in the API, so that the 'new' operator can be used in a
// straightforward way. Behind the scenes, the C# compiler
// morphs all 'new CoClass()' calls to 'new CoClassWrapper()'
-[ComImport,
-Guid(IIDGuid.IFileSaveDialog),
-CoClass(typeof(FileSaveDialogRCW))]
-internal interface FileSaveDialog : IFileSaveDialog
-{
-}
+[ComImport, Guid(IIDGuid.IFileSaveDialog), CoClass(typeof(FileSaveDialogRCW))]
+internal interface FileSaveDialog : IFileSaveDialog { }
diff --git a/src/ExternalLibraries.FilePickers/Interfaces/IFileDialog.cs b/src/ExternalLibraries.FilePickers/Interfaces/IFileDialog.cs
index 12f2955bad..23a49dd1de 100644
--- a/src/ExternalLibraries.FilePickers/Interfaces/IFileDialog.cs
+++ b/src/ExternalLibraries.FilePickers/Interfaces/IFileDialog.cs
@@ -1,4 +1,4 @@
-using System.Runtime.CompilerServices;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ExternalLibraries.Pickers.Enums;
using ExternalLibraries.Pickers.Guids;
@@ -6,21 +6,24 @@
namespace ExternalLibraries.Pickers.Interfaces;
-[ComImport(),
-Guid(IIDGuid.IFileDialog),
-InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+[ComImport(), Guid(IIDGuid.IFileDialog), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IFileDialog : IModalWindow
{
// Defined on IModalWindow - repeated here due to requirements of COM interop layer
// --------------------------------------------------------------------------------
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime),
- PreserveSig]
+ [
+ MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime),
+ PreserveSig
+ ]
new int Show([In] IntPtr parent);
// IFileDialog-Specific interface members
// --------------------------------------------------------------------------------
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
- void SetFileTypes([In] uint cFileTypes, [In, MarshalAs(UnmanagedType.LPArray)] COMDLG_FILTERSPEC[] rgFilterSpec);
+ void SetFileTypes(
+ [In] uint cFileTypes,
+ [In, MarshalAs(UnmanagedType.LPArray)] COMDLG_FILTERSPEC[] rgFilterSpec
+ );
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
void SetFileTypeIndex([In] uint iFileType);
@@ -29,7 +32,10 @@ internal interface IFileDialog : IModalWindow
void GetFileTypeIndex(out uint piFileType);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
- void Advise([In, MarshalAs(UnmanagedType.Interface)] IFileDialogEvents pfde, out uint pdwCookie);
+ void Advise(
+ [In, MarshalAs(UnmanagedType.Interface)] IFileDialogEvents pfde,
+ out uint pdwCookie
+ );
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
void Unadvise([In] uint dwCookie);
diff --git a/src/ExternalLibraries.FilePickers/Interfaces/IFileDialogEvents.cs b/src/ExternalLibraries.FilePickers/Interfaces/IFileDialogEvents.cs
index 732a52d25c..f1eeddeb99 100644
--- a/src/ExternalLibraries.FilePickers/Interfaces/IFileDialogEvents.cs
+++ b/src/ExternalLibraries.FilePickers/Interfaces/IFileDialogEvents.cs
@@ -1,26 +1,31 @@
-using System.Runtime.CompilerServices;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ExternalLibraries.Pickers.Enums;
using ExternalLibraries.Pickers.Guids;
namespace ExternalLibraries.Pickers.Interfaces;
-[ComImport,
-Guid(IIDGuid.IFileDialogEvents),
-InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+[ComImport, Guid(IIDGuid.IFileDialogEvents), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IFileDialogEvents
{
- // NOTE: some of these callbacks are cancelable - returning S_FALSE means that
- // the dialog should not proceed (e.g. with closing, changing folder); to
+ // NOTE: some of these callbacks are cancelable - returning S_FALSE means that
+ // the dialog should not proceed (e.g. with closing, changing folder); to
// support this, we need to use the PreserveSig attribute to enable us to return
// the proper HRESULT
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime),
- PreserveSig]
+ [
+ MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime),
+ PreserveSig
+ ]
HRESULT OnFileOk([In, MarshalAs(UnmanagedType.Interface)] IFileDialog pfd);
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime),
- PreserveSig]
- HRESULT OnFolderChanging([In, MarshalAs(UnmanagedType.Interface)] IFileDialog pfd, [In, MarshalAs(UnmanagedType.Interface)] IShellItem psiFolder);
+ [
+ MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime),
+ PreserveSig
+ ]
+ HRESULT OnFolderChanging(
+ [In, MarshalAs(UnmanagedType.Interface)] IFileDialog pfd,
+ [In, MarshalAs(UnmanagedType.Interface)] IShellItem psiFolder
+ );
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
void OnFolderChange([In, MarshalAs(UnmanagedType.Interface)] IFileDialog pfd);
@@ -29,11 +34,19 @@ internal interface IFileDialogEvents
void OnSelectionChange([In, MarshalAs(UnmanagedType.Interface)] IFileDialog pfd);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
- void OnShareViolation([In, MarshalAs(UnmanagedType.Interface)] IFileDialog pfd, [In, MarshalAs(UnmanagedType.Interface)] IShellItem psi, out FDE_SHAREVIOLATION_RESPONSE pResponse);
+ void OnShareViolation(
+ [In, MarshalAs(UnmanagedType.Interface)] IFileDialog pfd,
+ [In, MarshalAs(UnmanagedType.Interface)] IShellItem psi,
+ out FDE_SHAREVIOLATION_RESPONSE pResponse
+ );
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
void OnTypeChange([In, MarshalAs(UnmanagedType.Interface)] IFileDialog pfd);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
- void OnOverwrite([In, MarshalAs(UnmanagedType.Interface)] IFileDialog pfd, [In, MarshalAs(UnmanagedType.Interface)] IShellItem psi, out FDE_OVERWRITE_RESPONSE pResponse);
+ void OnOverwrite(
+ [In, MarshalAs(UnmanagedType.Interface)] IFileDialog pfd,
+ [In, MarshalAs(UnmanagedType.Interface)] IShellItem psi,
+ out FDE_OVERWRITE_RESPONSE pResponse
+ );
}
diff --git a/src/ExternalLibraries.FilePickers/Interfaces/IFileOpenDialog.cs b/src/ExternalLibraries.FilePickers/Interfaces/IFileOpenDialog.cs
index 61f666d288..3388db6146 100644
--- a/src/ExternalLibraries.FilePickers/Interfaces/IFileOpenDialog.cs
+++ b/src/ExternalLibraries.FilePickers/Interfaces/IFileOpenDialog.cs
@@ -1,13 +1,11 @@
-using System.Runtime.CompilerServices;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ExternalLibraries.Pickers.Guids;
using ExternalLibraries.Pickers.Structures;
namespace ExternalLibraries.Pickers.Interfaces;
-[ComImport(),
-Guid(IIDGuid.IFileOpenDialog),
-InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+[ComImport(), Guid(IIDGuid.IFileOpenDialog), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IFileOpenDialog : IFileDialog
{
// Defined on IFileDialog - repeated here due to requirements of COM interop layer
diff --git a/src/ExternalLibraries.FilePickers/Interfaces/IModalWindow.cs b/src/ExternalLibraries.FilePickers/Interfaces/IModalWindow.cs
index 59f836abdf..edc345f93b 100644
--- a/src/ExternalLibraries.FilePickers/Interfaces/IModalWindow.cs
+++ b/src/ExternalLibraries.FilePickers/Interfaces/IModalWindow.cs
@@ -1,16 +1,15 @@
-using System.Runtime.CompilerServices;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ExternalLibraries.Pickers.Guids;
namespace ExternalLibraries.Pickers.Interfaces;
-[ComImport(),
-Guid(IIDGuid.IModalWindow),
-InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+[ComImport(), Guid(IIDGuid.IModalWindow), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IModalWindow
{
-
- [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime),
- PreserveSig]
+ [
+ MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime),
+ PreserveSig
+ ]
int Show([In] IntPtr parent);
}
diff --git a/src/ExternalLibraries.FilePickers/Interfaces/IShellItem.cs b/src/ExternalLibraries.FilePickers/Interfaces/IShellItem.cs
index 8bf3f168ff..cd141e3c2a 100644
--- a/src/ExternalLibraries.FilePickers/Interfaces/IShellItem.cs
+++ b/src/ExternalLibraries.FilePickers/Interfaces/IShellItem.cs
@@ -1,28 +1,38 @@
-using System.Runtime.CompilerServices;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ExternalLibraries.Pickers.Enums;
using ExternalLibraries.Pickers.Guids;
namespace ExternalLibraries.Pickers.Interfaces;
-[ComImport,
-Guid(IIDGuid.IShellItem),
-InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+[ComImport, Guid(IIDGuid.IShellItem), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IShellItem
{
// Not supported: IBindCtx
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
- void BindToHandler([In, MarshalAs(UnmanagedType.Interface)] IntPtr pbc, [In] ref Guid bhid, [In] ref Guid riid, out IntPtr ppv);
+ void BindToHandler(
+ [In, MarshalAs(UnmanagedType.Interface)] IntPtr pbc,
+ [In] ref Guid bhid,
+ [In] ref Guid riid,
+ out IntPtr ppv
+ );
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
void GetParent([MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
- void GetDisplayName([In] SIGDN sigdnName, [MarshalAs(UnmanagedType.LPWStr)] out string ppszName);
+ void GetDisplayName(
+ [In] SIGDN sigdnName,
+ [MarshalAs(UnmanagedType.LPWStr)] out string ppszName
+ );
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
void GetAttributes([In] uint sfgaoMask, out uint psfgaoAttribs);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
- void Compare([In, MarshalAs(UnmanagedType.Interface)] IShellItem psi, [In] uint hint, out int piOrder);
+ void Compare(
+ [In, MarshalAs(UnmanagedType.Interface)] IShellItem psi,
+ [In] uint hint,
+ out int piOrder
+ );
}
diff --git a/src/ExternalLibraries.FilePickers/Interfaces/IShellItemArray.cs b/src/ExternalLibraries.FilePickers/Interfaces/IShellItemArray.cs
index 990cb92fbf..603ecf5832 100644
--- a/src/ExternalLibraries.FilePickers/Interfaces/IShellItemArray.cs
+++ b/src/ExternalLibraries.FilePickers/Interfaces/IShellItemArray.cs
@@ -1,4 +1,4 @@
-using System.Runtime.CompilerServices;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ExternalLibraries.Pickers.Enums;
using ExternalLibraries.Pickers.Guids;
@@ -6,23 +6,34 @@
namespace ExternalLibraries.Pickers.Interfaces;
-[ComImport,
-Guid(IIDGuid.IShellItemArray),
-InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+[ComImport, Guid(IIDGuid.IShellItemArray), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IShellItemArray
{
// Not supported: IBindCtx
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
- void BindToHandler([In, MarshalAs(UnmanagedType.Interface)] IntPtr pbc, [In] ref Guid rbhid, [In] ref Guid riid, out IntPtr ppvOut);
+ void BindToHandler(
+ [In, MarshalAs(UnmanagedType.Interface)] IntPtr pbc,
+ [In] ref Guid rbhid,
+ [In] ref Guid riid,
+ out IntPtr ppvOut
+ );
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
void GetPropertyStore([In] int Flags, [In] ref Guid riid, out IntPtr ppv);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
- void GetPropertyDescriptionList([In] ref PROPERTYKEY keyType, [In] ref Guid riid, out IntPtr ppv);
+ void GetPropertyDescriptionList(
+ [In] ref PROPERTYKEY keyType,
+ [In] ref Guid riid,
+ out IntPtr ppv
+ );
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
- void GetAttributes([In] SIATTRIBFLAGS dwAttribFlags, [In] uint sfgaoMask, out uint psfgaoAttribs);
+ void GetAttributes(
+ [In] SIATTRIBFLAGS dwAttribFlags,
+ [In] uint sfgaoMask,
+ out uint psfgaoAttribs
+ );
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
void GetCount(out uint pdwNumItems);
diff --git a/src/ExternalLibraries.FilePickers/Structures/COMDLG_FILTERSPEC.cs b/src/ExternalLibraries.FilePickers/Structures/COMDLG_FILTERSPEC.cs
index 2fa3b3110e..1807ba6ccd 100644
--- a/src/ExternalLibraries.FilePickers/Structures/COMDLG_FILTERSPEC.cs
+++ b/src/ExternalLibraries.FilePickers/Structures/COMDLG_FILTERSPEC.cs
@@ -1,4 +1,4 @@
-using System.Runtime.InteropServices;
+using System.Runtime.InteropServices;
namespace ExternalLibraries.Pickers.Structures;
@@ -19,6 +19,7 @@ internal COMDLG_FILTERSPEC(string name, string spec)
[MarshalAs(UnmanagedType.LPWStr)]
public string pszName;
+
[MarshalAs(UnmanagedType.LPWStr)]
public string pszSpec;
}
diff --git a/src/ExternalLibraries.FilePickers/Structures/PROPERTYKEY.cs b/src/ExternalLibraries.FilePickers/Structures/PROPERTYKEY.cs
index dbb1a5ab4d..3729e2841b 100644
--- a/src/ExternalLibraries.FilePickers/Structures/PROPERTYKEY.cs
+++ b/src/ExternalLibraries.FilePickers/Structures/PROPERTYKEY.cs
@@ -1,4 +1,4 @@
-using System.Runtime.InteropServices;
+using System.Runtime.InteropServices;
namespace ExternalLibraries.Pickers.Structures;
diff --git a/src/SharedAssemblyInfo.cs b/src/SharedAssemblyInfo.cs
index f7c98c2905..635b385194 100644
--- a/src/SharedAssemblyInfo.cs
+++ b/src/SharedAssemblyInfo.cs
@@ -1,4 +1,4 @@
-using System.Reflection;
+using System.Reflection;
#if WINDOWS
using System.Runtime.Versioning;
#endif
diff --git a/src/UniGetUI.Core.Classes.Tests/PersonTests.cs b/src/UniGetUI.Core.Classes.Tests/PersonTests.cs
index 607dbeaac0..dd53854fd9 100644
--- a/src/UniGetUI.Core.Classes.Tests/PersonTests.cs
+++ b/src/UniGetUI.Core.Classes.Tests/PersonTests.cs
@@ -1,19 +1,24 @@
-namespace UniGetUI.Core.Classes.Tests
+namespace UniGetUI.Core.Classes.Tests
{
public class PersonTests
{
[Theory]
- [InlineData("Bernat-Miquel Guimerà", "https://github.com/BernatMiquelG.png", "https://github.com/BernatMiquelG")]
+ [InlineData(
+ "Bernat-Miquel Guimerà",
+ "https://github.com/BernatMiquelG.png",
+ "https://github.com/BernatMiquelG"
+ )]
[InlineData("Bernat-Miquel Guimerà", "https://github.com/BernatMiquelG.png", null)]
[InlineData("Bernat-Miquel Guimerà", null, "https://github.com/BernatMiquelG")]
[InlineData("Bernat-Miquel Guimerà", null, null)]
public void TestPerson(string name, string? profilePicture, string? gitHubUrl)
{
-
//arrange
- Person actual = new(Name: name,
- ProfilePicture: profilePicture is null ? null : new Uri(profilePicture),
- GitHubUrl: gitHubUrl is null ? null : new Uri(gitHubUrl));
+ Person actual = new(
+ Name: name,
+ ProfilePicture: profilePicture is null ? null : new Uri(profilePicture),
+ GitHubUrl: gitHubUrl is null ? null : new Uri(gitHubUrl)
+ );
//Assert
if (string.IsNullOrEmpty(profilePicture))
diff --git a/src/UniGetUI.Core.Classes.Tests/SortableObservableCollectionTests.cs b/src/UniGetUI.Core.Classes.Tests/SortableObservableCollectionTests.cs
index c4ec45e6cb..907347190f 100644
--- a/src/UniGetUI.Core.Classes.Tests/SortableObservableCollectionTests.cs
+++ b/src/UniGetUI.Core.Classes.Tests/SortableObservableCollectionTests.cs
@@ -7,7 +7,11 @@ private class SortableInt : IIndexableListItem
{
public int Value { get; set; }
public int Index { get; set; }
- public SortableInt(int value) { Value = value; }
+
+ public SortableInt(int value)
+ {
+ Value = value;
+ }
}
[Fact]
@@ -16,8 +20,14 @@ public void TestSortableCollection()
int EventTriggeredCount = 0;
SortableObservableCollection SortableCollection = [];
- SortableCollection.CollectionChanged += (_, _) => { EventTriggeredCount++; };
- SortableCollection.SortingSelector = (s) => { return s.Value; };
+ SortableCollection.CollectionChanged += (_, _) =>
+ {
+ EventTriggeredCount++;
+ };
+ SortableCollection.SortingSelector = (s) =>
+ {
+ return s.Value;
+ };
SortableCollection.Add(new(1));
SortableCollection.Add(new(2));
SortableCollection.Add(new(4));
diff --git a/src/UniGetUI.Core.Classes.Tests/TaskRecyclerTests.cs b/src/UniGetUI.Core.Classes.Tests/TaskRecyclerTests.cs
index 85575d8ff1..1d55397162 100644
--- a/src/UniGetUI.Core.Classes.Tests/TaskRecyclerTests.cs
+++ b/src/UniGetUI.Core.Classes.Tests/TaskRecyclerTests.cs
@@ -12,16 +12,24 @@ private int MySlowMethod1()
private sealed class TestClass
{
- public TestClass() {}
+ public TestClass() { }
- [SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "Instance methods are required to validate TaskRecycler instance-bound delegate behavior.")]
+ [SuppressMessage(
+ "Performance",
+ "CA1822:Mark members as static",
+ Justification = "Instance methods are required to validate TaskRecycler instance-bound delegate behavior."
+ )]
public string SlowMethod2()
{
Thread.Sleep(1000);
return new Random().Next().ToString();
}
- [SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "Instance methods are required to validate TaskRecycler instance-bound delegate behavior.")]
+ [SuppressMessage(
+ "Performance",
+ "CA1822:Mark members as static",
+ Justification = "Instance methods are required to validate TaskRecycler instance-bound delegate behavior."
+ )]
public string SlowMethod3()
{
Thread.Sleep(1000);
@@ -42,7 +50,7 @@ public async Task TestTaskRecycler_Static_Int()
var task1 = TaskRecycler.RunOrAttachAsync(MySlowMethod1);
var task2 = TaskRecycler.RunOrAttachAsync(MySlowMethod1);
int result1 = await task1;
- int result2 = await task2;
+ int result2 = await task2;
Assert.Equal(result1, result2);
// The same static method should be cached, and therefore the return value should be the same, but different from previous runs
diff --git a/src/UniGetUI.Core.Classes.Tests/UniGetUI.Core.Classes.Tests.csproj b/src/UniGetUI.Core.Classes.Tests/UniGetUI.Core.Classes.Tests.csproj
index 2820a5963b..2627cb85ad 100644
--- a/src/UniGetUI.Core.Classes.Tests/UniGetUI.Core.Classes.Tests.csproj
+++ b/src/UniGetUI.Core.Classes.Tests/UniGetUI.Core.Classes.Tests.csproj
@@ -1,39 +1,38 @@
+
+ $(PortableTargetFramework)
+
+ false
+ true
+
-
- $(PortableTargetFramework)
-
- false
- true
-
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
- runtime; build; native; contentfiles; analyzers; buildtransitive
- all
-
-
+
+
+
-
-
-
+
+
+
-
-
-
-
-
-
-
+
+
+
diff --git a/src/UniGetUI.Core.Classes/IIndexableListItem.cs b/src/UniGetUI.Core.Classes/IIndexableListItem.cs
index 76856aab66..5e7b20dee3 100644
--- a/src/UniGetUI.Core.Classes/IIndexableListItem.cs
+++ b/src/UniGetUI.Core.Classes/IIndexableListItem.cs
@@ -1,4 +1,4 @@
-namespace UniGetUI.Core.Classes
+namespace UniGetUI.Core.Classes
{
public interface IIndexableListItem
{
diff --git a/src/UniGetUI.Core.Classes/ObservableQueue.cs b/src/UniGetUI.Core.Classes/ObservableQueue.cs
index ebc57e53b0..54996e5525 100644
--- a/src/UniGetUI.Core.Classes/ObservableQueue.cs
+++ b/src/UniGetUI.Core.Classes/ObservableQueue.cs
@@ -18,7 +18,7 @@ public class EventArgs(T item)
public new T Dequeue()
{
- T item = base.Dequeue();
+ T item = base.Dequeue();
ItemDequeued?.Invoke(this, new EventArgs(item));
return item;
}
diff --git a/src/UniGetUI.Core.Classes/Person.cs b/src/UniGetUI.Core.Classes/Person.cs
index 6e5996f4d0..be7aa29c02 100644
--- a/src/UniGetUI.Core.Classes/Person.cs
+++ b/src/UniGetUI.Core.Classes/Person.cs
@@ -1,4 +1,4 @@
-namespace UniGetUI.Core.Classes
+namespace UniGetUI.Core.Classes
{
public readonly struct Person
{
@@ -9,7 +9,12 @@ public readonly struct Person
public readonly bool HasGitHubProfile;
public readonly string Language;
- public Person(string Name, Uri? ProfilePicture = null, Uri? GitHubUrl = null, string Language = "")
+ public Person(
+ string Name,
+ Uri? ProfilePicture = null,
+ Uri? GitHubUrl = null,
+ string Language = ""
+ )
{
this.Name = Name;
this.ProfilePicture = ProfilePicture;
diff --git a/src/UniGetUI.Core.Classes/SortableObservableCollection.cs b/src/UniGetUI.Core.Classes/SortableObservableCollection.cs
index 37d187d362..f6510315db 100644
--- a/src/UniGetUI.Core.Classes/SortableObservableCollection.cs
+++ b/src/UniGetUI.Core.Classes/SortableObservableCollection.cs
@@ -6,7 +6,8 @@ namespace UniGetUI.Core.Classes
/*
* An observable sorted collection that keeps IIndexableListItem indexes up to date
*/
- public class SortableObservableCollection : ObservableCollection where T : IIndexableListItem
+ public class SortableObservableCollection : ObservableCollection
+ where T : IIndexableListItem
{
public Func? SortingSelector { get; set; }
public bool Descending { get; set; }
@@ -18,7 +19,12 @@ protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
return;
base.OnCollectionChanged(e);
- if (SortingSelector is null || e.Action is NotifyCollectionChangedAction.Remove or NotifyCollectionChangedAction.Reset)
+ if (
+ SortingSelector is null
+ || e.Action
+ is NotifyCollectionChangedAction.Remove
+ or NotifyCollectionChangedAction.Reset
+ )
return;
Sort();
@@ -33,10 +39,14 @@ public void Sort()
if (SortingSelector is null)
{
- throw new InvalidOperationException("SortableObservableCollection.SortingSelector must not be null when sorting");
+ throw new InvalidOperationException(
+ "SortableObservableCollection.SortingSelector must not be null when sorting"
+ );
}
- List sorted = Descending ? this.OrderByDescending(SortingSelector).ToList() : this.OrderBy(SortingSelector).ToList();
+ List sorted = Descending
+ ? this.OrderByDescending(SortingSelector).ToList()
+ : this.OrderBy(SortingSelector).ToList();
foreach (T item in sorted)
{
Move(IndexOf(item), sorted.IndexOf(item));
@@ -48,7 +58,9 @@ public void Sort()
}
BlockSorting = false;
- base.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
+ base.OnCollectionChanged(
+ new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)
+ );
}
}
}
diff --git a/src/UniGetUI.Core.Classes/TaskRecycler.cs b/src/UniGetUI.Core.Classes/TaskRecycler.cs
index 94aa9b6d0e..53ae2aaba0 100644
--- a/src/UniGetUI.Core.Classes/TaskRecycler.cs
+++ b/src/UniGetUI.Core.Classes/TaskRecycler.cs
@@ -37,47 +37,78 @@ public static Task RunOrAttachAsync(Func method, int cacheTime
}
/// Asynchronous entry point for 1 parameter
- public static Task RunOrAttachAsync(Func method, ParamT arg1, int cacheTimeSecs = 0)
+ public static Task RunOrAttachAsync(
+ Func method,
+ ParamT arg1,
+ int cacheTimeSecs = 0
+ )
{
int hash = method.GetHashCode() + (arg1?.GetHashCode() ?? 0);
return _runTaskAndWait(new Task(() => method(arg1)), hash, cacheTimeSecs);
}
/// Asynchronous entry point for 2 parameters
- public static Task RunOrAttachAsync(Func method,
- Param1T arg1, Param2T arg2, int cacheTimeSecs = 0)
+ public static Task RunOrAttachAsync(
+ Func method,
+ Param1T arg1,
+ Param2T arg2,
+ int cacheTimeSecs = 0
+ )
{
int hash = method.GetHashCode() + (arg1?.GetHashCode() ?? 0) + (arg2?.GetHashCode() ?? 0);
return _runTaskAndWait(new Task(() => method(arg1, arg2)), hash, cacheTimeSecs);
}
/// Asynchronous entry point for 3 parameters
- public static Task RunOrAttachAsync(Func method,
- Param1T arg1, Param2T arg2, Param3T arg3, int cacheTimeSecs = 0)
+ public static Task RunOrAttachAsync(
+ Func method,
+ Param1T arg1,
+ Param2T arg2,
+ Param3T arg3,
+ int cacheTimeSecs = 0
+ )
{
- int hash = method.GetHashCode() + (arg1?.GetHashCode() ?? 0) + (arg2?.GetHashCode() ?? 0) + (arg3?.GetHashCode() ?? 0);
- return _runTaskAndWait(new Task(() => method(arg1, arg2, arg3)), hash, cacheTimeSecs);
+ int hash =
+ method.GetHashCode()
+ + (arg1?.GetHashCode() ?? 0)
+ + (arg2?.GetHashCode() ?? 0)
+ + (arg3?.GetHashCode() ?? 0);
+ return _runTaskAndWait(
+ new Task(() => method(arg1, arg2, arg3)),
+ hash,
+ cacheTimeSecs
+ );
}
// ---------------------------------------------------------------------------------------------------------------
/// Synchronous entry point for 0 parameters
- public static ReturnT RunOrAttach(Func method, int cacheTimeSecs = 0)
- => RunOrAttachAsync(method, cacheTimeSecs).GetAwaiter().GetResult();
+ public static ReturnT RunOrAttach(Func method, int cacheTimeSecs = 0) =>
+ RunOrAttachAsync(method, cacheTimeSecs).GetAwaiter().GetResult();
/// Synchronous entry point for 1 parameter1
- public static ReturnT RunOrAttach(Func method, ParamT arg1, int cacheTimeSecs = 0)
- => RunOrAttachAsync(method, arg1, cacheTimeSecs).GetAwaiter().GetResult();
+ public static ReturnT RunOrAttach(
+ Func method,
+ ParamT arg1,
+ int cacheTimeSecs = 0
+ ) => RunOrAttachAsync(method, arg1, cacheTimeSecs).GetAwaiter().GetResult();
/// Synchronous entry point for 2 parameters
- public static ReturnT RunOrAttach(Func method, Param1T arg1,
- Param2T arg2, int cacheTimeSecs = 0)
- => RunOrAttachAsync(method, arg1, arg2, cacheTimeSecs).GetAwaiter().GetResult();
+ public static ReturnT RunOrAttach(
+ Func method,
+ Param1T arg1,
+ Param2T arg2,
+ int cacheTimeSecs = 0
+ ) => RunOrAttachAsync(method, arg1, arg2, cacheTimeSecs).GetAwaiter().GetResult();
/// Synchronous entry point for 3 parameters
- public static ReturnT RunOrAttach(Func method, Param1T arg1,
- Param2T arg2, Param3T arg3, int cacheTimeSecs = 0)
- => RunOrAttachAsync(method, arg1, arg2, arg3, cacheTimeSecs).GetAwaiter().GetResult();
+ public static ReturnT RunOrAttach(
+ Func method,
+ Param1T arg1,
+ Param2T arg2,
+ Param3T arg3,
+ int cacheTimeSecs = 0
+ ) => RunOrAttachAsync(method, arg1, arg2, arg3, cacheTimeSecs).GetAwaiter().GetResult();
// ---------------------------------------------------------------------------------------------------------------
@@ -88,8 +119,8 @@ public static ReturnT RunOrAttach(Func
///
- public static void RemoveFromCache(Func method)
- => _removeFromCache(method.GetHashCode(), 0);
+ public static void RemoveFromCache(Func method) =>
+ _removeFromCache(method.GetHashCode(), 0);
// ---------------------------------------------------------------------------------------------------------------
@@ -126,7 +157,11 @@ private static async Task _runTaskAndWait_VOID(Task task, int hash, int cacheTim
///
/// Handles running the task if no such task was found on cache, and returning the cached task if it was found.
///
- private static async Task _runTaskAndWait(Task task, int hash, int cacheTimeSecsSecs)
+ private static async Task _runTaskAndWait(
+ Task task,
+ int hash,
+ int cacheTimeSecsSecs
+ )
{
if (_tasks.TryGetValue(hash, out Task? _task))
{
diff --git a/src/UniGetUI.Core.Classes/UniGetUI.Core.Classes.csproj b/src/UniGetUI.Core.Classes/UniGetUI.Core.Classes.csproj
index 37104013bb..b66c05a73b 100644
--- a/src/UniGetUI.Core.Classes/UniGetUI.Core.Classes.csproj
+++ b/src/UniGetUI.Core.Classes/UniGetUI.Core.Classes.csproj
@@ -1,10 +1,13 @@
+
+ $(SharedTargetFrameworks)
+
-
-
-
+
+
+
-
-
-
+
+
+
diff --git a/src/UniGetUI.Core.Data.Tests/ContributorsTests.cs b/src/UniGetUI.Core.Data.Tests/ContributorsTests.cs
index 9fd9925494..ab8ab45a13 100644
--- a/src/UniGetUI.Core.Data.Tests/ContributorsTests.cs
+++ b/src/UniGetUI.Core.Data.Tests/ContributorsTests.cs
@@ -1,8 +1,7 @@
-namespace UniGetUI.Core.Data.Tests
+namespace UniGetUI.Core.Data.Tests
{
public class ContributorsTests
{
-
[Fact]
public void CheckIfContributorListIsEmpty()
{
diff --git a/src/UniGetUI.Core.Data.Tests/CoreTests.cs b/src/UniGetUI.Core.Data.Tests/CoreTests.cs
index e38f662e74..0f0ad4ca82 100644
--- a/src/UniGetUI.Core.Data.Tests/CoreTests.cs
+++ b/src/UniGetUI.Core.Data.Tests/CoreTests.cs
@@ -1,22 +1,25 @@
-namespace UniGetUI.Core.Data.Tests
+namespace UniGetUI.Core.Data.Tests
{
public class CoreTests
{
public static object[][] Data =>
[
[CoreData.UniGetUIDataDirectory],
- [CoreData.UniGetUIInstallationOptionsDirectory ],
- [CoreData.UniGetUICacheDirectory_Data ],
- [CoreData.UniGetUICacheDirectory_Icons ],
- [CoreData.UniGetUICacheDirectory_Lang ],
- [CoreData.UniGetUI_DefaultBackupDirectory ]
- ];
+ [CoreData.UniGetUIInstallationOptionsDirectory],
+ [CoreData.UniGetUICacheDirectory_Data],
+ [CoreData.UniGetUICacheDirectory_Icons],
+ [CoreData.UniGetUICacheDirectory_Lang],
+ [CoreData.UniGetUI_DefaultBackupDirectory],
+ ];
[Theory]
[MemberData(nameof(Data))]
public void CheckDirectoryAttributes(string directory)
{
- Assert.True(Directory.Exists(directory), $"Directory ${directory} does not exist, but it should have been created automatically");
+ Assert.True(
+ Directory.Exists(directory),
+ $"Directory ${directory} does not exist, but it should have been created automatically"
+ );
}
[Fact]
@@ -26,8 +29,14 @@ public void CheckOtherAttributes()
Assert.NotEqual(0, CoreData.BuildNumber);
Assert.NotEqual(0, CoreData.UpdatesAvailableNotificationTag);
- Assert.True(Directory.Exists(CoreData.UniGetUIExecutableDirectory), "Directory where the executable is located does not exist");
- Assert.True(File.Exists(CoreData.UniGetUIExecutableFile), "The executable file does not exist");
+ Assert.True(
+ Directory.Exists(CoreData.UniGetUIExecutableDirectory),
+ "Directory where the executable is located does not exist"
+ );
+ Assert.True(
+ File.Exists(CoreData.UniGetUIExecutableFile),
+ "The executable file does not exist"
+ );
}
}
}
diff --git a/src/UniGetUI.Core.Data.Tests/LicensesTest.cs b/src/UniGetUI.Core.Data.Tests/LicensesTest.cs
index ebb8c41e46..debdb89d5c 100644
--- a/src/UniGetUI.Core.Data.Tests/LicensesTest.cs
+++ b/src/UniGetUI.Core.Data.Tests/LicensesTest.cs
@@ -15,7 +15,10 @@ public void EnsureLicenseUrlsExist()
}
}
- Assert.True(MissingUrls.Count == 0, "The list of missing licenses is not empty: " + MissingUrls.ToArray().ToString());
+ Assert.True(
+ MissingUrls.Count == 0,
+ "The list of missing licenses is not empty: " + MissingUrls.ToArray().ToString()
+ );
}
[Fact]
@@ -31,8 +34,10 @@ public void EnsureHomepageUrlsExist()
}
}
- Assert.True(MissingUrls.Count == 0, "The list of missing licenses is not empty: " + MissingUrls.ToArray().ToString());
+ Assert.True(
+ MissingUrls.Count == 0,
+ "The list of missing licenses is not empty: " + MissingUrls.ToArray().ToString()
+ );
}
-
}
-}
\ No newline at end of file
+}
diff --git a/src/UniGetUI.Core.Data.Tests/UniGetUI.Core.Data.Tests.csproj b/src/UniGetUI.Core.Data.Tests/UniGetUI.Core.Data.Tests.csproj
index 37eb555bba..556d89135b 100644
--- a/src/UniGetUI.Core.Data.Tests/UniGetUI.Core.Data.Tests.csproj
+++ b/src/UniGetUI.Core.Data.Tests/UniGetUI.Core.Data.Tests.csproj
@@ -1,43 +1,40 @@
-
-
- $(PortableTargetFramework)
-
-
-
-
-
-
- false
- true
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
- runtime; build; native; contentfiles; analyzers; buildtransitive
- all
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ $(PortableTargetFramework)
+
+
+
+
+ false
+ true
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/UniGetUI.Core.Data/Contributors.cs b/src/UniGetUI.Core.Data/Contributors.cs
index cd274d57be..46a913c71b 100644
--- a/src/UniGetUI.Core.Data/Contributors.cs
+++ b/src/UniGetUI.Core.Data/Contributors.cs
@@ -1,9 +1,16 @@
-namespace UniGetUI.Core.Data
+namespace UniGetUI.Core.Data
{
public static class ContributorsData
{
public static string[] Contributors = File.ReadAllLines(
- Path.Join(CoreData.UniGetUIExecutableDirectory, "Assets", "Data", "Contributors.list")
- ).Where(x => x != "").ToArray();
+ Path.Join(
+ CoreData.UniGetUIExecutableDirectory,
+ "Assets",
+ "Data",
+ "Contributors.list"
+ )
+ )
+ .Where(x => x != "")
+ .ToArray();
}
}
diff --git a/src/UniGetUI.Core.Data/CoreCredentialStore.cs b/src/UniGetUI.Core.Data/CoreCredentialStore.cs
index ca5ce6eecf..7cbed4adf0 100644
--- a/src/UniGetUI.Core.Data/CoreCredentialStore.cs
+++ b/src/UniGetUI.Core.Data/CoreCredentialStore.cs
@@ -15,15 +15,11 @@ public static class CoreCredentialStore
string? secret = GetSecret(resourceName, userName);
return secret is null
? null
- : new NetworkCredential
- {
- UserName = userName,
- Password = secret,
- };
+ : new NetworkCredential { UserName = userName, Password = secret };
}
- public static void SetCredential(string resourceName, string userName, string password)
- => SetSecret(resourceName, userName, password);
+ public static void SetCredential(string resourceName, string userName, string password) =>
+ SetSecret(resourceName, userName, password);
public static string? GetSecret(string resourceName, string userName)
{
@@ -73,8 +69,13 @@ public static void DeleteSecret(string resourceName, string userName)
{
#if WINDOWS
var vault = new PasswordVault();
- IReadOnlyList credentials = vault.FindAllByResource(resourceName) ?? [];
- foreach (PasswordCredential credential in credentials.Where(credential => credential.UserName == userName))
+ IReadOnlyList credentials =
+ vault.FindAllByResource(resourceName) ?? [];
+ foreach (
+ PasswordCredential credential in credentials.Where(credential =>
+ credential.UserName == userName
+ )
+ )
{
vault.Remove(credential);
}
@@ -94,11 +95,11 @@ public static void DeleteSecret(string resourceName, string userName)
}
#if !WINDOWS
- private static string GetStorageDirectory()
- => Path.Join(CoreData.UniGetUIDataDirectory, "SecureStorage");
+ private static string GetStorageDirectory() =>
+ Path.Join(CoreData.UniGetUIDataDirectory, "SecureStorage");
- private static string GetSecretPath(string resourceName, string userName)
- => Path.Join(GetStorageDirectory(), GetStableFileName(resourceName, userName));
+ private static string GetSecretPath(string resourceName, string userName) =>
+ Path.Join(GetStorageDirectory(), GetStableFileName(resourceName, userName));
private static string GetStableFileName(string resourceName, string userName)
{
@@ -106,4 +107,4 @@ private static string GetStableFileName(string resourceName, string userName)
return Convert.ToHexString(hash) + ".secret";
}
#endif
-}
\ No newline at end of file
+}
diff --git a/src/UniGetUI.Core.Data/CoreData.cs b/src/UniGetUI.Core.Data/CoreData.cs
index 54ec0e31f0..62153855e2 100644
--- a/src/UniGetUI.Core.Data/CoreData.cs
+++ b/src/UniGetUI.Core.Data/CoreData.cs
@@ -1,4 +1,4 @@
-using System.Diagnostics;
+using System.Diagnostics;
using System.Text;
using UniGetUI.Core.Logging;
@@ -7,18 +7,25 @@ namespace UniGetUI.Core.Data
public static class CoreData
{
private static int? __code_page;
- public static int CODE_PAGE { get => __code_page ??= GetCodePage(); }
+ public static int CODE_PAGE
+ {
+ get => __code_page ??= GetCodePage();
+ }
public const string VersionName = "3.3.7"; // Do not modify this line, use file scripts/set-version.ps1
public const int BuildNumber = 106; // Do not modify this line, use file scripts/set-version.ps1
- public const string UserAgentString = $"UniGetUI/{VersionName} (https://marticliment.com/unigetui/; contact@marticliment.com)";
+ public const string UserAgentString =
+ $"UniGetUI/{VersionName} (https://marticliment.com/unigetui/; contact@marticliment.com)";
public const string AppIdentifier = "MartiCliment.UniGetUI";
public const string MainWindowIdentifier = "MartiCliment.UniGetUI.MainInterface";
private static bool? IS_PORTABLE;
private static string? PORTABLE_PATH;
- public static bool IsPortable { get => IS_PORTABLE ?? false; }
+ public static bool IsPortable
+ {
+ get => IS_PORTABLE ?? false;
+ }
public static string? TEST_DataDirectoryOverride { private get; set; }
@@ -36,16 +43,22 @@ public static string UniGetUIDataDirectory
if (IS_PORTABLE is null)
{
- IS_PORTABLE = File.Exists(Path.Join(UniGetUIExecutableDirectory, "ForceUniGetUIPortable"));
+ IS_PORTABLE = File.Exists(
+ Path.Join(UniGetUIExecutableDirectory, "ForceUniGetUIPortable")
+ );
if (IS_PORTABLE is true)
{
string path = Path.Join(UniGetUIExecutableDirectory, "Settings");
try
{
- if (!Directory.Exists(path)) Directory.CreateDirectory(path);
+ if (!Directory.Exists(path))
+ Directory.CreateDirectory(path);
var testfilepath = Path.Join(path, "PermissionTestFile");
- File.WriteAllText(testfilepath, "https://www.youtube.com/watch?v=dQw4w9WgXcQ");
+ File.WriteAllText(
+ testfilepath,
+ "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
+ );
PORTABLE_PATH = path;
return path;
}
@@ -53,16 +66,22 @@ public static string UniGetUIDataDirectory
{
IS_PORTABLE = false;
Logger.Error(
- $"Could not acces/write path {path}. UniGetUI will NOT be run in portable mode, and User settings will be used instead");
+ $"Could not acces/write path {path}. UniGetUI will NOT be run in portable mode, and User settings will be used instead"
+ );
Logger.Error(ex);
}
}
- } else if (IS_PORTABLE is true)
+ }
+ else if (IS_PORTABLE is true)
{
- return PORTABLE_PATH ?? throw new InvalidOperationException("This shouldn't be possible");
+ return PORTABLE_PATH
+ ?? throw new InvalidOperationException("This shouldn't be possible");
}
- string old_path = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".wingetui");
+ string old_path = Path.Join(
+ Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
+ ".wingetui"
+ );
string new_path = Path.Join(GetLocalDataRoot(), "UniGetUI");
return GetNewDataDirectoryOrMoveOld(old_path, new_path);
}
@@ -83,14 +102,24 @@ public static string UniGetUIUserConfigurationDirectory
//Migration case
try
{
- Logger.Info($"Moving configuration files from '{oldConfigPath}' to '{newConfigPath}'");
+ Logger.Info(
+ $"Moving configuration files from '{oldConfigPath}' to '{newConfigPath}'"
+ );
Directory.CreateDirectory(newConfigPath);
- foreach (string file in Directory.GetFiles(oldConfigPath, "*.*", SearchOption.TopDirectoryOnly))
+ foreach (
+ string file in Directory.GetFiles(
+ oldConfigPath,
+ "*.*",
+ SearchOption.TopDirectoryOnly
+ )
+ )
{
string fileName = Path.GetFileName(file);
string fileExtension = Path.GetExtension(file);
- bool isConfigFile = string.IsNullOrEmpty(fileExtension) || fileExtension.ToLowerInvariant() == ".json";
+ bool isConfigFile =
+ string.IsNullOrEmpty(fileExtension)
+ || fileExtension.ToLowerInvariant() == ".json";
if (isConfigFile)
{
@@ -99,18 +128,24 @@ public static string UniGetUIUserConfigurationDirectory
if (!File.Exists(newFile))
{
File.Move(file, newFile);
- Logger.Debug($"Moved configuration file '{file}' to '{newFile}'");
+ Logger.Debug(
+ $"Moved configuration file '{file}' to '{newFile}'"
+ );
}
// Clean up old file to avoid duplicates and confusion
else
{
- Logger.Warn($"Configuration file '{newFile}' already exists, skipping move from '{file}'.");
+ Logger.Warn(
+ $"Configuration file '{newFile}' already exists, skipping move from '{file}'."
+ );
File.Delete(file);
}
}
else
{
- Logger.Debug($"Skipping non-configuration file '{file}' during migration.");
+ Logger.Debug(
+ $"Skipping non-configuration file '{file}' during migration."
+ );
}
}
Logger.Info($"Configuration files moved successfully to '{newConfigPath}'");
@@ -118,7 +153,9 @@ public static string UniGetUIUserConfigurationDirectory
catch (Exception ex)
{
// Fallback to old path if migration fails to not break functionality
- Logger.Error($"Error moving configuration files from '{oldConfigPath}' to '{newConfigPath}'. Using old path for now. Manual migration might be needed.");
+ Logger.Error(
+ $"Error moving configuration files from '{oldConfigPath}' to '{newConfigPath}'. Using old path for now. Manual migration might be needed."
+ );
Logger.Error(ex);
return oldConfigPath;
}
@@ -140,7 +177,8 @@ public static string UniGetUIInstallationOptionsDirectory
get
{
string path = Path.Join(UniGetUIDataDirectory, "InstallationOptions");
- if (!Directory.Exists(path)) Directory.CreateDirectory(path);
+ if (!Directory.Exists(path))
+ Directory.CreateDirectory(path);
return path;
}
}
@@ -153,7 +191,8 @@ public static string UniGetUICacheDirectory_Data
get
{
string path = Path.Join(UniGetUIDataDirectory, "CachedMetadata");
- if (!Directory.Exists(path)) Directory.CreateDirectory(path);
+ if (!Directory.Exists(path))
+ Directory.CreateDirectory(path);
return path;
}
}
@@ -166,7 +205,8 @@ public static string UniGetUICacheDirectory_Icons
get
{
string path = Path.Join(UniGetUIDataDirectory, "CachedMedia");
- if (!Directory.Exists(path)) Directory.CreateDirectory(path);
+ if (!Directory.Exists(path))
+ Directory.CreateDirectory(path);
return path;
}
}
@@ -179,7 +219,8 @@ public static string UniGetUICacheDirectory_Lang
get
{
string path = Path.Join(UniGetUIDataDirectory, "CachedLanguageFiles");
- if (!Directory.Exists(path)) Directory.CreateDirectory(path);
+ if (!Directory.Exists(path))
+ Directory.CreateDirectory(path);
return path;
}
}
@@ -205,10 +246,12 @@ public static string UniGetUI_DefaultBackupDirectory
/// The ID of the notification that is used to inform the user that updates are available
///
public const int UpdatesAvailableNotificationTag = 1234;
+
///
/// The ID of the notification that is used to inform the user that UniGetUI can be updated
///
public const int UniGetUICanBeUpdated = 1235;
+
///
/// The ID of the notification that is used to inform the user that shortcuts are available for deletion
///
@@ -221,15 +264,22 @@ public static string UniGetUIExecutableDirectory
{
get
{
- string? dir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
+ string? dir = Path.GetDirectoryName(
+ System.Reflection.Assembly.GetExecutingAssembly().Location
+ );
if (dir is not null)
{
return dir;
}
- Logger.Error("System.Reflection.Assembly.GetExecutingAssembly().Location returned an empty path");
+ Logger.Error(
+ "System.Reflection.Assembly.GetExecutingAssembly().Location returned an empty path"
+ );
- return AppContext.BaseDirectory.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
+ return AppContext.BaseDirectory.TrimEnd(
+ Path.DirectorySeparatorChar,
+ Path.AltDirectorySeparatorChar
+ );
}
}
@@ -246,7 +296,9 @@ public static string UniGetUIExecutableFile
return NormalizeExecutablePath(filename);
}
- Logger.Error("System.Reflection.Assembly.GetExecutingAssembly().Location returned an empty path");
+ Logger.Error(
+ "System.Reflection.Assembly.GetExecutingAssembly().Location returned an empty path"
+ );
return OperatingSystem.IsWindows()
? Path.Join(UniGetUIExecutableDirectory, "UniGetUI.exe")
@@ -276,7 +328,13 @@ private static string GetNewDataDirectoryOrMoveOld(string old_path, string new_p
{
try
{
- foreach (string old_subdir in Directory.GetDirectories(old_path, "*", SearchOption.AllDirectories))
+ foreach (
+ string old_subdir in Directory.GetDirectories(
+ old_path,
+ "*",
+ SearchOption.AllDirectories
+ )
+ )
{
string new_subdir = old_subdir.Replace(old_path, new_path);
if (!Directory.Exists(new_subdir))
@@ -290,7 +348,13 @@ private static string GetNewDataDirectoryOrMoveOld(string old_path, string new_p
}
}
- foreach (string old_file in Directory.GetFiles(old_path, "*", SearchOption.AllDirectories))
+ foreach (
+ string old_file in Directory.GetFiles(
+ old_path,
+ "*",
+ SearchOption.AllDirectories
+ )
+ )
{
string new_file = old_file.Replace(old_path, new_path);
if (!File.Exists(new_file))
@@ -305,16 +369,28 @@ private static string GetNewDataDirectoryOrMoveOld(string old_path, string new_p
}
}
- foreach (string old_subdir in Directory.GetDirectories(old_path, "*", SearchOption.AllDirectories))
+ foreach (
+ string old_subdir in Directory.GetDirectories(
+ old_path,
+ "*",
+ SearchOption.AllDirectories
+ )
+ )
{
- if (!Directory.EnumerateFiles(old_subdir).Any() && !Directory.EnumerateDirectories(old_subdir).Any())
+ if (
+ !Directory.EnumerateFiles(old_subdir).Any()
+ && !Directory.EnumerateDirectories(old_subdir).Any()
+ )
{
Logger.Debug("Deleting old empty subdirectory " + old_subdir);
Directory.Delete(old_subdir);
}
}
- if (!Directory.EnumerateFiles(old_path).Any() && !Directory.EnumerateDirectories(old_path).Any())
+ if (
+ !Directory.EnumerateFiles(old_path).Any()
+ && !Directory.EnumerateDirectories(old_path).Any()
+ )
{
Logger.Info("Deleting old Chocolatey directory " + old_path);
Directory.Delete(old_path);
@@ -329,7 +405,9 @@ private static string GetNewDataDirectoryOrMoveOld(string old_path, string new_p
}
}
- if (/*Directory.Exists(new_path)*/Directory.Exists(old_path))
+ if ( /*Directory.Exists(new_path)*/
+ Directory.Exists(old_path)
+ )
{
try
{
@@ -339,7 +417,12 @@ private static string GetNewDataDirectoryOrMoveOld(string old_path, string new_p
}
catch (Exception e)
{
- Logger.Error("Cannot move old data directory to new location. Directory to move: " + old_path + ". Destination: " + new_path);
+ Logger.Error(
+ "Cannot move old data directory to new location. Directory to move: "
+ + old_path
+ + ". Destination: "
+ + new_path
+ );
Logger.Error(e);
return old_path;
}
@@ -353,7 +436,9 @@ private static string GetNewDataDirectoryOrMoveOld(string old_path, string new_p
}
catch (Exception e)
{
- Logger.Error("Could not create new directory. You may perhaps need to disable Controlled Folder Access from Windows Settings or make an exception for UniGetUI.");
+ Logger.Error(
+ "Could not create new directory. You may perhaps need to disable Controlled Folder Access from Windows Settings or make an exception for UniGetUI."
+ );
Logger.Error(e);
return new_path;
}
@@ -376,7 +461,7 @@ private static int GetCodePage()
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true,
- }
+ },
};
p.Start();
string contents = p.StandardOutput.ReadToEnd();
@@ -405,7 +490,9 @@ private static int GetCodePage()
private static string GetLocalDataRoot()
{
- string localApplicationData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
+ string localApplicationData = Environment.GetFolderPath(
+ Environment.SpecialFolder.LocalApplicationData
+ );
if (!string.IsNullOrWhiteSpace(localApplicationData))
{
return localApplicationData;
@@ -422,7 +509,9 @@ private static string GetLocalDataRoot()
private static string GetDocumentsRoot()
{
- string documentsDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
+ string documentsDirectory = Environment.GetFolderPath(
+ Environment.SpecialFolder.MyDocuments
+ );
if (!string.IsNullOrWhiteSpace(documentsDirectory))
{
return documentsDirectory;
@@ -444,7 +533,10 @@ private static string GetUserHomeDirectory()
private static string NormalizeExecutablePath(string path)
{
- if (OperatingSystem.IsWindows() && path.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
+ if (
+ OperatingSystem.IsWindows()
+ && path.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)
+ )
{
return Path.ChangeExtension(path, ".exe");
}
diff --git a/src/UniGetUI.Core.Data/Licenses.cs b/src/UniGetUI.Core.Data/Licenses.cs
index acbd048207..fae4800ba0 100644
--- a/src/UniGetUI.Core.Data/Licenses.cs
+++ b/src/UniGetUI.Core.Data/Licenses.cs
@@ -2,104 +2,137 @@ namespace UniGetUI.Core.Data
{
public static class LicenseData
{
- public static Dictionary LicenseNames = new() {
- {"UniGetUI", "MIT" },
-
+ public static Dictionary LicenseNames = new()
+ {
+ { "UniGetUI", "MIT" },
// C# Libraries
- {"Pickers", "MIT"},
- {"Community Toolkit", "MIT"},
- {"H.NotifyIcon", "MIT"},
- {"Windows App Sdk", "MIT"},
- {"PhotoSauce.MagicScaler", "MIT"},
- {"YamlDotNet", "MIT"},
- {"InnoDependencyInstaller", "CPOL 1.02" },
-
+ { "Pickers", "MIT" },
+ { "Community Toolkit", "MIT" },
+ { "H.NotifyIcon", "MIT" },
+ { "Windows App Sdk", "MIT" },
+ { "PhotoSauce.MagicScaler", "MIT" },
+ { "YamlDotNet", "MIT" },
+ { "InnoDependencyInstaller", "CPOL 1.02" },
// Package managers and related
- {"WinGet", "MIT"},
- {"Scoop", "MIT"},
- {"scoop-search", "MIT"},
- {"Chocolatey", "Apache v2"},
- {"npm", "Artistic License 2.0"},
- {"Pip", "MIT"},
- {"parse_pip_search", "MIT"},
- {"PowerShell Gallery", "Unknown"},
- {".NET SDK", "MIT"},
- {"Cargo", "MIT"},
- {"cargo-binstall", "GPL-3.0-only"},
- {"cargo-update", "MIT"},
- {"vcpkg", "MIT"},
-
+ { "WinGet", "MIT" },
+ { "Scoop", "MIT" },
+ { "scoop-search", "MIT" },
+ { "Chocolatey", "Apache v2" },
+ { "npm", "Artistic License 2.0" },
+ { "Pip", "MIT" },
+ { "parse_pip_search", "MIT" },
+ { "PowerShell Gallery", "Unknown" },
+ { ".NET SDK", "MIT" },
+ { "Cargo", "MIT" },
+ { "cargo-binstall", "GPL-3.0-only" },
+ { "cargo-update", "MIT" },
+ { "vcpkg", "MIT" },
// Other
- {"GSudo", "MIT"},
- {"UniGetUI Elevator", "MIT"},
- {"Icons", "By Icons8"},
+ { "GSudo", "MIT" },
+ { "UniGetUI Elevator", "MIT" },
+ { "Icons", "By Icons8" },
};
- public static Dictionary LicenseURLs = new(){
- {"UniGetUI", new Uri("https://github.com/Devolutions/UniGetUI/blob/main/LICENSE")},
-
+ public static Dictionary LicenseURLs = new()
+ {
+ { "UniGetUI", new Uri("https://github.com/Devolutions/UniGetUI/blob/main/LICENSE") },
// C# Libraries
- {"Pickers", new Uri("https://github.com/PavlikBender/Pickers/blob/master/LICENSE")},
- {"Community Toolkit", new Uri("https://github.com/CommunityToolkit/Windows/blob/main/License.md")},
- {"H.NotifyIcon", new Uri("https://github.com/HavenDV/H.NotifyIcon/blob/master/LICENSE.md")},
- {"Windows App Sdk", new Uri("https://github.com/microsoft/WindowsAppSDK/blob/main/LICENSE")},
- {"PhotoSauce.MagicScaler", new Uri("https://github.com/saucecontrol/PhotoSauce/blob/master/license")},
- {"YamlDotNet", new Uri("https://github.com/aaubry/YamlDotNet/blob/master/LICENSE.txt") },
- {"InnoDependencyInstaller", new Uri("https://github.com/DomGries/InnoDependencyInstaller/blob/master/LICENSE.md") },
-
+ { "Pickers", new Uri("https://github.com/PavlikBender/Pickers/blob/master/LICENSE") },
+ {
+ "Community Toolkit",
+ new Uri("https://github.com/CommunityToolkit/Windows/blob/main/License.md")
+ },
+ {
+ "H.NotifyIcon",
+ new Uri("https://github.com/HavenDV/H.NotifyIcon/blob/master/LICENSE.md")
+ },
+ {
+ "Windows App Sdk",
+ new Uri("https://github.com/microsoft/WindowsAppSDK/blob/main/LICENSE")
+ },
+ {
+ "PhotoSauce.MagicScaler",
+ new Uri("https://github.com/saucecontrol/PhotoSauce/blob/master/license")
+ },
+ {
+ "YamlDotNet",
+ new Uri("https://github.com/aaubry/YamlDotNet/blob/master/LICENSE.txt")
+ },
+ {
+ "InnoDependencyInstaller",
+ new Uri(
+ "https://github.com/DomGries/InnoDependencyInstaller/blob/master/LICENSE.md"
+ )
+ },
// Package managers and related
- {"WinGet", new Uri("https://github.com/microsoft/winget-cli/blob/master/LICENSE")},
- {"Scoop", new Uri("https://github.com/ScoopInstaller/Scoop/blob/master/LICENSE")},
- {"scoop-search", new Uri("https://github.com/shilangyu/scoop-search/blob/master/LICENSE")},
- {"Chocolatey", new Uri("https://github.com/chocolatey/choco/blob/develop/LICENSE")},
- {"npm", new Uri("https://github.com/npm/cli/blob/latest/LICENSE")},
- {"Pip", new Uri("https://github.com/pypa/pip/blob/main/LICENSE.txt")},
- {"parse_pip_search", new Uri("https://github.com/marticliment/parseable_pip_search/blob/master/LICENSE.md")},
- {".NET SDK", new Uri("https://github.com/dotnet/sdk/blob/main/LICENSE.TXT")},
- {"PowerShell Gallery", new Uri("https://www.powershellgallery.com/")},
- {"Cargo", new Uri("https://github.com/rust-lang/cargo/blob/master/LICENSE-MIT")},
- {"cargo-binstall", new Uri("https://spdx.org/licenses/GPL-3.0-only.html")},
- {"cargo-update", new Uri("https://github.com/nabijaczleweli/cargo-update/blob/master/LICENSE")},
- {"vcpkg", new Uri("https://github.com/microsoft/vcpkg/blob/master/LICENSE.txt")},
-
+ { "WinGet", new Uri("https://github.com/microsoft/winget-cli/blob/master/LICENSE") },
+ { "Scoop", new Uri("https://github.com/ScoopInstaller/Scoop/blob/master/LICENSE") },
+ {
+ "scoop-search",
+ new Uri("https://github.com/shilangyu/scoop-search/blob/master/LICENSE")
+ },
+ { "Chocolatey", new Uri("https://github.com/chocolatey/choco/blob/develop/LICENSE") },
+ { "npm", new Uri("https://github.com/npm/cli/blob/latest/LICENSE") },
+ { "Pip", new Uri("https://github.com/pypa/pip/blob/main/LICENSE.txt") },
+ {
+ "parse_pip_search",
+ new Uri(
+ "https://github.com/marticliment/parseable_pip_search/blob/master/LICENSE.md"
+ )
+ },
+ { ".NET SDK", new Uri("https://github.com/dotnet/sdk/blob/main/LICENSE.TXT") },
+ { "PowerShell Gallery", new Uri("https://www.powershellgallery.com/") },
+ { "Cargo", new Uri("https://github.com/rust-lang/cargo/blob/master/LICENSE-MIT") },
+ { "cargo-binstall", new Uri("https://spdx.org/licenses/GPL-3.0-only.html") },
+ {
+ "cargo-update",
+ new Uri("https://github.com/nabijaczleweli/cargo-update/blob/master/LICENSE")
+ },
+ { "vcpkg", new Uri("https://github.com/microsoft/vcpkg/blob/master/LICENSE.txt") },
// Other
- {"GSudo", new Uri("https://github.com/gerardog/gsudo/blob/master/LICENSE.txt")},
- {"UniGetUI Elevator", new Uri("https://github.com/marticliment/GSudo-for-UniGetUI/blob/main/LICENSE.txt")},
- {"Icons", new Uri("https://icons8.com/license")},
+ { "GSudo", new Uri("https://github.com/gerardog/gsudo/blob/master/LICENSE.txt") },
+ {
+ "UniGetUI Elevator",
+ new Uri("https://github.com/marticliment/GSudo-for-UniGetUI/blob/main/LICENSE.txt")
+ },
+ { "Icons", new Uri("https://icons8.com/license") },
};
- public static Dictionary HomepageUrls = new(){
- {"UniGetUI", new Uri("https://marticliment.com/unigetui")},
-
+ public static Dictionary HomepageUrls = new()
+ {
+ { "UniGetUI", new Uri("https://marticliment.com/unigetui") },
// C# Libraries
- {"Pickers", new Uri("https://github.com/PavlikBender/Pickers/")},
- {"Community Toolkit", new Uri("https://github.com/CommunityToolkit/Windows/")},
- {"H.NotifyIcon", new Uri("https://github.com/HavenDV/H.NotifyIcon/")},
- {"Windows App Sdk", new Uri("https://github.com/microsoft/WindowsAppSDK/")},
- {"PhotoSauce.MagicScaler", new Uri("https://github.com/saucecontrol/PhotoSauce/")},
- {"YamlDotNet", new Uri("https://github.com/aaubry/YamlDotNet/") },
- {"InnoDependencyInstaller", new Uri("https://github.com/DomGries/InnoDependencyInstaller")},
-
+ { "Pickers", new Uri("https://github.com/PavlikBender/Pickers/") },
+ { "Community Toolkit", new Uri("https://github.com/CommunityToolkit/Windows/") },
+ { "H.NotifyIcon", new Uri("https://github.com/HavenDV/H.NotifyIcon/") },
+ { "Windows App Sdk", new Uri("https://github.com/microsoft/WindowsAppSDK/") },
+ { "PhotoSauce.MagicScaler", new Uri("https://github.com/saucecontrol/PhotoSauce/") },
+ { "YamlDotNet", new Uri("https://github.com/aaubry/YamlDotNet/") },
+ {
+ "InnoDependencyInstaller",
+ new Uri("https://github.com/DomGries/InnoDependencyInstaller")
+ },
// Package managers and related
- {"WinGet", new Uri("https://github.com/microsoft/winget-cli/")},
- {"Scoop", new Uri("https://github.com/ScoopInstaller/Scoop/")},
- {"scoop-search", new Uri("https://github.com/shilangyu/scoop-search/")},
- {"Chocolatey", new Uri("https://github.com/chocolatey/choco/")},
- {"npm", new Uri("https://github.com/npm/cli/")},
- {"Pip", new Uri("https://github.com/pypa/pip/")},
- {"parse_pip_search", new Uri("https://github.com/marticliment/parseable_pip_search/")},
- {".NET SDK", new Uri("https://dotnet.microsoft.com/")},
- {"PowerShell Gallery", new Uri("https://www.powershellgallery.com/")},
- {"Cargo", new Uri("https://github.com/rust-lang/cargo")},
- {"cargo-binstall", new Uri("https://github.com/cargo-bins/cargo-binstall")},
- {"cargo-update", new Uri("https://github.com/nabijaczleweli/cargo-update/")},
- {"vcpkg", new Uri("https://github.com/microsoft/vcpkg")},
-
+ { "WinGet", new Uri("https://github.com/microsoft/winget-cli/") },
+ { "Scoop", new Uri("https://github.com/ScoopInstaller/Scoop/") },
+ { "scoop-search", new Uri("https://github.com/shilangyu/scoop-search/") },
+ { "Chocolatey", new Uri("https://github.com/chocolatey/choco/") },
+ { "npm", new Uri("https://github.com/npm/cli/") },
+ { "Pip", new Uri("https://github.com/pypa/pip/") },
+ {
+ "parse_pip_search",
+ new Uri("https://github.com/marticliment/parseable_pip_search/")
+ },
+ { ".NET SDK", new Uri("https://dotnet.microsoft.com/") },
+ { "PowerShell Gallery", new Uri("https://www.powershellgallery.com/") },
+ { "Cargo", new Uri("https://github.com/rust-lang/cargo") },
+ { "cargo-binstall", new Uri("https://github.com/cargo-bins/cargo-binstall") },
+ { "cargo-update", new Uri("https://github.com/nabijaczleweli/cargo-update/") },
+ { "vcpkg", new Uri("https://github.com/microsoft/vcpkg") },
// Other
- {"GSudo", new Uri("https://github.com/gerardog/gsudo/")},
- {"UniGetUI Elevator", new Uri("https://github.com/marticliment/GSudo-for-UniGetUI/")},
- {"Icons", new Uri("https://icons8.com")},
+ { "GSudo", new Uri("https://github.com/gerardog/gsudo/") },
+ { "UniGetUI Elevator", new Uri("https://github.com/marticliment/GSudo-for-UniGetUI/") },
+ { "Icons", new Uri("https://icons8.com") },
};
-
}
}
diff --git a/src/UniGetUI.Core.Data/UniGetUI.Core.Data.csproj b/src/UniGetUI.Core.Data/UniGetUI.Core.Data.csproj
index 2329f02494..a764202b92 100644
--- a/src/UniGetUI.Core.Data/UniGetUI.Core.Data.csproj
+++ b/src/UniGetUI.Core.Data/UniGetUI.Core.Data.csproj
@@ -1,20 +1,23 @@
+
+ $(SharedTargetFrameworks)
+
-
-
-
+
+
+
-
-
- PreserveNewest
-
-
+
+
+ PreserveNewest
+
+
-
-
-
+
+
+
-
-
-
+
+
+
diff --git a/src/UniGetUI.Core.IconEngine.Tests/IconCacheEngineTests.cs b/src/UniGetUI.Core.IconEngine.Tests/IconCacheEngineTests.cs
index 8f22b98d2b..4d7548f30f 100644
--- a/src/UniGetUI.Core.IconEngine.Tests/IconCacheEngineTests.cs
+++ b/src/UniGetUI.Core.IconEngine.Tests/IconCacheEngineTests.cs
@@ -8,15 +8,88 @@ public static class IconCacheEngineTests
public static void TestCacheEngineForSha256()
{
Uri ICON_1 = new Uri("https://marticliment.com/resources/unigetui.png");
- byte[] HASH_1 = [0xB7, 0x41, 0xC3, 0x18, 0xBF, 0x2B, 0x07, 0xAA, 0x92, 0xB2, 0x7A, 0x1B, 0x4D, 0xC5, 0xEE, 0xC4, 0xD1, 0x9B, 0x22, 0xD4, 0x0A, 0x13, 0x26, 0xA7, 0x45, 0xA4, 0xA7, 0xF5, 0x81, 0x8E, 0xAF, 0xFF];
+ byte[] HASH_1 =
+ [
+ 0xB7,
+ 0x41,
+ 0xC3,
+ 0x18,
+ 0xBF,
+ 0x2B,
+ 0x07,
+ 0xAA,
+ 0x92,
+ 0xB2,
+ 0x7A,
+ 0x1B,
+ 0x4D,
+ 0xC5,
+ 0xEE,
+ 0xC4,
+ 0xD1,
+ 0x9B,
+ 0x22,
+ 0xD4,
+ 0x0A,
+ 0x13,
+ 0x26,
+ 0xA7,
+ 0x45,
+ 0xA4,
+ 0xA7,
+ 0xF5,
+ 0x81,
+ 0x8E,
+ 0xAF,
+ 0xFF,
+ ];
Uri ICON_2 = new Uri("https://marticliment.com/resources/elevenclock.png");
- byte[] HASH_2 = [0x9E, 0xB8, 0x7A, 0x5A, 0x64, 0xCA, 0x6D, 0x8D, 0x0A, 0x7B, 0x98, 0xC5, 0x4F, 0x6A, 0x58, 0x72, 0xFD, 0x94, 0xC9, 0xA6, 0x82, 0xB3, 0x2B, 0x90, 0x70, 0x66, 0x66, 0x1C, 0xBF, 0x81, 0x97, 0x97];
+ byte[] HASH_2 =
+ [
+ 0x9E,
+ 0xB8,
+ 0x7A,
+ 0x5A,
+ 0x64,
+ 0xCA,
+ 0x6D,
+ 0x8D,
+ 0x0A,
+ 0x7B,
+ 0x98,
+ 0xC5,
+ 0x4F,
+ 0x6A,
+ 0x58,
+ 0x72,
+ 0xFD,
+ 0x94,
+ 0xC9,
+ 0xA6,
+ 0x82,
+ 0xB3,
+ 0x2B,
+ 0x90,
+ 0x70,
+ 0x66,
+ 0x66,
+ 0x1C,
+ 0xBF,
+ 0x81,
+ 0x97,
+ 0x97,
+ ];
string managerName = "TestManager";
string packageId = "Package55";
string extension = ICON_1.ToString().Split(".")[^1];
- string expectedFile = Path.Join(CoreData.UniGetUICacheDirectory_Icons, managerName, packageId, $"icon.{extension}");
+ string expectedFile = Path.Join(
+ CoreData.UniGetUICacheDirectory_Icons,
+ managerName,
+ packageId,
+ $"icon.{extension}"
+ );
if (File.Exists(expectedFile))
{
File.Delete(expectedFile);
@@ -67,7 +140,12 @@ public static void TestCacheEngineForPackageVersion()
string PACKAGE_ID = "Package2";
string extension = URI.ToString().Split(".")[^1];
- string expectedFile = Path.Join(CoreData.UniGetUICacheDirectory_Icons, MANAGER_NAME, PACKAGE_ID, $"icon.{extension}");
+ string expectedFile = Path.Join(
+ CoreData.UniGetUICacheDirectory_Icons,
+ MANAGER_NAME,
+ PACKAGE_ID,
+ $"icon.{extension}"
+ );
if (File.Exists(expectedFile))
{
File.Delete(expectedFile);
@@ -75,7 +153,12 @@ public static void TestCacheEngineForPackageVersion()
// Download an icon through version verification
CacheableIcon icon = new(URI, VERSION);
- string? path = IconCacheEngine.GetCacheOrDownloadIcon(icon, MANAGER_NAME, PACKAGE_ID, 0);
+ string? path = IconCacheEngine.GetCacheOrDownloadIcon(
+ icon,
+ MANAGER_NAME,
+ PACKAGE_ID,
+ 0
+ );
Assert.NotNull(path);
Assert.Equal(expectedFile, path);
Assert.True(File.Exists(path));
@@ -112,7 +195,12 @@ public static void TestCacheEngineForIconUri()
string packageId = "Package12";
string extension = URI_1.ToString().Split(".")[^1];
- string expectedFile = Path.Join(CoreData.UniGetUICacheDirectory_Icons, managerName, packageId, $"icon.{extension}");
+ string expectedFile = Path.Join(
+ CoreData.UniGetUICacheDirectory_Icons,
+ managerName,
+ packageId,
+ $"icon.{extension}"
+ );
if (File.Exists(expectedFile))
{
File.Delete(expectedFile);
@@ -160,7 +248,12 @@ public static void TestCacheEngineForPackageSize()
// Clear any cache for reproducible data
string extension = ICON_1.ToString().Split(".")[^1];
- string expectedFile = Path.Join(CoreData.UniGetUICacheDirectory_Icons, managerName, packageId, $"icon.{extension}");
+ string expectedFile = Path.Join(
+ CoreData.UniGetUICacheDirectory_Icons,
+ managerName,
+ packageId,
+ $"icon.{extension}"
+ );
if (File.Exists(expectedFile))
{
File.Delete(expectedFile);
diff --git a/src/UniGetUI.Core.IconEngine.Tests/IconDatabaseTests.cs b/src/UniGetUI.Core.IconEngine.Tests/IconDatabaseTests.cs
index ea9df05f85..0d1dfc70c3 100644
--- a/src/UniGetUI.Core.IconEngine.Tests/IconDatabaseTests.cs
+++ b/src/UniGetUI.Core.IconEngine.Tests/IconDatabaseTests.cs
@@ -26,7 +26,9 @@ public async Task TestGetExistingIconAndImagesAsync()
string? icon = iconStore.GetIconUrlForId("__test_entry_DO_NOT_EDIT_PLEASE");
Assert.Equal("https://this.is.a.test/url/used_for/automated_unit_testing.png", icon);
- string[] screenshots = iconStore.GetScreenshotsUrlForId("__test_entry_DO_NOT_EDIT_PLEASE");
+ string[] screenshots = iconStore.GetScreenshotsUrlForId(
+ "__test_entry_DO_NOT_EDIT_PLEASE"
+ );
Assert.Equal(3, screenshots.Length);
Assert.Equal("https://image_number.com/1.png", screenshots[0]);
Assert.Equal("https://image_number.com/2.png", screenshots[1]);
@@ -38,10 +40,14 @@ public async Task TestGetNonExistingIconAndImagesAsync()
{
await iconStore.LoadIconAndScreenshotsDatabaseAsync();
- string? nonexistent_icon = iconStore.GetIconUrlForId("__test_entry_THIS_ICON_DOES_NOT_EXTST");
+ string? nonexistent_icon = iconStore.GetIconUrlForId(
+ "__test_entry_THIS_ICON_DOES_NOT_EXTST"
+ );
Assert.Null(nonexistent_icon);
- string[] nonexistent_screenshots = iconStore.GetScreenshotsUrlForId("__test_entry_THIS_ICON_DOES_NOT_EXTST");
+ string[] nonexistent_screenshots = iconStore.GetScreenshotsUrlForId(
+ "__test_entry_THIS_ICON_DOES_NOT_EXTST"
+ );
Assert.Empty(nonexistent_screenshots);
}
}
diff --git a/src/UniGetUI.Core.IconEngine.Tests/UniGetUI.Core.IconEngine.Tests.csproj b/src/UniGetUI.Core.IconEngine.Tests/UniGetUI.Core.IconEngine.Tests.csproj
index f523803f79..57a4effc4c 100644
--- a/src/UniGetUI.Core.IconEngine.Tests/UniGetUI.Core.IconEngine.Tests.csproj
+++ b/src/UniGetUI.Core.IconEngine.Tests/UniGetUI.Core.IconEngine.Tests.csproj
@@ -1,41 +1,38 @@
+
+ $(PortableTargetFramework)
+
+ false
+ true
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+
+
+
-
- $(PortableTargetFramework)
-
- false
- true
-
+
+
+
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
- runtime; build; native; contentfiles; analyzers; buildtransitive
- all
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
diff --git a/src/UniGetUI.Core.IconStore/IconCacheEngine.cs b/src/UniGetUI.Core.IconStore/IconCacheEngine.cs
index 3a0c5140a4..85112ce640 100644
--- a/src/UniGetUI.Core.IconStore/IconCacheEngine.cs
+++ b/src/UniGetUI.Core.IconStore/IconCacheEngine.cs
@@ -13,7 +13,7 @@ public enum IconValidationMethod
SHA256,
FileSize,
PackageVersion,
- UriSource
+ UriSource,
}
public readonly struct CacheableIcon
@@ -37,7 +37,8 @@ public CacheableIcon(Uri uri, byte[] Sha256)
Url = uri;
this.SHA256 = Sha256;
ValidationMethod = IconValidationMethod.SHA256;
- _hashCode = uri.ToString().GetHashCode() + Sha256[0] + Sha256[1] + Sha256[2] + Sha256[3];
+ _hashCode =
+ uri.ToString().GetHashCode() + Sha256[0] + Sha256[1] + Sha256[2] + Sha256[3];
}
///
@@ -100,21 +101,41 @@ public static class IconCacheEngine
/// the Id of the package
/// the Time to store the icons on the TaskRecycler cache
/// A path to a local icon file
- public static string? GetCacheOrDownloadIcon(CacheableIcon? icon, string ManagerName, string PackageId, int cacheInterval = 30)
- => TaskRecycler.RunOrAttach(_getCacheOrDownloadIcon, icon, ManagerName, PackageId, cacheInterval);
-
- private static string? _getCacheOrDownloadIcon(CacheableIcon? _icon, string ManagerName, string PackageId)
+ public static string? GetCacheOrDownloadIcon(
+ CacheableIcon? icon,
+ string ManagerName,
+ string PackageId,
+ int cacheInterval = 30
+ ) =>
+ TaskRecycler.RunOrAttach(
+ _getCacheOrDownloadIcon,
+ icon,
+ ManagerName,
+ PackageId,
+ cacheInterval
+ );
+
+ private static string? _getCacheOrDownloadIcon(
+ CacheableIcon? _icon,
+ string ManagerName,
+ string PackageId
+ )
{
if (_icon is null)
return null;
var icon = _icon.Value;
- if(icon.IsLocalPath)
+ if (icon.IsLocalPath)
return icon.LocalPath;
- string iconLocation = Path.Join(CoreData.UniGetUICacheDirectory_Icons, ManagerName, PackageId);
- if (!Directory.Exists(iconLocation)) Directory.CreateDirectory(iconLocation);
+ string iconLocation = Path.Join(
+ CoreData.UniGetUICacheDirectory_Icons,
+ ManagerName,
+ PackageId
+ );
+ if (!Directory.Exists(iconLocation))
+ Directory.CreateDirectory(iconLocation);
string iconVersionFile = Path.Join(iconLocation, $"icon.version");
string iconUriFile = Path.Join(iconLocation, $"icon.uri");
@@ -122,8 +143,8 @@ public static class IconCacheEngine
string? cachedIconFile = GetLocalCachedFile(icon, iconLocation);
bool isLocalCacheValid = // Verify if the cached icon exists and is valid
- cachedIconFile is not null &&
- icon.ValidationMethod switch
+ cachedIconFile is not null
+ && icon.ValidationMethod switch
{
IconValidationMethod.FileSize => ValidateByImageSize(icon, cachedIconFile),
IconValidationMethod.SHA256 => ValidateBySHA256(icon, cachedIconFile),
@@ -135,12 +156,16 @@ cachedIconFile is not null &&
// If a valid cache was found, return that cache
if (isLocalCacheValid)
{
- Logger.Debug($"Cached icon for id={PackageId} is valid and won't be downloaded again ({icon.ValidationMethod})");
+ Logger.Debug(
+ $"Cached icon for id={PackageId} is valid and won't be downloaded again ({icon.ValidationMethod})"
+ );
return cachedIconFile;
}
if (cachedIconFile is not null)
- Logger.ImportantInfo($"Cached icon for id={PackageId} is INVALID ({icon.ValidationMethod})");
+ Logger.ImportantInfo(
+ $"Cached icon for id={PackageId} is INVALID ({icon.ValidationMethod})"
+ );
return SaveIconToCacheAndGetPath(icon, iconLocation);
}
@@ -163,10 +188,16 @@ cachedIconFile is not null &&
string iconVersionFile = Path.Join(iconLocation, $"icon.version");
string iconUriFile = Path.Join(iconLocation, $"icon.uri");
- if (icon.ValidationMethod is IconValidationMethod.PackageVersion && !File.Exists(iconVersionFile))
+ if (
+ icon.ValidationMethod is IconValidationMethod.PackageVersion
+ && !File.Exists(iconVersionFile)
+ )
return null; // If version file does not exist and icon is versioned
- if (icon.ValidationMethod is IconValidationMethod.UriSource && !File.Exists(iconUriFile))
+ if (
+ icon.ValidationMethod is IconValidationMethod.UriSource
+ && !File.Exists(iconUriFile)
+ )
return null; // If uri file does not exist and icon is versioned
return cachedIconFile;
@@ -189,14 +220,18 @@ cachedIconFile is not null &&
HttpResponseMessage response = client.GetAsync(icon.Url).GetAwaiter().GetResult();
if (!response.IsSuccessStatusCode)
{
- Logger.Warn($"Icon download attempt at {icon.Url} failed with code {response.StatusCode}");
+ Logger.Warn(
+ $"Icon download attempt at {icon.Url} failed with code {response.StatusCode}"
+ );
return null;
}
string mimeType = response.Content.Headers.GetValues("Content-Type").First();
if (!MimeToExtension.TryGetValue(mimeType, out string? extension))
{
- Logger.Warn($"Unknown mimetype {mimeType} for icon {icon.Url}, aborting download");
+ Logger.Warn(
+ $"Unknown mimetype {mimeType} for icon {icon.Url}, aborting download"
+ );
return null;
}
@@ -228,17 +263,25 @@ cachedIconFile is not null &&
if (isNewCacheValid)
{
- if (icon.ValidationMethod is IconValidationMethod.PackageVersion or IconValidationMethod.UriSource
- && new[] { "png", "webp", "tif", "avif" }.Contains(extension))
+ if (
+ icon.ValidationMethod
+ is IconValidationMethod.PackageVersion
+ or IconValidationMethod.UriSource
+ && new[] { "png", "webp", "tif", "avif" }.Contains(extension)
+ )
{
DownsizeImage(cachedIconFile);
}
- Logger.Debug($"Icon for Location={iconLocation} has been downloaded and verified properly (if applicable) ({icon.ValidationMethod})");
+ Logger.Debug(
+ $"Icon for Location={iconLocation} has been downloaded and verified properly (if applicable) ({icon.ValidationMethod})"
+ );
return cachedIconFile;
}
- Logger.Warn($"NEWLY DOWNLOADED Icon for Location={iconLocation} Uri={icon.Url} is NOT VALID and will be discarded (verification method is {icon.ValidationMethod})");
+ Logger.Warn(
+ $"NEWLY DOWNLOADED Icon for Location={iconLocation} Uri={icon.Url} is NOT VALID and will be discarded (verification method is {icon.ValidationMethod})"
+ );
DeteteCachedFiles(iconLocation);
return null;
}
@@ -266,25 +309,32 @@ private static void DownsizeImage(string cachedIconFile)
if (width > MAX_SIDE || height > MAX_SIDE)
{
File.Move(cachedIconFile, $"{cachedIconFile}.copy");
- var image = MagicImageProcessor.BuildPipeline($"{cachedIconFile}.copy", new ProcessImageSettings
- {
- Width = MAX_SIDE,
- Height = MAX_SIDE,
- ResizeMode = CropScaleMode.Contain,
- });
+ var image = MagicImageProcessor.BuildPipeline(
+ $"{cachedIconFile}.copy",
+ new ProcessImageSettings
+ {
+ Width = MAX_SIDE,
+ Height = MAX_SIDE,
+ ResizeMode = CropScaleMode.Contain,
+ }
+ );
// Apply changes and save the image to disk
using (FileStream fileStream = File.Create(cachedIconFile))
{
image.WriteOutput(fileStream);
}
- Logger.Debug($"File {cachedIconFile} was downsized from {width}x{height} to {image.Settings.Width}x{image.Settings.Height}");
+ Logger.Debug(
+ $"File {cachedIconFile} was downsized from {width}x{height} to {image.Settings.Width}x{image.Settings.Height}"
+ );
image.Dispose();
File.Delete($"{cachedIconFile}.copy");
}
else
{
- Logger.Debug($"File {cachedIconFile} had an already appropiate size of {width}x{height}");
+ Logger.Debug(
+ $"File {cachedIconFile} had an already appropiate size of {width}x{height}"
+ );
}
}
catch (Exception ex)
@@ -306,7 +356,9 @@ private static bool ValidateByImageSize(CacheableIcon icon, string cachedIconPat
}
catch (Exception e)
{
- Logger.Warn($"Failed to verify icon file size for {icon.Url} via FileSize with error {e.Message}");
+ Logger.Warn(
+ $"Failed to verify icon file size for {icon.Url} via FileSize with error {e.Message}"
+ );
return false;
}
}
@@ -324,7 +376,9 @@ private static bool ValidateBySHA256(CacheableIcon icon, string cachedIconPath)
}
catch (Exception e)
{
- Logger.Warn($"Failed to verify icon file size for {icon.Url} via Sha256 with error {e.Message}");
+ Logger.Warn(
+ $"Failed to verify icon file size for {icon.Url} via Sha256 with error {e.Message}"
+ );
return false;
}
}
@@ -336,11 +390,15 @@ private static bool ValidateByVersion(CacheableIcon icon, string versionPath)
{
try
{
- return File.Exists(versionPath) && CoreTools.VersionStringToStruct(File.ReadAllText(versionPath)) >= CoreTools.VersionStringToStruct(icon.Version);
+ return File.Exists(versionPath)
+ && CoreTools.VersionStringToStruct(File.ReadAllText(versionPath))
+ >= CoreTools.VersionStringToStruct(icon.Version);
}
catch (Exception e)
{
- Logger.Warn($"Failed to verify icon file size for {icon.Url} via PackageVersion with error {e.Message}");
+ Logger.Warn(
+ $"Failed to verify icon file size for {icon.Url} via PackageVersion with error {e.Message}"
+ );
return false;
}
}
@@ -356,7 +414,9 @@ private static bool ValidateByUri(CacheableIcon icon, string uriPath)
}
catch (Exception e)
{
- Logger.Warn($"Failed to verify icon file size for {icon.Url} via UriSource with error {e.Message}");
+ Logger.Warn(
+ $"Failed to verify icon file size for {icon.Url} via UriSource with error {e.Message}"
+ );
return false;
}
}
@@ -379,32 +439,38 @@ private static void DeteteCachedFiles(string iconLocation)
}
}
- public static readonly ReadOnlyDictionary MimeToExtension = new ReadOnlyDictionary(new Dictionary
- {
- {"image/avif", "avif"},
- {"image/gif", "gif"},
- // {"image/bmp", "bmp"}, Should non-transparent types be allowed?
- // {"image/jpeg", "jpg"},
- {"image/png", "png"},
- {"image/webp", "webp"},
- {"image/svg+xml", "svg"},
- {"image/vnd.microsoft.icon", "ico"},
- {"application/octet-stream", "ico"},
- {"image/image/x-icon", "ico"},
- {"image/tiff", "tif"},
- });
-
- public static readonly ReadOnlyDictionary ExtensionToMime = new ReadOnlyDictionary(new Dictionary
- {
- {"avif", "image/avif"},
- {"gif", "image/gif"},
- // {"bmp", "image/bmp"}, Should non-transparent types be allowed
- // {"jpg", "image/jpeg"},
- {"png", "image/png"},
- {"webp", "image/webp"},
- {"svg", "image/svg+xml"},
- {"ico", "image/image/x-icon"},
- {"tif", "image/tiff"},
- });
+ public static readonly ReadOnlyDictionary MimeToExtension =
+ new ReadOnlyDictionary(
+ new Dictionary
+ {
+ { "image/avif", "avif" },
+ { "image/gif", "gif" },
+ // {"image/bmp", "bmp"}, Should non-transparent types be allowed?
+ // {"image/jpeg", "jpg"},
+ { "image/png", "png" },
+ { "image/webp", "webp" },
+ { "image/svg+xml", "svg" },
+ { "image/vnd.microsoft.icon", "ico" },
+ { "application/octet-stream", "ico" },
+ { "image/image/x-icon", "ico" },
+ { "image/tiff", "tif" },
+ }
+ );
+
+ public static readonly ReadOnlyDictionary ExtensionToMime =
+ new ReadOnlyDictionary(
+ new Dictionary
+ {
+ { "avif", "image/avif" },
+ { "gif", "image/gif" },
+ // {"bmp", "image/bmp"}, Should non-transparent types be allowed
+ // {"jpg", "image/jpeg"},
+ { "png", "image/png" },
+ { "webp", "image/webp" },
+ { "svg", "image/svg+xml" },
+ { "ico", "image/image/x-icon" },
+ { "tif", "image/tiff" },
+ }
+ );
}
}
diff --git a/src/UniGetUI.Core.IconStore/IconDatabase.cs b/src/UniGetUI.Core.IconStore/IconDatabase.cs
index e18fb4b6c0..7a28119c0d 100644
--- a/src/UniGetUI.Core.IconStore/IconDatabase.cs
+++ b/src/UniGetUI.Core.IconStore/IconDatabase.cs
@@ -16,6 +16,7 @@ public struct IconCount
public int PackagesWithIconCount = 0;
public int TotalScreenshotCount = 0;
public int PackagesWithScreenshotCount = 0;
+
public IconCount() { }
}
@@ -28,7 +29,10 @@ public static IconDatabase Instance
///
/// The icon and screenshot database
///
- private Dictionary IconDatabaseData = [];
+ private Dictionary<
+ string,
+ IconScreenshotDatabase_v2.PackageIconAndScreenshots
+ > IconDatabaseData = [];
private IconCount __icon_count = new();
///
@@ -38,10 +42,13 @@ public async Task LoadIconAndScreenshotsDatabaseAsync()
{
try
{
- string IconsAndScreenshotsFile = Path.Join(CoreData.UniGetUICacheDirectory_Data, "Icon Database.json");
- Uri DownloadUrl =
- new(
- "https://github.com/Devolutions/UniGetUI/raw/refs/heads/main/WebBasedData/screenshot-database-v2.json");
+ string IconsAndScreenshotsFile = Path.Join(
+ CoreData.UniGetUICacheDirectory_Data,
+ "Icon Database.json"
+ );
+ Uri DownloadUrl = new(
+ "https://github.com/Devolutions/UniGetUI/raw/refs/heads/main/WebBasedData/screenshot-database-v2.json"
+ );
if (Settings.Get(Settings.K.IconDataBaseURL))
{
DownloadUrl = new Uri(Settings.GetValue(Settings.K.IconDataBaseURL));
@@ -76,11 +83,15 @@ public async Task LoadFromCacheAsync()
{
try
{
- string IconsAndScreenshotsFile = Path.Join(CoreData.UniGetUICacheDirectory_Data, "Icon Database.json");
- IconScreenshotDatabase_v2 JsonData = JsonSerializer.Deserialize(
- await File.ReadAllTextAsync(IconsAndScreenshotsFile),
- SerializationHelpers.DefaultOptions
+ string IconsAndScreenshotsFile = Path.Join(
+ CoreData.UniGetUICacheDirectory_Data,
+ "Icon Database.json"
);
+ IconScreenshotDatabase_v2 JsonData =
+ JsonSerializer.Deserialize(
+ await File.ReadAllTextAsync(IconsAndScreenshotsFile),
+ SerializationHelpers.DefaultOptions
+ );
if (JsonData.icons_and_screenshots is not null)
{
IconDatabaseData = JsonData.icons_and_screenshots;
@@ -119,6 +130,5 @@ public IconCount GetIconCount()
{
return __icon_count;
}
-
}
}
diff --git a/src/UniGetUI.Core.IconStore/Serializable.cs b/src/UniGetUI.Core.IconStore/Serializable.cs
index 543fa263ce..a7acac1272 100644
--- a/src/UniGetUI.Core.IconStore/Serializable.cs
+++ b/src/UniGetUI.Core.IconStore/Serializable.cs
@@ -1,4 +1,4 @@
-namespace UniGetUI.Core.IconEngine
+namespace UniGetUI.Core.IconEngine
{
internal struct IconScreenshotDatabase_v2
{
@@ -10,6 +10,7 @@ public struct PackageCount
public int packages_with_screenshot { get; set; }
public int total_screenshots { get; set; }
}
+
public struct PackageIconAndScreenshots
{
public string icon { get; set; }
diff --git a/src/UniGetUI.Core.IconStore/UniGetUI.Core.IconEngine.csproj b/src/UniGetUI.Core.IconStore/UniGetUI.Core.IconEngine.csproj
index e8ce530823..c360acdcb6 100644
--- a/src/UniGetUI.Core.IconStore/UniGetUI.Core.IconEngine.csproj
+++ b/src/UniGetUI.Core.IconStore/UniGetUI.Core.IconEngine.csproj
@@ -1,18 +1,20 @@
+
+ $(SharedTargetFrameworks)
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
+
+
+
-
+
+
+
diff --git a/src/UniGetUI.Core.Language.Tests/LanguageDataTests.cs b/src/UniGetUI.Core.Language.Tests/LanguageDataTests.cs
index 11e758dd28..3fefaa371e 100644
--- a/src/UniGetUI.Core.Language.Tests/LanguageDataTests.cs
+++ b/src/UniGetUI.Core.Language.Tests/LanguageDataTests.cs
@@ -11,13 +11,11 @@ public class LanguageDataTests
LanguageData.LanguageReference.Select(x => new object[] { x.Key, x.Value }).ToArray();
[Fact]
- public void TranslatorsListNotEmptyTest()
- => Assert.NotEmpty(LanguageData.TranslatorsList);
+ public void TranslatorsListNotEmptyTest() => Assert.NotEmpty(LanguageData.TranslatorsList);
[Theory]
[MemberData(nameof(Translators))]
- public void TranslatorsListTest(Person translator)
- => Assert.NotEmpty(translator.Name);
+ public void TranslatorsListTest(Person translator) => Assert.NotEmpty(translator.Name);
[Fact]
public void LanguageReferenceNotEmptyTest()
@@ -29,17 +27,27 @@ public void LanguageReferenceNotEmptyTest()
[MemberData(nameof(LanguageReferences))]
public void LanguageReferenceTest(string key, string value)
{
- Assert.False(value.Contains("NoNameLang_"), $"The language with key {key} has no assigned name");
+ Assert.False(
+ value.Contains("NoNameLang_"),
+ $"The language with key {key} has no assigned name"
+ );
}
[Fact]
public void TranslatedPercentageNotEmptyTests()
{
- System.Collections.ObjectModel.ReadOnlyDictionary TranslatedPercent = LanguageData.TranslationPercentages;
+ System.Collections.ObjectModel.ReadOnlyDictionary TranslatedPercent =
+ LanguageData.TranslationPercentages;
foreach (string key in TranslatedPercent.Keys)
{
- Assert.True(LanguageData.LanguageReference.ContainsKey(key), $"The language key {key} was not found on LanguageReference");
- Assert.False(LanguageData.TranslationPercentages[key].Contains("404%"), $"Somehow the key {key} has no value");
+ Assert.True(
+ LanguageData.LanguageReference.ContainsKey(key),
+ $"The language key {key} was not found on LanguageReference"
+ );
+ Assert.False(
+ LanguageData.TranslationPercentages[key].Contains("404%"),
+ $"Somehow the key {key} has no value"
+ );
}
}
}
diff --git a/src/UniGetUI.Core.Language.Tests/LanguageEngineTests.cs b/src/UniGetUI.Core.Language.Tests/LanguageEngineTests.cs
index 317a3ee171..059cc0b0b5 100644
--- a/src/UniGetUI.Core.Language.Tests/LanguageEngineTests.cs
+++ b/src/UniGetUI.Core.Language.Tests/LanguageEngineTests.cs
@@ -30,7 +30,11 @@ public void TestLoadingLanguageForNonExistentKey()
[Theory]
[InlineData("en", "UniGetUI Log", "UniGetUI (formerly WingetUI)")]
[InlineData("ca", "Registre de l'UniGetUI", "UniGetUI (abans WingetUI)")]
- public void TestUniGetUIRefactoring(string language, string uniGetUILogTranslation, string uniGetUITranslation)
+ public void TestUniGetUIRefactoring(
+ string language,
+ string uniGetUILogTranslation,
+ string uniGetUITranslation
+ )
{
LanguageEngine engine = new();
@@ -56,8 +60,14 @@ public void TestStaticallyLoadedLanguages()
Assert.Equal("Usuari | Local", CommonTranslations.ScopeNames[PackageScope.Local]);
Assert.Equal("Màquina | Global", CommonTranslations.ScopeNames[PackageScope.Global]);
- Assert.Equal(PackageScope.Global, CommonTranslations.InvertedScopeNames["Màquina | Global"]);
- Assert.Equal(PackageScope.Local, CommonTranslations.InvertedScopeNames["Usuari | Local"]);
+ Assert.Equal(
+ PackageScope.Global,
+ CommonTranslations.InvertedScopeNames["Màquina | Global"]
+ );
+ Assert.Equal(
+ PackageScope.Local,
+ CommonTranslations.InvertedScopeNames["Usuari | Local"]
+ );
}
/*
diff --git a/src/UniGetUI.Core.Language.Tests/UniGetUI.Core.LanguageEngine.Tests.csproj b/src/UniGetUI.Core.Language.Tests/UniGetUI.Core.LanguageEngine.Tests.csproj
index 1c2e54bab6..8682af74cf 100644
--- a/src/UniGetUI.Core.Language.Tests/UniGetUI.Core.LanguageEngine.Tests.csproj
+++ b/src/UniGetUI.Core.Language.Tests/UniGetUI.Core.LanguageEngine.Tests.csproj
@@ -1,40 +1,37 @@
+
+ $(PortableTargetFramework)
+
+ false
+ true
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+
+
+
-
- $(PortableTargetFramework)
-
- false
- true
-
+
+
+
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
- runtime; build; native; contentfiles; analyzers; buildtransitive
- all
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
diff --git a/src/UniGetUI.Core.LanguageEngine/LanguageData.cs b/src/UniGetUI.Core.LanguageEngine/LanguageData.cs
index 07e6d10cc6..90542c8789 100644
--- a/src/UniGetUI.Core.LanguageEngine/LanguageData.cs
+++ b/src/UniGetUI.Core.LanguageEngine/LanguageData.cs
@@ -54,10 +54,25 @@ public static ReadOnlyDictionary TranslationPercentages
private static ReadOnlyDictionary LoadTranslationPercentages()
{
- try {
- if (JsonNode.Parse(File.ReadAllText(Path.Join(CoreData.UniGetUIExecutableDirectory, "Assets", "Data", "TranslatedPercentages.json"))) is JsonObject val)
+ try
+ {
+ if (
+ JsonNode.Parse(
+ File.ReadAllText(
+ Path.Join(
+ CoreData.UniGetUIExecutableDirectory,
+ "Assets",
+ "Data",
+ "TranslatedPercentages.json"
+ )
+ )
+ )
+ is JsonObject val
+ )
{
- return new(val.ToDictionary(x => x.Key, x => (x.Value ?? ("404%" + x.Key)).ToString()));
+ return new(
+ val.ToDictionary(x => x.Key, x => (x.Value ?? ("404%" + x.Key)).ToString())
+ );
}
return new(new Dictionary());
@@ -74,10 +89,26 @@ private static ReadOnlyDictionary LoadLanguageReference()
{
try
{
- if (JsonNode.Parse(File.ReadAllText(Path.Join(CoreData.UniGetUIExecutableDirectory, "Assets", "Data",
- "LanguagesReference.json"))) is JsonObject val)
+ if (
+ JsonNode.Parse(
+ File.ReadAllText(
+ Path.Join(
+ CoreData.UniGetUIExecutableDirectory,
+ "Assets",
+ "Data",
+ "LanguagesReference.json"
+ )
+ )
+ )
+ is JsonObject val
+ )
{
- return new(val.ToDictionary(x => x.Key, x => (x.Value ?? ("NoNameLang_" + x.Key)).ToString()));
+ return new(
+ val.ToDictionary(
+ x => x.Key,
+ x => (x.Value ?? ("NoNameLang_" + x.Key)).ToString()
+ )
+ );
}
return new(new Dictionary());
@@ -94,8 +125,14 @@ private static Person[] LoadLanguageTranslatorList()
{
try
{
- string JsonContents = File.ReadAllText(Path.Join(CoreData.UniGetUIExecutableDirectory, "Assets", "Data",
- "Translators.json"));
+ string JsonContents = File.ReadAllText(
+ Path.Join(
+ CoreData.UniGetUIExecutableDirectory,
+ "Assets",
+ "Data",
+ "Translators.json"
+ )
+ );
if (JsonNode.Parse(JsonContents) is not JsonObject TranslatorsInfo)
{
@@ -107,7 +144,9 @@ private static Person[] LoadLanguageTranslatorList()
{
if (!LanguageReference.ContainsKey(langKey.Key))
{
- Logger.Warn($"Language {langKey.Key} not in list, maybe has not been added yet?");
+ Logger.Warn(
+ $"Language {langKey.Key} not in list, maybe has not been added yet?"
+ );
continue;
}
@@ -127,8 +166,11 @@ private static Person[] LoadLanguageTranslatorList()
}
Person person = new(
- Name: (url is not null ? "@" : "") + (translator["name"] ?? "").ToString(),
- ProfilePicture: url is not null ? new Uri(url.ToString() + ".png") : null,
+ Name: (url is not null ? "@" : "")
+ + (translator["name"] ?? "").ToString(),
+ ProfilePicture: url is not null
+ ? new Uri(url.ToString() + ".png")
+ : null,
GitHubUrl: url,
Language: !LangShown ? LanguageReference[langKey.Key] : ""
);
@@ -163,4 +205,3 @@ public static class CommonTranslations
};
}
}
-
diff --git a/src/UniGetUI.Core.LanguageEngine/LanguageEngine.cs b/src/UniGetUI.Core.LanguageEngine/LanguageEngine.cs
index fba0fa5c36..1459d4f90d 100644
--- a/src/UniGetUI.Core.LanguageEngine/LanguageEngine.cs
+++ b/src/UniGetUI.Core.LanguageEngine/LanguageEngine.cs
@@ -65,33 +65,52 @@ public Dictionary LoadLanguageFile(string LangKey)
{
try
{
-
- string BundledLangFileToLoad = Path.Join(CoreData.UniGetUIExecutableDirectory, "Assets", "Languages", "lang_" + LangKey + ".json");
+ string BundledLangFileToLoad = Path.Join(
+ CoreData.UniGetUIExecutableDirectory,
+ "Assets",
+ "Languages",
+ "lang_" + LangKey + ".json"
+ );
JsonObject BundledContents = [];
if (!File.Exists(BundledLangFileToLoad))
{
- Logger.Error($"Tried to access a non-existing bundled language file! file={BundledLangFileToLoad}");
+ Logger.Error(
+ $"Tried to access a non-existing bundled language file! file={BundledLangFileToLoad}"
+ );
}
else
{
try
{
- if (JsonNode.Parse(File.ReadAllText(BundledLangFileToLoad)) is JsonObject parsedObject)
+ if (
+ JsonNode.Parse(File.ReadAllText(BundledLangFileToLoad))
+ is JsonObject parsedObject
+ )
BundledContents = parsedObject;
else
- throw new ArgumentException($"parsedObject was null for lang file {BundledLangFileToLoad}");
+ throw new ArgumentException(
+ $"parsedObject was null for lang file {BundledLangFileToLoad}"
+ );
}
catch (Exception ex)
{
- Logger.Warn($"Something went wrong when parsing language file {BundledLangFileToLoad}");
+ Logger.Warn(
+ $"Something went wrong when parsing language file {BundledLangFileToLoad}"
+ );
Logger.Warn(ex);
}
}
- Dictionary LangDict = BundledContents.ToDictionary(x => x.Key, x => x.Value?.ToString() ?? "");
+ Dictionary LangDict = BundledContents.ToDictionary(
+ x => x.Key,
+ x => x.Value?.ToString() ?? ""
+ );
- string CachedLangFileToLoad = Path.Join(CoreData.UniGetUICacheDirectory_Lang, "lang_" + LangKey + ".json");
+ string CachedLangFileToLoad = Path.Join(
+ CoreData.UniGetUICacheDirectory_Lang,
+ "lang_" + LangKey + ".json"
+ );
if (Settings.Get(Settings.K.DisableLangAutoUpdater))
{
@@ -99,23 +118,34 @@ public Dictionary LoadLanguageFile(string LangKey)
}
else if (!File.Exists(CachedLangFileToLoad))
{
- Logger.Warn($"Tried to access a non-existing cached language file! file={CachedLangFileToLoad}");
+ Logger.Warn(
+ $"Tried to access a non-existing cached language file! file={CachedLangFileToLoad}"
+ );
}
else
{
try
{
- if (JsonNode.Parse(File.ReadAllText(CachedLangFileToLoad)) is JsonObject parsedObject)
- foreach (var keyval in parsedObject.ToDictionary(x => x.Key, x => x.Value))
+ if (
+ JsonNode.Parse(File.ReadAllText(CachedLangFileToLoad))
+ is JsonObject parsedObject
+ )
+ foreach (
+ var keyval in parsedObject.ToDictionary(x => x.Key, x => x.Value)
+ )
{
LangDict[keyval.Key] = keyval.Value?.ToString() ?? "";
}
else
- throw new ArgumentException($"parsedObject was null for lang file {CachedLangFileToLoad}");
+ throw new ArgumentException(
+ $"parsedObject was null for lang file {CachedLangFileToLoad}"
+ );
}
catch (Exception ex)
{
- Logger.Warn($"Something went wrong when parsing language file {BundledLangFileToLoad}");
+ Logger.Warn(
+ $"Something went wrong when parsing language file {BundledLangFileToLoad}"
+ );
Logger.Warn(ex);
}
}
@@ -141,7 +171,11 @@ public async Task DownloadUpdatedLanguageFile(string LangKey)
{
try
{
- Uri NewFile = new("https://raw.githubusercontent.com/Devolutions/UniGetUI/main/src/UniGetUI.Core.LanguageEngine/Assets/Languages/lang_" + LangKey + ".json");
+ Uri NewFile = new(
+ "https://raw.githubusercontent.com/Devolutions/UniGetUI/main/src/UniGetUI.Core.LanguageEngine/Assets/Languages/lang_"
+ + LangKey
+ + ".json"
+ );
HttpClient client = new();
client.DefaultRequestHeaders.UserAgent.ParseAdd(CoreData.UserAgentString);
@@ -152,7 +186,10 @@ public async Task DownloadUpdatedLanguageFile(string LangKey)
Directory.CreateDirectory(CoreData.UniGetUICacheDirectory_Lang);
}
- File.WriteAllText(Path.Join(CoreData.UniGetUICacheDirectory_Lang, "lang_" + LangKey + ".json"), fileContents);
+ File.WriteAllText(
+ Path.Join(CoreData.UniGetUICacheDirectory_Lang, "lang_" + LangKey + ".json"),
+ fileContents
+ );
Logger.ImportantInfo("Lang files were updated successfully from GitHub");
}
@@ -169,15 +206,24 @@ public void LoadStaticTranslation()
CommonTranslations.ScopeNames[PackageScope.Global] = Translate("Machine | Global");
CommonTranslations.InvertedScopeNames.Clear();
- CommonTranslations.InvertedScopeNames.Add(Translate("Machine | Global"), PackageScope.Global);
- CommonTranslations.InvertedScopeNames.Add(Translate("User | Local"), PackageScope.Local);
+ CommonTranslations.InvertedScopeNames.Add(
+ Translate("Machine | Global"),
+ PackageScope.Global
+ );
+ CommonTranslations.InvertedScopeNames.Add(
+ Translate("User | Local"),
+ PackageScope.Local
+ );
}
public string Translate(string key)
{
if (key == "WingetUI")
{
- if (MainLangDict.TryGetValue("formerly WingetUI", out var formerly) && formerly != "")
+ if (
+ MainLangDict.TryGetValue("formerly WingetUI", out var formerly)
+ && formerly != ""
+ )
{
return "UniGetUI (" + formerly + ")";
}
diff --git a/src/UniGetUI.Core.LanguageEngine/UniGetUI.Core.LanguageEngine.csproj b/src/UniGetUI.Core.LanguageEngine/UniGetUI.Core.LanguageEngine.csproj
index 10d2b3bee6..314633789a 100644
--- a/src/UniGetUI.Core.LanguageEngine/UniGetUI.Core.LanguageEngine.csproj
+++ b/src/UniGetUI.Core.LanguageEngine/UniGetUI.Core.LanguageEngine.csproj
@@ -1,82 +1,85 @@
+
+ $(SharedTargetFrameworks)
+
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
+
+
+
diff --git a/src/UniGetUI.Core.Logger/LogEntry.cs b/src/UniGetUI.Core.Logger/LogEntry.cs
index dc7f10704b..0686e6aee5 100644
--- a/src/UniGetUI.Core.Logger/LogEntry.cs
+++ b/src/UniGetUI.Core.Logger/LogEntry.cs
@@ -21,6 +21,5 @@ public LogEntry(string content, SeverityLevel severity)
Content = content;
Severity = severity;
}
-
}
}
diff --git a/src/UniGetUI.Core.Logger/Logger.cs b/src/UniGetUI.Core.Logger/Logger.cs
index a6a40a34ea..19a817e82d 100644
--- a/src/UniGetUI.Core.Logger/Logger.cs
+++ b/src/UniGetUI.Core.Logger/Logger.cs
@@ -7,62 +7,92 @@ public static class Logger
private static readonly List LogContents = [];
// String parameter log functions
- public static void ImportantInfo(string s, [System.Runtime.CompilerServices.CallerMemberName] string caller = "")
+ public static void ImportantInfo(
+ string s,
+ [System.Runtime.CompilerServices.CallerMemberName] string caller = ""
+ )
{
Diagnostics.Debug.WriteLine($"[{caller}] " + s);
LogContents.Add(new LogEntry(s, LogEntry.SeverityLevel.Success));
}
- public static void Debug(string s, [System.Runtime.CompilerServices.CallerMemberName] string caller = "")
+ public static void Debug(
+ string s,
+ [System.Runtime.CompilerServices.CallerMemberName] string caller = ""
+ )
{
Diagnostics.Debug.WriteLine($"[{caller}] " + s);
LogContents.Add(new LogEntry(s, LogEntry.SeverityLevel.Debug));
}
- public static void Info(string s, [System.Runtime.CompilerServices.CallerMemberName] string caller = "")
+ public static void Info(
+ string s,
+ [System.Runtime.CompilerServices.CallerMemberName] string caller = ""
+ )
{
Diagnostics.Debug.WriteLine($"[{caller}] " + s);
LogContents.Add(new LogEntry(s, LogEntry.SeverityLevel.Info));
}
- public static void Warn(string s, [System.Runtime.CompilerServices.CallerMemberName] string caller = "")
+ public static void Warn(
+ string s,
+ [System.Runtime.CompilerServices.CallerMemberName] string caller = ""
+ )
{
Diagnostics.Debug.WriteLine($"[{caller}] " + s);
LogContents.Add(new LogEntry(s, LogEntry.SeverityLevel.Warning));
}
- public static void Error(string s, [System.Runtime.CompilerServices.CallerMemberName] string caller = "")
+ public static void Error(
+ string s,
+ [System.Runtime.CompilerServices.CallerMemberName] string caller = ""
+ )
{
Diagnostics.Debug.WriteLine($"[{caller}] " + s);
LogContents.Add(new LogEntry(s, LogEntry.SeverityLevel.Error));
}
// Exception parameter log functions
- public static void ImportantInfo(Exception e, [System.Runtime.CompilerServices.CallerMemberName] string caller = "")
+ public static void ImportantInfo(
+ Exception e,
+ [System.Runtime.CompilerServices.CallerMemberName] string caller = ""
+ )
{
Diagnostics.Debug.WriteLine($"[{caller}] " + e.ToString());
LogContents.Add(new LogEntry(e.ToString(), LogEntry.SeverityLevel.Success));
}
- public static void Debug(Exception e, [System.Runtime.CompilerServices.CallerMemberName] string caller = "")
+ public static void Debug(
+ Exception e,
+ [System.Runtime.CompilerServices.CallerMemberName] string caller = ""
+ )
{
Diagnostics.Debug.WriteLine($"[{caller}] " + e.ToString());
LogContents.Add(new LogEntry(e.ToString(), LogEntry.SeverityLevel.Debug));
}
- public static void Info(Exception e, [System.Runtime.CompilerServices.CallerMemberName] string caller = "")
+ public static void Info(
+ Exception e,
+ [System.Runtime.CompilerServices.CallerMemberName] string caller = ""
+ )
{
Diagnostics.Debug.WriteLine($"[{caller}] " + e.ToString());
LogContents.Add(new LogEntry(e.ToString(), LogEntry.SeverityLevel.Info));
}
- public static void Warn(Exception e, [System.Runtime.CompilerServices.CallerMemberName] string caller = "")
+ public static void Warn(
+ Exception e,
+ [System.Runtime.CompilerServices.CallerMemberName] string caller = ""
+ )
{
Diagnostics.Debug.WriteLine($"[{caller}] " + e.ToString());
LogContents.Add(new LogEntry(e.ToString(), LogEntry.SeverityLevel.Warning));
}
- public static void Error(Exception e, [System.Runtime.CompilerServices.CallerMemberName] string caller = "")
+ public static void Error(
+ Exception e,
+ [System.Runtime.CompilerServices.CallerMemberName] string caller = ""
+ )
{
Diagnostics.Debug.WriteLine($"[{caller}] " + e.ToString());
LogContents.Add(new LogEntry(e.ToString(), LogEntry.SeverityLevel.Error));
diff --git a/src/UniGetUI.Core.Logger/UniGetUI.Core.Logging.csproj b/src/UniGetUI.Core.Logger/UniGetUI.Core.Logging.csproj
index 6c35193aa1..3b1ea6e421 100644
--- a/src/UniGetUI.Core.Logger/UniGetUI.Core.Logging.csproj
+++ b/src/UniGetUI.Core.Logger/UniGetUI.Core.Logging.csproj
@@ -1,6 +1,9 @@
+
+ $(SharedTargetFrameworks)
+
-
-
-
+
+
+
diff --git a/src/UniGetUI.Core.Logging.Tests/LogEntryTests.cs b/src/UniGetUI.Core.Logging.Tests/LogEntryTests.cs
index 568f12031d..d04bc0f740 100644
--- a/src/UniGetUI.Core.Logging.Tests/LogEntryTests.cs
+++ b/src/UniGetUI.Core.Logging.Tests/LogEntryTests.cs
@@ -34,4 +34,4 @@ public async Task TestLogEntry()
Assert.True(logEntry2.Time < logEntry3.Time);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/UniGetUI.Core.Logging.Tests/UniGetUI.Core.Logging.Tests.csproj b/src/UniGetUI.Core.Logging.Tests/UniGetUI.Core.Logging.Tests.csproj
index 1955578c9a..2a8cccea10 100644
--- a/src/UniGetUI.Core.Logging.Tests/UniGetUI.Core.Logging.Tests.csproj
+++ b/src/UniGetUI.Core.Logging.Tests/UniGetUI.Core.Logging.Tests.csproj
@@ -1,40 +1,37 @@
+
+ $(PortableTargetFramework)
+
+ false
+ true
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+
+
+
-
- $(PortableTargetFramework)
-
- false
- true
-
+
+
+
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
- runtime; build; native; contentfiles; analyzers; buildtransitive
- all
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
diff --git a/src/UniGetUI.Core.SecureSettings/SecureGHTokenManager.cs b/src/UniGetUI.Core.SecureSettings/SecureGHTokenManager.cs
index ebb6d1beb7..1970bbbfee 100644
--- a/src/UniGetUI.Core.SecureSettings/SecureGHTokenManager.cs
+++ b/src/UniGetUI.Core.SecureSettings/SecureGHTokenManager.cs
@@ -26,7 +26,9 @@ public static void StoreToken(string token)
}
catch (Exception ex)
{
- Logger.Error("An error occurred while attempting to delete the currently stored GitHub Token");
+ Logger.Error(
+ "An error occurred while attempting to delete the currently stored GitHub Token"
+ );
Logger.Error(ex);
}
}
@@ -60,7 +62,9 @@ public static void DeleteToken()
}
catch (Exception ex)
{
- Logger.Error("An error occurred while attempting to delete the currently stored GitHub Token");
+ Logger.Error(
+ "An error occurred while attempting to delete the currently stored GitHub Token"
+ );
Logger.Error(ex);
}
}
diff --git a/src/UniGetUI.Core.SecureSettings/SecureSettings.cs b/src/UniGetUI.Core.SecureSettings/SecureSettings.cs
index 240211119f..b5063de47c 100644
--- a/src/UniGetUI.Core.SecureSettings/SecureSettings.cs
+++ b/src/UniGetUI.Core.SecureSettings/SecureSettings.cs
@@ -15,7 +15,7 @@ public enum K
AllowImportPrePostOpCommands,
ForceUserGSudo,
AllowCustomManagerPaths,
- Unset
+ Unset,
};
public static string ResolveKey(K key)
@@ -30,7 +30,9 @@ public static string ResolveKey(K key)
K.AllowCustomManagerPaths => "AllowCustomManagerPaths",
K.Unset => throw new InvalidDataException("SecureSettings key was unset!"),
- _ => throw new KeyNotFoundException($"The SecureSettings key {key} was not found on the ResolveKey map")
+ _ => throw new KeyNotFoundException(
+ $"The SecureSettings key {key} was not found on the ResolveKey map"
+ ),
};
}
@@ -87,10 +89,10 @@ public static async Task TrySet(K key, bool enabled)
Verb = "runas",
ArgumentList =
{
- enabled? Args.ENABLE_FOR_USER: Args.DISABLE_FOR_USER,
+ enabled ? Args.ENABLE_FOR_USER : Args.DISABLE_FOR_USER,
purifiedUser,
- purifiedSetting
- }
+ purifiedSetting,
+ },
};
p.Start();
@@ -140,7 +142,11 @@ private static string GetSecureSettingsRoot()
{
if (OperatingSystem.IsWindows())
{
- return Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "UniGetUI", "SecureSettings");
+ return Path.Join(
+ Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
+ "UniGetUI",
+ "SecureSettings"
+ );
}
return Path.Join(CoreData.UniGetUIDataDirectory, "SecureSettings");
diff --git a/src/UniGetUI.Core.SecureSettings/UniGetUI.Core.SecureSettings.csproj b/src/UniGetUI.Core.SecureSettings/UniGetUI.Core.SecureSettings.csproj
index f5614d0e25..5d077fcf5d 100644
--- a/src/UniGetUI.Core.SecureSettings/UniGetUI.Core.SecureSettings.csproj
+++ b/src/UniGetUI.Core.SecureSettings/UniGetUI.Core.SecureSettings.csproj
@@ -1,4 +1,8 @@
+
+ $(SharedTargetFrameworks)
+
+
diff --git a/src/UniGetUI.Core.Settings.Tests/SettingsTest.cs b/src/UniGetUI.Core.Settings.Tests/SettingsTest.cs
index f568c5da00..6ca45f8ebe 100644
--- a/src/UniGetUI.Core.Settings.Tests/SettingsTest.cs
+++ b/src/UniGetUI.Core.Settings.Tests/SettingsTest.cs
@@ -3,16 +3,27 @@
namespace UniGetUI.Core.SettingsEngine.Tests
{
-
public sealed class SerializableTestSub
{
- public SerializableTestSub(string s, int c) { sub = s; count = c; }
+ public SerializableTestSub(string s, int c)
+ {
+ sub = s;
+ count = c;
+ }
+
public string sub { get; set; }
public int count { get; set; }
}
+
public sealed class SerializableTest
{
- public SerializableTest(string t, int c, SerializableTestSub s) { title = t; count = c; sub = s; }
+ public SerializableTest(string t, int c, SerializableTestSub s)
+ {
+ title = t;
+ count = c;
+ sub = s;
+ }
+
public string title { get; set; }
public int count { get; set; }
public SerializableTestSub sub { get; set; }
@@ -47,8 +58,11 @@ public void Dispose()
Directory.Delete(_testRoot, true);
}
- private string GetNewSettingPath(string fileName) => Path.Combine(_newConfigurationDirectory, fileName);
- private string GetOldSettingsPath(string fileName) => Path.Combine(_oldConfigurationDirectory, fileName);
+ private string GetNewSettingPath(string fileName) =>
+ Path.Combine(_newConfigurationDirectory, fileName);
+
+ private string GetOldSettingsPath(string fileName) =>
+ Path.Combine(_oldConfigurationDirectory, fileName);
[Fact]
public void TestSettingsSaveToNewDirectory()
@@ -90,63 +104,139 @@ public void TestBooleanSettings(Settings.K key, bool st1, bool st2, bool st3, bo
string sName = Settings.ResolveKey(key);
Settings.Set(key, st1);
Assert.Equal(st1, Settings.Get(key));
- Assert.Equal(st1, File.Exists(Path.Join(CoreData.UniGetUIUserConfigurationDirectory, sName)));
+ Assert.Equal(
+ st1,
+ File.Exists(Path.Join(CoreData.UniGetUIUserConfigurationDirectory, sName))
+ );
Settings.Set(key, st2);
Assert.Equal(st2, Settings.Get(key));
- Assert.Equal(st2, File.Exists(Path.Join(CoreData.UniGetUIUserConfigurationDirectory, sName)));
+ Assert.Equal(
+ st2,
+ File.Exists(Path.Join(CoreData.UniGetUIUserConfigurationDirectory, sName))
+ );
Settings.Set(key, st3);
Assert.Equal(st3, Settings.Get(key));
- Assert.Equal(st3, File.Exists(Path.Join(CoreData.UniGetUIUserConfigurationDirectory, sName)));
+ Assert.Equal(
+ st3,
+ File.Exists(Path.Join(CoreData.UniGetUIUserConfigurationDirectory, sName))
+ );
Settings.Set(key, st4);
Assert.Equal(st4, Settings.Get(key));
- Assert.Equal(st4, File.Exists(Path.Join(CoreData.UniGetUIUserConfigurationDirectory, sName)));
+ Assert.Equal(
+ st4,
+ File.Exists(Path.Join(CoreData.UniGetUIUserConfigurationDirectory, sName))
+ );
Settings.Set(key, false); // Cleanup
Assert.False(Settings.Get(key));
- Assert.False(File.Exists(Path.Join(CoreData.UniGetUIUserConfigurationDirectory, sName)));
+ Assert.False(
+ File.Exists(Path.Join(CoreData.UniGetUIUserConfigurationDirectory, sName))
+ );
}
[Theory]
- [InlineData(Settings.K.Test1, "RandomFirstValue", "RandomSecondValue", "", "RandomThirdValue")]
+ [InlineData(
+ Settings.K.Test1,
+ "RandomFirstValue",
+ "RandomSecondValue",
+ "",
+ "RandomThirdValue"
+ )]
[InlineData(Settings.K.Test2, "", "", "", "RandomThirdValue")]
[InlineData(Settings.K.Test3, "RandomFirstValue", " ", "\t", "RandomThirdValue")]
[InlineData(Settings.K.Test4, "RandomFirstValue", "", "", "")]
[InlineData(Settings.K.Test5, "\x00\x01\x02\u0003", "", "", "RandomThirdValue")]
- public void TestValueSettings(Settings.K key, string st1, string st2, string st3, string st4)
+ public void TestValueSettings(
+ Settings.K key,
+ string st1,
+ string st2,
+ string st3,
+ string st4
+ )
{
string sName = Settings.ResolveKey(key);
Settings.SetValue(key, st1);
Assert.Equal(st1, Settings.GetValue(key));
- Assert.Equal(st1 != "", File.Exists(Path.Join(CoreData.UniGetUIUserConfigurationDirectory, sName)));
+ Assert.Equal(
+ st1 != "",
+ File.Exists(Path.Join(CoreData.UniGetUIUserConfigurationDirectory, sName))
+ );
Settings.SetValue(key, st2);
Assert.Equal(st2, Settings.GetValue(key));
- Assert.Equal(st2 != "", File.Exists(Path.Join(CoreData.UniGetUIUserConfigurationDirectory, sName)));
+ Assert.Equal(
+ st2 != "",
+ File.Exists(Path.Join(CoreData.UniGetUIUserConfigurationDirectory, sName))
+ );
Settings.SetValue(key, st3);
Assert.Equal(st3, Settings.GetValue(key));
- Assert.Equal(st3 != "", File.Exists(Path.Join(CoreData.UniGetUIUserConfigurationDirectory, sName)));
+ Assert.Equal(
+ st3 != "",
+ File.Exists(Path.Join(CoreData.UniGetUIUserConfigurationDirectory, sName))
+ );
Settings.SetValue(key, st4);
Assert.Equal(st4, Settings.GetValue(key));
- Assert.Equal(st4 != "", File.Exists(Path.Join(CoreData.UniGetUIUserConfigurationDirectory, sName)));
+ Assert.Equal(
+ st4 != "",
+ File.Exists(Path.Join(CoreData.UniGetUIUserConfigurationDirectory, sName))
+ );
Settings.Set(key, false); // Cleanup
Assert.False(Settings.Get(key));
Assert.Equal("", Settings.GetValue(key));
- Assert.False(File.Exists(Path.Join(CoreData.UniGetUIUserConfigurationDirectory, sName)));
+ Assert.False(
+ File.Exists(Path.Join(CoreData.UniGetUIUserConfigurationDirectory, sName))
+ );
}
[Theory]
- [InlineData("lsTestSetting1", new[] { "UpdatedFirstValue", "RandomString1", "RandomTestValue", "AnotherRandomValue" }, new[] { 9, 15, 21, 1001, 4567 }, new[] { "itemA", "itemB", "itemC" })]
- [InlineData("lsktjgshdfsd", new[] { "newValue1", "updatedString", "emptyString", "randomSymbols@123" }, new[] { 42, 23, 17, 98765, 3482 }, new[] { "itemX", "itemY", "itemZ" })]
- [InlineData("lsª", new[] { "UniqueVal1", "NewVal2", "AnotherVal3", "TestVal4" }, new[] { 123, 456, 789, 321, 654 }, new[] { "item1", "item2", "item3" })]
- [InlineData("lsTestSettingEntry With A Space", new[] { "ChangedFirstValue", "AlteredSecondVal", "TestedValue", "FinalVal" }, new[] { 23, 98, 456, 753, 951 }, new[] { "testA", "testB", "testC" })]
- [InlineData("lsVeryVeryLongTestSettingEntrySoTheClassCanReallyBeStressedOut", new[] { "newCharacterSet\x99\x01\x02", "UpdatedRandomValue", "TestEmptyString", "FinalTestValue" }, new[] { 0b11001100, 1234, 5678, 1000000 }, new[] { "finalTest1", "finalTest2", "finalTest3" })]
- public void TestListSettings(string SettingName, string[] ls1Array, int[] ls2Array, string[] ls3Array)
+ [InlineData(
+ "lsTestSetting1",
+ new[] { "UpdatedFirstValue", "RandomString1", "RandomTestValue", "AnotherRandomValue" },
+ new[] { 9, 15, 21, 1001, 4567 },
+ new[] { "itemA", "itemB", "itemC" }
+ )]
+ [InlineData(
+ "lsktjgshdfsd",
+ new[] { "newValue1", "updatedString", "emptyString", "randomSymbols@123" },
+ new[] { 42, 23, 17, 98765, 3482 },
+ new[] { "itemX", "itemY", "itemZ" }
+ )]
+ [InlineData(
+ "lsª",
+ new[] { "UniqueVal1", "NewVal2", "AnotherVal3", "TestVal4" },
+ new[] { 123, 456, 789, 321, 654 },
+ new[] { "item1", "item2", "item3" }
+ )]
+ [InlineData(
+ "lsTestSettingEntry With A Space",
+ new[] { "ChangedFirstValue", "AlteredSecondVal", "TestedValue", "FinalVal" },
+ new[] { 23, 98, 456, 753, 951 },
+ new[] { "testA", "testB", "testC" }
+ )]
+ [InlineData(
+ "lsVeryVeryLongTestSettingEntrySoTheClassCanReallyBeStressedOut",
+ new[]
+ {
+ "newCharacterSet\x99\x01\x02",
+ "UpdatedRandomValue",
+ "TestEmptyString",
+ "FinalTestValue",
+ },
+ new[] { 0b11001100, 1234, 5678, 1000000 },
+ new[] { "finalTest1", "finalTest2", "finalTest3" }
+ )]
+ public void TestListSettings(
+ string SettingName,
+ string[] ls1Array,
+ int[] ls2Array,
+ string[] ls3Array
+ )
{
// Convert arrays to Lists manually
List ls1 = ls1Array.ToList();
@@ -154,11 +244,20 @@ public void TestListSettings(string SettingName, string[] ls1Array, int[] ls2Arr
List ls3 = [];
foreach (var item in ls3Array.ToList())
{
- ls3.Add(new SerializableTest(item, new Random().Next(), new SerializableTestSub(item + new Random().Next(), new Random().Next())));
+ ls3.Add(
+ new SerializableTest(
+ item,
+ new Random().Next(),
+ new SerializableTestSub(item + new Random().Next(), new Random().Next())
+ )
+ );
}
Settings.ClearList(SettingName);
- Assert.Empty(Settings.GetList