Skip to content

Commit

Permalink
Run code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
marticliment committed Jun 3, 2024
1 parent 299c2b0 commit 0224b92
Show file tree
Hide file tree
Showing 101 changed files with 364 additions and 802 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Runtime.InteropServices;
using ExternalLibraries.Pickers.Guids;
using ExternalLibraries.Pickers.Guids;
using System.Runtime.InteropServices;

namespace ExternalLibraries.Pickers.Classes;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Runtime.InteropServices;
using ExternalLibraries.Pickers.Guids;
using ExternalLibraries.Pickers.Guids;
using System.Runtime.InteropServices;

namespace ExternalLibraries.Pickers.Classes;

Expand Down
6 changes: 2 additions & 4 deletions src/ExternalLibraries.FilePickers/Classes/Helper.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using ExternalLibraries.Pickers.Enums;
using ExternalLibraries.Pickers.Enums;
using ExternalLibraries.Pickers.Interfaces;
using ExternalLibraries.Pickers.Structures;
using System.Runtime.InteropServices;

namespace ExternalLibraries.Pickers.Classes;

Expand Down
4 changes: 1 addition & 3 deletions src/ExternalLibraries.FilePickers/Enums/FOS.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace ExternalLibraries.Pickers.Enums;
namespace ExternalLibraries.Pickers.Enums;

[Flags]
// https://learn.microsoft.com/ru-ru/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptions
Expand Down
4 changes: 1 addition & 3 deletions src/ExternalLibraries.FilePickers/FileOpenPicker.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using ExternalLibraries.Pickers.Classes;
using ExternalLibraries.Pickers.Classes;
using ExternalLibraries.Pickers.Enums;

namespace ExternalLibraries.Pickers;
Expand Down
4 changes: 1 addition & 3 deletions src/ExternalLibraries.FilePickers/FileSavePicker.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using ExternalLibraries.Pickers.Classes;
using ExternalLibraries.Pickers.Classes;
using ExternalLibraries.Pickers.Enums;

namespace ExternalLibraries.Pickers;
Expand Down
3 changes: 1 addition & 2 deletions src/ExternalLibraries.FilePickers/FolderPicker.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using ExternalLibraries.Pickers.Classes;
using ExternalLibraries.Pickers.Classes;
using ExternalLibraries.Pickers.Enums;

namespace ExternalLibraries.Pickers;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Runtime.InteropServices;
using ExternalLibraries.Pickers.Classes;
using ExternalLibraries.Pickers.Classes;
using ExternalLibraries.Pickers.Guids;
using System.Runtime.InteropServices;

namespace ExternalLibraries.Pickers.Interfaces;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Runtime.InteropServices;
using ExternalLibraries.Pickers.Classes;
using ExternalLibraries.Pickers.Classes;
using ExternalLibraries.Pickers.Guids;
using System.Runtime.InteropServices;

namespace ExternalLibraries.Pickers.Interfaces;

Expand Down
7 changes: 3 additions & 4 deletions src/ExternalLibraries.FilePickers/Interfaces/IFileDialog.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ExternalLibraries.Pickers.Enums;
using ExternalLibraries.Pickers.Enums;
using ExternalLibraries.Pickers.Guids;
using ExternalLibraries.Pickers.Structures;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace ExternalLibraries.Pickers.Interfaces;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ExternalLibraries.Pickers.Enums;
using ExternalLibraries.Pickers.Enums;
using ExternalLibraries.Pickers.Guids;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace ExternalLibraries.Pickers.Interfaces;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ExternalLibraries.Pickers.Guids;
using ExternalLibraries.Pickers.Guids;
using ExternalLibraries.Pickers.Structures;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace ExternalLibraries.Pickers.Interfaces;

Expand Down
3 changes: 1 addition & 2 deletions src/ExternalLibraries.FilePickers/Interfaces/IModalWindow.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using ExternalLibraries.Pickers.Guids;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ExternalLibraries.Pickers.Guids;

namespace ExternalLibraries.Pickers.Interfaces;

