Skip to content

Commit

Permalink
Merge pull request #2531 from Saibamen/fix_warnings
Browse files Browse the repository at this point in the history
Fix warnings + fix typos
  • Loading branch information
marticliment authored Jul 25, 2024
2 parents ab7427e + e38cc1d commit 254de6e
Show file tree
Hide file tree
Showing 102 changed files with 285 additions and 676 deletions.
4 changes: 2 additions & 2 deletions src/ExternalLibraries.FilePickers/Enums/SIATTRIBFLAGS.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
namespace ExternalLibraries.Pickers.Enums;
namespace ExternalLibraries.Pickers.Enums;

// https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-ishellitemarray-getattributes
internal enum SIATTRIBFLAGS
{
SIATTRIBFLAGS_AND = 0x00000001, // if multiple items and the attirbutes together.
SIATTRIBFLAGS_AND = 0x00000001, // if multiple items and the attributes together.
SIATTRIBFLAGS_OR = 0x00000002, // if multiple items or the attributes together.
SIATTRIBFLAGS_APPCOMPAT = 0x00000003, // Call GetAttributes directly on the ShellFolder for multiple attributes
}
4 changes: 1 addition & 3 deletions src/UniGetUI.Core.Classes/SingletonBase.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
namespace UniGetUI.Core.Classes
namespace UniGetUI.Core.Classes
{
public abstract class SingletonBase<T> where T : SingletonBase<T>
{
private static readonly Lazy<T> Lazy =
new(() => (Activator.CreateInstance(typeof(T), true) as T)!);

public static T Instance => Lazy.Value;

protected SingletonBase() { }
}
}
6 changes: 2 additions & 4 deletions src/UniGetUI.Core.Data/CoreData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ private static int GetCodePage()
{
try
{
Process p = new Process()
Process p = new Process
{
StartInfo = new ProcessStartInfo()
StartInfo = new ProcessStartInfo
{
FileName = "chcp.com",
RedirectStandardOutput = true,
Expand Down Expand Up @@ -155,7 +155,6 @@ public static string IgnoredUpdatesDatabaseFile

public static string ManagerLogs = "";


private static int __volatile_notification_id_counter = 1235;

/// <summary>
Expand Down Expand Up @@ -214,7 +213,6 @@ public static string UniGetUIExecutableFile

public static string GSudoPath = "";


/// <summary>
/// This method will return the most appropriate data directory.
/// If the new directory exists, it will be used.
Expand Down
24 changes: 12 additions & 12 deletions src/UniGetUI.Core.Data/Licenses.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace UniGetUI.Core.Data
namespace UniGetUI.Core.Data
{
public static class LicenseData
{
Expand All @@ -12,8 +12,8 @@ public static class LicenseData
{"Windows App Sdk", "MIT"},
{"NancyFx", "MIT"},
{"YamlDotNet", "MIT"},
{"InnoDependencyInstaller", "CPOL 1.02" },
{"InnoDependencyInstaller", "CPOL 1.02" },

// Package managers and related
{"Winget", "MIT"},
{"Scoop", "MIT"},
Expand All @@ -33,16 +33,16 @@ public static class LicenseData

public static Dictionary<string, Uri> LicenseURLs = new(){
{"UniGetUI", new Uri("https://github.com/marticliment/WingetUI/blob/main/LICENSE")},
// C# Libraries

// 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")},
{"NancyFx", new Uri("https://github.com/NancyFx/Nancy/blob/master/license.txt")},
{"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")},
Expand All @@ -54,15 +54,15 @@ public static class LicenseData
{".NET Sdk", new Uri("https://github.com/dotnet/sdk/blob/main/LICENSE.TXT")},
{"dotnet-tools-outdated", new Uri("https://github.com/rychlym/dotnet-tools-outdated/blob/master/LICENSE")},
{"PowerShell Gallery", new Uri("https://www.powershellgallery.com/")},
// Other

// Other
{"Gsudo", new Uri("https://github.com/gerardog/gsudo/blob/master/LICENSE.txt")},
{"Icons", new Uri("https://icons8.com/license")},
};

public static Dictionary<string, Uri> 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/")},
Expand All @@ -71,7 +71,7 @@ public static class LicenseData
{"NancyFx", new Uri("https://github.com/NancyFx/Nancy/")},
{"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/")},
Expand All @@ -83,8 +83,8 @@ public static class LicenseData
{".NET Sdk", new Uri("https://dotnet.microsoft.com/")},
{"dotnet-tools-outdated", new Uri("https://github.com/rychlym/dotnet-tools-outdated/")},
{"PowerShell Gallery", new Uri("https://www.powershellgallery.com/")},
// Other

// Other
{"Gsudo", new Uri("https://github.com/gerardog/gsudo/")},
{"Icons", new Uri("https://icons8.com")},
};
Expand Down
3 changes: 1 addition & 2 deletions src/UniGetUI.Core.IconEngine.Tests/IconCacheEngineTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using UniGetUI.Core.Data;
using UniGetUI.Core.Data;

namespace UniGetUI.Core.IconEngine.Tests
{
Expand Down Expand Up @@ -68,7 +68,6 @@ public static async Task TestCacheEngineForPackageVersion(string url, string ver
Assert.True(File.Exists(path));
}


[Theory]
[InlineData("https://marticliment.com/resources/wingetui.png", 47903, "TestManager", "Package3")]
public static async Task TestCacheEngineForPackageSize(string url, long size, string managerName, string packageId)
Expand Down
7 changes: 3 additions & 4 deletions src/UniGetUI.Core.IconStore/IconCacheEngine.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Security.Cryptography;
using System.Security.Cryptography;
using UniGetUI.Core.Data;
using UniGetUI.Core.Logging;
using UniGetUI.Core.Tools;
Expand Down Expand Up @@ -55,7 +55,7 @@ public static class IconCacheEngine
/// <summary>
/// Returns the path to the icon file, downloading it if necessary
/// </summary>
/// <param name="icon">a CacheableIcon object representing the object</param>
/// <param name="_icon">a CacheableIcon object representing the object</param>
/// <param name="ManagerName">The name of the PackageManager</param>
/// <param name="PackageId">the Id of the package</param>
/// <returns>A path to a local icon file</returns>
Expand All @@ -66,7 +66,7 @@ public static async Task<string> DownloadIconOrCache(CacheableIcon? _icon, strin
return "";
}

CacheableIcon icon = _icon ?? new CacheableIcon();
var icon = (CacheableIcon)_icon;

string extension = icon.Url.AbsolutePath[icon.Url.AbsolutePath.LastIndexOf('.')..][1..];

Expand Down Expand Up @@ -186,7 +186,6 @@ public static async Task<string> DownloadIconOrCache(CacheableIcon? _icon, strin
return FilePath;
}


private static async Task<byte[]> CalculateFileHashAsync(string filePath)
{
using FileStream stream = File.OpenRead(filePath);
Expand Down
12 changes: 4 additions & 8 deletions src/UniGetUI.Core.IconStore/IconDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

namespace UniGetUI.Core.IconEngine
{
/// <summary>
/// This class represents the structure of the icon and screenshot database. It is used to deserialize the JSON data.
/// </summary>
public class IconDatabase
{
public struct IconCount
Expand Down Expand Up @@ -42,15 +45,9 @@ public static void InitializeInstance()
private Dictionary<string, IconScreenshotDatabase_v2.PackageIconAndScreenshots> IconDatabaseData = [];
private IconCount __icon_count = new();

/// <summary>
/// Tis class represents the structure of the icon and screenshot database. It is used to deserialize the JSON data.
/// </summary>


/// <summary>
/// Download the icon and screenshots database to a local file, and load it into memory
/// </summary>
/// <returns></returns>
public async void LoadIconAndScreenshotsDatabase()
{
await LoadIconAndScreenshotsDatabaseAsync();
Expand Down Expand Up @@ -83,7 +80,6 @@ public async Task LoadIconAndScreenshotsDatabaseAsync()
Logger.Warn(e);
}


if (!File.Exists(IconsAndScreenshotsFile))
{
Logger.Error("Icon Database file not found");
Expand All @@ -98,7 +94,7 @@ public async Task LoadIconAndScreenshotsDatabaseAsync()
IconDatabaseData = JsonData.icons_and_screenshots;
}

__icon_count = new IconCount()
__icon_count = new IconCount
{
PackagesWithIconCount = JsonData.package_count.packages_with_icon,
PackagesWithScreenshotCount = JsonData.package_count.packages_with_screenshot,
Expand Down
3 changes: 1 addition & 2 deletions src/UniGetUI.Core.Language.Tests/LanguageDataTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public void TranslatorsListNotEmptyTest()
public void TranslatorsListTest(Person translator)
=> Assert.NotEmpty(translator.Name);


[Fact]
public void LanguageReferenceNotEmptyTest()
{
Expand All @@ -44,4 +43,4 @@ public void TranslatedPercentageNotEmptyTests()
}
}
}
}
}
3 changes: 1 addition & 2 deletions src/UniGetUI.Core.Language.Tests/LanguageEngineTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using UniGetUI.PackageEngine.Enums;
using UniGetUI.PackageEngine.Enums;

namespace UniGetUI.Core.Language.Tests
{
Expand Down Expand Up @@ -39,7 +39,6 @@ public void TestUniGetUIRefactoring(string language, string uniGetUILogTranslati
Assert.Equal(uniGetUITranslation, engine.Translate("WingetUI"));
}


[Fact]
public void LocalFallbackTest()
{
Expand Down
5 changes: 1 addition & 4 deletions src/UniGetUI.Core.LanguageEngine/LanguageData.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.ObjectModel;
using System.Collections.ObjectModel;
using System.Runtime.InteropServices;
using System.Text.Json.Nodes;
using UniGetUI.Core.Classes;
Expand All @@ -10,9 +10,6 @@ namespace UniGetUI.Core.Language
{
public static class LanguageData
{
/// <summary>
/// Returns
/// </summary>
private static Person[]? __translators_list;

public static Person[] TranslatorsList
Expand Down
3 changes: 0 additions & 3 deletions src/UniGetUI.Core.LanguageEngine/LanguageEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public Dictionary<string, string> LoadLanguageFile(string LangKey, bool ForceBun
}
}


Dictionary<string, string>? __LangDict = (JsonNode.Parse(File.ReadAllText(LangFileToLoad)) as JsonObject)?.ToDictionary(x => x.Key, x => x.Value != null ? x.Value.ToString() : "");

if (__LangDict != null)
Expand Down Expand Up @@ -103,8 +102,6 @@ public Dictionary<string, string> LoadLanguageFile(string LangKey, bool ForceBun
/// Downloads and saves an updated version of the translations for the specified language.
/// </summary>
/// <param name="LangKey">The Id of the language to download</param>
/// <param name="UseOldUrl">Use the new or the old Url (should not be used manually)</param>
/// <returns></returns>
public async Task DownloadUpdatedLanguageFile(string LangKey)
{
try
Expand Down
4 changes: 1 addition & 3 deletions src/UniGetUI.Core.Logger/Logger.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Diagnostics = System.Diagnostics;
using Diagnostics = System.Diagnostics;

namespace UniGetUI.Core.Logging
{
Expand Down Expand Up @@ -37,7 +37,6 @@ public static void Error(string s)
LogContents.Add(new LogEntry(s, LogEntry.SeverityLevel.Error));
}


// Exception parameter log functions
public static void ImportantInfo(Exception e)
{
Expand Down Expand Up @@ -69,7 +68,6 @@ public static void Error(Exception e)
LogContents.Add(new LogEntry(e.ToString(), LogEntry.SeverityLevel.Error));
}


public static LogEntry[] GetLogs()
{
return LogContents.ToArray();
Expand Down
4 changes: 2 additions & 2 deletions src/UniGetUI.Core.Tools.Tests/ToolsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void TestRandomStringGenerator(int length)
Assert.NotEqual(string1, string3);
}

foreach (string s in new []{string1, string2, string3})
foreach (string s in new[] { string1, string2, string3 })
{
foreach (char c in s)
{
Expand Down Expand Up @@ -137,4 +137,4 @@ public void TestSafeQueryString(string query, string expected)
Assert.Equal(CoreTools.EnsureSafeQueryString(query), expected);
}
}
}
}
Loading

0 comments on commit 254de6e

Please sign in to comment.