Skip to content

Commit 0d094e4

Browse files
Fix build warnings (#4458)
* Fix low-risk build warnings * Fix IDE2000 build warnings * Fix CA1852 build warnings * Fix CS4014 build warnings * Fix safe CA1822 build warning * Fix IDE0031 build warnings * Fix IDE0051 build warnings * Fix CA1830 and CA1835 build warnings * Fix CS0067 build warnings * Fix CA2201 build warnings * Fix safe nullability build warnings * Fix remaining CA1416 build warnings * Finalize build warning cleanup * Fix verified final build warnings * Fix generated CS4014 build warnings * Fix CI meta-test for AutoUpdater serialization
1 parent 0e90737 commit 0d094e4

File tree

84 files changed

+172
-188
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+172
-188
lines changed

src/Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,6 @@
5252
<PropertyGroup>
5353
<LangVersion>latest</LangVersion>
5454
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
55+
<NoWarn>$(NoWarn);EnableGenerateDocumentationFile</NoWarn>
5556
</PropertyGroup>
5657
</Project>

src/UniGetUI.Core.Classes.Tests/TaskRecyclerTests.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using System.Diagnostics.CodeAnalysis;
2+
13
namespace UniGetUI.Core.Classes.Tests;
24

35
public class TaskRecyclerTests
@@ -8,16 +10,18 @@ private int MySlowMethod1()
810
return new Random().Next();
911
}
1012

11-
private class TestClass
13+
private sealed class TestClass
1214
{
1315
public TestClass() {}
1416

17+
[SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "Instance methods are required to validate TaskRecycler instance-bound delegate behavior.")]
1518
public string SlowMethod2()
1619
{
1720
Thread.Sleep(1000);
1821
return new Random().Next().ToString();
1922
}
2023

24+
[SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "Instance methods are required to validate TaskRecycler instance-bound delegate behavior.")]
2125
public string SlowMethod3()
2226
{
2327
Thread.Sleep(1000);

src/UniGetUI.Core.Classes/TaskRecycler.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ public static void RemoveFromCache(Func<ReturnT> method)
9393

9494
// ---------------------------------------------------------------------------------------------------------------
9595

96-
9796
/// <summary>
9897
/// Handles running the task if no such task was found on cache, and returning the cached task if it was found.
9998
/// </summary>

src/UniGetUI.Core.Data/CoreCredentialStore.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public static void DeleteSecret(string resourceName, string userName)
9393
}
9494
}
9595

96+
#if !WINDOWS
9697
private static string GetStorageDirectory()
9798
=> Path.Join(CoreData.UniGetUIDataDirectory, "SecureStorage");
9899

@@ -104,4 +105,5 @@ private static string GetStableFileName(string resourceName, string userName)
104105
byte[] hash = SHA256.HashData(Encoding.UTF8.GetBytes($"{resourceName}\n{userName}"));
105106
return Convert.ToHexString(hash) + ".secret";
106107
}
108+
#endif
107109
}

src/UniGetUI.Core.Data/CoreData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static string UniGetUIDataDirectory
5959
}
6060
} else if (IS_PORTABLE is true)
6161
{
62-
return PORTABLE_PATH ?? throw new Exception("This shouldn't be possible");
62+
return PORTABLE_PATH ?? throw new InvalidOperationException("This shouldn't be possible");
6363
}
6464

6565
string old_path = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".wingetui");

src/UniGetUI.Core.IconStore/IconDatabase.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public struct IconCount
1919
public IconCount() { }
2020
}
2121