Expand Down
5 changes: 2 additions & 3 deletions src/ExternalLibraries.FilePickers/Interfaces/IShellItem.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using System;
using ExternalLibraries.Pickers.Enums;
using ExternalLibraries.Pickers.Guids;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ExternalLibraries.Pickers.Enums;
using ExternalLibraries.Pickers.Guids;

namespace ExternalLibraries.Pickers.Interfaces;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ExternalLibraries.Pickers.Enums;
using ExternalLibraries.Pickers.Enums;
using ExternalLibraries.Pickers.Guids;
using ExternalLibraries.Pickers.Structures;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace ExternalLibraries.Pickers.Interfaces;

Expand Down
3 changes: 1 addition & 2 deletions src/ExternalLibraries.FilePickers/Structures/PROPERTYKEY.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices;

namespace ExternalLibraries.Pickers.Structures;

Expand Down
4 changes: 1 addition & 3 deletions src/UniGetUI.Core.Classes.Tests/PersonTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Xunit;

namespace UniGetUI.Core.Classes.Tests
namespace UniGetUI.Core.Classes.Tests
{
public class PersonTests
{
Expand Down
10 changes: 4 additions & 6 deletions src/UniGetUI.Core.Classes.Tests/SingletonBaseTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Xunit;

namespace UniGetUI.Core.Classes.Tests
namespace UniGetUI.Core.Classes.Tests
{
public class SingletonBaseTest
{
Expand All @@ -19,16 +17,16 @@ private class InheritedClass2 : SingletonBase<InheritedClass2>
[Fact]
public void TestSingletonClass()
{
var Type1Instance1 = InheritedClass1.Instance;
InheritedClass1 Type1Instance1 = InheritedClass1.Instance;
Type1Instance1.Attribute1 = 1;

var Type1Instance2 = InheritedClass1.Instance;
InheritedClass1 Type1Instance2 = InheritedClass1.Instance;
Type1Instance2.Attribute1 = 3;

Assert.Equal(Type1Instance1.Attribute1, Type1Instance2.Attribute1);
Assert.Equal(Type1Instance1, Type1Instance2);

var Type2Instance1 = new InheritedClass2();
InheritedClass2 Type2Instance1 = new();
Type2Instance1.Attribute1 = 2;

Assert.NotEqual(Type1Instance1.Attribute1, Type2Instance1.Attribute1);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Xunit;

namespace UniGetUI.Core.Classes.Tests
{
public class SortableObservableCollectionTests
Expand All @@ -8,8 +6,8 @@ public class SortableObservableCollectionTests
public void TestSortableCollection()
{
int EventTriggeredCount = 0;
var SortableCollection = new SortableObservableCollection<int>();

SortableObservableCollection<int> SortableCollection = new();
SortableCollection.CollectionChanged += (s, e) => { EventTriggeredCount++; };
SortableCollection.SortingSelector = (s) => { return s; };
SortableCollection.Add(1);
Expand Down
8 changes: 1 addition & 7 deletions src/UniGetUI.Core.Classes/SingletonBase.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UniGetUI.Core.Classes
namespace UniGetUI.Core.Classes
{
public abstract class SingletonBase<T> where T : SingletonBase<T>
{
Expand Down
10 changes: 5 additions & 5 deletions src/UniGetUI.Core.Data.Tests/CoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ public void CheckOtherAttributes()
Assert.NotEmpty(CoreData.VersionName);
Assert.NotEqual(0, CoreData.VersionNumber);
Assert.True(File.Exists(CoreData.IgnoredUpdatesDatabaseFile), "The Ignored Updates database file does not exist, but it should have been created automatically.");
var notif_1 = CoreData.VolatileNotificationIdCounter;
var notif_2 = CoreData.VolatileNotificationIdCounter;

int notif_1 = CoreData.VolatileNotificationIdCounter;
int notif_2 = CoreData.VolatileNotificationIdCounter;
Assert.NotEqual(notif_1, notif_2);

var notif_3 = CoreData.UpdatesAvailableNotificationId;
var notif_4 = CoreData.UpdatesAvailableNotificationId;
int notif_3 = CoreData.UpdatesAvailableNotificationId;
int notif_4 = CoreData.UpdatesAvailableNotificationId;
Assert.True(notif_3 == notif_4, "The UpdatesAvailableNotificationId must be always the same");
Assert.NotEqual(0, CoreData.UpdatesAvailableNotificationId);

Expand Down
8 changes: 2 additions & 6 deletions src/UniGetUI.Core.Data/CoreData.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System.Linq.Expressions;
using System.Reflection.Metadata.Ecma335;
using UniGetUI.Core.Logging;
using Windows.Storage.Search;
using Windows.System.Diagnostics;
using UniGetUI.Core.Logging;

namespace UniGetUI.Core.Data
{
Expand Down Expand Up @@ -31,7 +27,7 @@ public static string UniGetUIInstallationOptionsDirectory
{
get
{
var path = Path.Join(UniGetUIDataDirectory, "InstallationOptions");
string path = Path.Join(UniGetUIDataDirectory, "InstallationOptions");
if(!Directory.Exists(path)) Directory.CreateDirectory(path);
return path;
}
Expand Down
43 changes: 18 additions & 25 deletions src/UniGetUI.Core.IconEngine.Tests/IconCacheEngineTests.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using UniGetUI.Core.Data;
using UniGetUI.Core.Tools;
using UniGetUI.Core.Data;

namespace UniGetUI.Core.IconEngine.Tests
{
Expand All @@ -18,19 +11,19 @@ public static class IconCacheEngineTests
public static async Task TestCacheEngineForSha256(string url, byte[] data, string managerName, string packageId)
{
string extension = url.Split(".")[^1];
var expectedFile = Path.Join(CoreData.UniGetUICacheDirectory_Icons, managerName, packageId + "." + extension);
string expectedFile = Path.Join(CoreData.UniGetUICacheDirectory_Icons, managerName, packageId + "." + extension);
if(File.Exists(expectedFile)) File.Delete(expectedFile);

CacheableIcon icon = new CacheableIcon(new Uri(url), data);
var path = await IconCacheEngine.DownloadIconOrCache(icon, managerName, packageId);
CacheableIcon icon = new(new Uri(url), data);
string path = await IconCacheEngine.DownloadIconOrCache(icon, managerName, packageId);
Assert.Equal(expectedFile, path);
Assert.True(File.Exists(path));

var oldModificationDate = File.GetLastWriteTime(path);
DateTime oldModificationDate = File.GetLastWriteTime(path);

icon = new CacheableIcon(new Uri(url.Replace("icon", "nonexistingicon")), data);
path = await IconCacheEngine.DownloadIconOrCache(icon, managerName, packageId);
var newModificationDate = File.GetLastWriteTime(path);
DateTime newModificationDate = File.GetLastWriteTime(path);

Assert.Equal(oldModificationDate, newModificationDate);
Assert.Equal(expectedFile, path);
Expand All @@ -42,27 +35,27 @@ public static async Task TestCacheEngineForSha256(string url, byte[] data, strin
public static async Task TestCacheEngineForPackageVersion(string url, string version, string managerName, string packageId)
{
string extension = url.Split(".")[^1];
var expectedFile = Path.Join(CoreData.UniGetUICacheDirectory_Icons, managerName, packageId + "." + extension);
string expectedFile = Path.Join(CoreData.UniGetUICacheDirectory_Icons, managerName, packageId + "." + extension);
if (File.Exists(expectedFile)) File.Delete(expectedFile);

CacheableIcon icon = new CacheableIcon(new Uri(url), version);
var path = await IconCacheEngine.DownloadIconOrCache(icon, managerName, packageId);
CacheableIcon icon = new(new Uri(url), version);
string path = await IconCacheEngine.DownloadIconOrCache(icon, managerName, packageId);
Assert.Equal(expectedFile, path);
Assert.True(File.Exists(path));

var oldModificationDate = File.GetLastWriteTime(path);
DateTime oldModificationDate = File.GetLastWriteTime(path);

icon = new CacheableIcon(new Uri(url), version);
path = await IconCacheEngine.DownloadIconOrCache(icon, managerName, packageId);
var newModificationDate = File.GetLastWriteTime(path);
DateTime newModificationDate = File.GetLastWriteTime(path);

Assert.Equal(oldModificationDate, newModificationDate);
Assert.Equal(expectedFile, path);
Assert.True(File.Exists(path));

icon = new CacheableIcon(new Uri(url), version+"-beta0");
path = await IconCacheEngine.DownloadIconOrCache(icon, managerName, packageId);
var newNewModificationDate = File.GetLastWriteTime(path);
DateTime newNewModificationDate = File.GetLastWriteTime(path);

Assert.NotEqual(oldModificationDate, newNewModificationDate);
Assert.Equal(expectedFile, path);
Expand All @@ -75,27 +68,27 @@ public static async Task TestCacheEngineForPackageVersion(string url, string ver
public static async Task TestCacheEngineForPackageSize(string url, long size, string managerName, string packageId)
{
string extension = url.Split(".")[^1];
var expectedFile = Path.Join(CoreData.UniGetUICacheDirectory_Icons, managerName, packageId + "." + extension);
string expectedFile = Path.Join(CoreData.UniGetUICacheDirectory_Icons, managerName, packageId + "." + extension);
if (File.Exists(expectedFile)) File.Delete(expectedFile);

CacheableIcon icon = new CacheableIcon(new Uri(url), size);
var path = await IconCacheEngine.DownloadIconOrCache(icon, managerName, packageId);
CacheableIcon icon = new(new Uri(url), size);
string path = await IconCacheEngine.DownloadIconOrCache(icon, managerName, packageId);
Assert.Equal(expectedFile, path);
Assert.True(File.Exists(path));

var oldModificationDate = File.GetLastWriteTime(path);
DateTime oldModificationDate = File.GetLastWriteTime(path);

icon = new CacheableIcon(new Uri(url), size);
path = await IconCacheEngine.DownloadIconOrCache(icon, managerName, packageId);
var newModificationDate = File.GetLastWriteTime(path);
DateTime newModificationDate = File.GetLastWriteTime(path);

Assert.Equal(oldModificationDate, newModificationDate);
Assert.Equal(expectedFile, path);
Assert.True(File.Exists(path));

icon = new CacheableIcon(new Uri(url), size+1);
path = await IconCacheEngine.DownloadIconOrCache(icon, managerName, packageId);
var newNewModificationDate = File.GetLastWriteTime(path);
DateTime newNewModificationDate = File.GetLastWriteTime(path);

Assert.NotEqual(oldModificationDate, newNewModificationDate);
Assert.Equal(expectedFile, path);
Expand Down
10 changes: 5 additions & 5 deletions src/UniGetUI.Core.IconEngine.Tests/IconDatabaseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public async Task LoadIconsAndScreenshotsDatabaseTest()

await iconStore.LoadIconAndScreenshotsDatabaseAsync();

var iconCount = iconStore.GetIconCount();
IconDatabase.IconCount iconCount = iconStore.GetIconCount();
Assert.NotEqual(0, iconCount.PackagesWithIconCount);
Assert.NotEqual(0, iconCount.PackagesWithScreenshotCount);
Assert.NotEqual(0, iconCount.TotalScreenshotCount);
Expand All @@ -23,10 +23,10 @@ public async Task TestGetExistingIconAndImagesAsync()
{
await iconStore.LoadIconAndScreenshotsDatabaseAsync();

var icon = iconStore.GetIconUrlForId("__test_entry_DO_NOT_EDIT_PLEASE");
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);

var 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]);
Expand All @@ -38,10 +38,10 @@ public async Task TestGetNonExistingIconAndImagesAsync()
{
await iconStore.LoadIconAndScreenshotsDatabaseAsync();

var nonexistent_icon = iconStore.GetIconUrlForId("__test_entry_THIS_ICON_DOES_NOT_EXTST");
string nonexistent_icon = iconStore.GetIconUrlForId("__test_entry_THIS_ICON_DOES_NOT_EXTST");
Assert.Empty(nonexistent_icon);

var 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);
}
}
Expand Down
Loading

0 comments on commit 0224b92

Please sign in to comment.