22-
2322
private static IconDatabase? __instance;
2423
public static IconDatabase Instance
2524
{
@@ -57,7 +56,6 @@ public async Task LoadIconAndScreenshotsDatabaseAsync()
5756

5857
Logger.ImportantInfo("Downloaded new icons and screenshots successfully!");
5958

60-
6159
if (!File.Exists(IconsAndScreenshotsFile))
6260
{
6361
Logger.Error("Icon Database file not found");
@@ -74,7 +72,6 @@ public async Task LoadIconAndScreenshotsDatabaseAsync()
7472
await LoadFromCacheAsync();
7573
}
7674

77-
7875
public async Task LoadFromCacheAsync()
7976
{
8077
try

src/UniGetUI.Core.SecureSettings/SecureSettings.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ public static string ResolveKey(K key)
3434
};
3535
}
3636

37-
3837
private static readonly Dictionary<string, bool> _cache = new();
3938

4039
public static class Args

src/UniGetUI.Core.Settings.Tests/SettingsTest.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public sealed class SerializableTest
1818
public SerializableTestSub sub { get; set; }
1919
}
2020

21-
public class SettingsTest
21+
public class SettingsTest : IDisposable
2222
{
2323
private readonly string _testRoot;
2424

@@ -50,7 +50,6 @@ public void Dispose()
5050
private string GetNewSettingPath(string fileName) => Path.Combine(_newConfigurationDirectory, fileName);
5151
private string GetOldSettingsPath(string fileName) => Path.Combine(_oldConfigurationDirectory, fileName);
5252

53-
5453
[Fact]
5554
public void TestSettingsSaveToNewDirectory()
5655
{
@@ -175,7 +174,9 @@ public void TestListSettings(string SettingName, string[] ls1Array, int[] ls2Arr
175174
Assert.Equal("this is now a test case", Settings.GetListItem<string>(SettingName, 3));
176175
Assert.Null(Settings.GetListItem<string>(SettingName, 4));
177176

178-
Assert.Equal(Settings.GetListItem<string>(SettingName, 0), JsonSerializer.Deserialize<List<string>>(File.ReadAllText(Path.Join(CoreData.UniGetUIUserConfigurationDirectory, $"{SettingName}.json")), Settings.SerializationOptions)[0]);
177+
List<string>? persistedList = JsonSerializer.Deserialize<List<string>>(File.ReadAllText(Path.Join(CoreData.UniGetUIUserConfigurationDirectory, $"{SettingName}.json")), Settings.SerializationOptions);
178+
Assert.NotNull(persistedList);
179+
Assert.Equal(Settings.GetListItem<string>(SettingName, 0), persistedList[0]);
179180
Settings.ClearList(SettingName);
180181
Assert.Empty(Settings.GetList<object>(SettingName) ?? ["this shouldn't be null; something's wrong"]);
181182

src/UniGetUI.Core.Settings/SettingsEngine_Dictionaries.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public static partial class Settings
1010
private static readonly ConcurrentDictionary<K, Dictionary<object, object?>> _dictionarySettings = new();
1111

1212
// Returns an empty dictionary if the setting doesn't exist and null if the types are invalid
13-
private static Dictionary<KeyT, ValueT?> _getDictionary<KeyT, ValueT>(K key)
13+
private static Dictionary<KeyT, ValueT?>? _getDictionary<KeyT, ValueT>(K key)
1414
where KeyT : notnull
1515
{
1616
string setting = ResolveKey(key);
@@ -73,7 +73,7 @@ public static partial class Settings
7373
}
7474

7575
// Returns an empty dictionary if the setting doesn't exist and null if the types are invalid
76-
public static IReadOnlyDictionary<KeyT, ValueT?> GetDictionary<KeyT, ValueT>(K settingsKey)
76+
public static IReadOnlyDictionary<KeyT, ValueT?>? GetDictionary<KeyT, ValueT>(K settingsKey)
7777
where KeyT : notnull
7878
{
7979
return _getDictionary<KeyT, ValueT?>(settingsKey);

src/UniGetUI.Core.Tools/DWMThreadHelper.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ private static void ChangeState(bool suspend, IntPtr expectedAdress, ref bool Is
144144
return;
145145
}
146146

147-
148147
if (suspend)
149148
{
150149
uint res = SuspendThread(hThread);

0 commit comments

Comments
 (0)