.NET 8 Upgrade Silenced Errors Fix (#30469)

* [Dev][Build] .NET 8 Upgrade Silenced errors first fix.

* [Dev][Build] .NET 8 Upgrade Silenced errors. CA1859

* [Dev][Build] .NET 8 Upgrade Silenced errors. CA1854.

* [Dev][Build] .NET 8 Upgrade Silenced errors. CA1860

* [Dev][Build] .NET 8 Upgrade Silenced errors. CA1861

* [Dev][Build] .NET 8 Upgrade Silenced errors. CA1862

* [Dev][Build] .NET 8 Upgrade Silenced errors. CA1863

* [Dev][Build] .NET 8 Upgrade Silenced errors. CA1864

* [Dev][Build] .NET 8 Upgrade Silenced errors. CA1865

* [Dev][Build] .NET 8 Upgrade Silenced errors. CA2208

* [Dev][Build] .NET 8 Upgrade Silenced errors. CS9191

* [Dev][Build] .NET 8 Upgrade Silenced errors. Spell check

* [Dev][Build] .NET 8 Upgrade Silenced errors. Spell check

* [Dev][Build] .NET 8 Upgrade Silenced errors.
- CompositeFormat variables used more than once in the same file were assigned to a single variable.
- GetProcessesByName logic fix.
- String comparion fix.
- ArgumentOutOfRangeException message change.

* [Dev][Build] .NET 8 Upgrade Silenced errors.
- Null check added.
- static readonly CompositeFormat added for all fields.
This commit is contained in:
gokcekantarci
2023-12-28 13:37:13 +03:00
committed by GitHub
parent cd57659ef6
commit a94b3eec39
112 changed files with 429 additions and 291 deletions

View File

@@ -127,7 +127,7 @@ namespace Wox.Infrastructure.Exception
foreach (string versionKeyName in ndpKey.GetSubKeyNames())
{
// Using InvariantCulture since this is internal and involves version key
if (versionKeyName.StartsWith("v", StringComparison.InvariantCulture))
if (versionKeyName.StartsWith('v'))
{
RegistryKey versionKey = ndpKey.OpenSubKey(versionKeyName);
string name = (string)versionKey.GetValue("Version", string.Empty);

View File

@@ -21,6 +21,15 @@ namespace Wox.Infrastructure
private static readonly IFileInfoFactory FileInfo = FileSystem.FileInfo;
private static readonly IDirectory Directory = FileSystem.Directory;
private static readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions
{
WriteIndented = true,
Converters =
{
new JsonStringEnumConverter(),
},
};
/// <summary>
/// http://www.yinwang.org/blog-cn/2015/11/21/programming-philosophy
/// </summary>
@@ -81,14 +90,7 @@ namespace Wox.Infrastructure
public static string Formatted<T>(this T t)
{
var formatted = JsonSerializer.Serialize(t, new JsonSerializerOptions
{
WriteIndented = true,
Converters =
{
new JsonStringEnumConverter(),
},
});
var formatted = JsonSerializer.Serialize(t, _serializerOptions);
return formatted;
}

View File

@@ -29,7 +29,7 @@ namespace Wox.Infrastructure.Image
private static readonly ImageCache ImageCache = new ImageCache();
private static readonly ConcurrentDictionary<string, string> GuidToKey = new ConcurrentDictionary<string, string>();
private static IImageHashGenerator _hashGenerator;
private static ImageHashGenerator _hashGenerator;
public static string ErrorIconPath { get; set; } = Constant.LightThemedErrorIcon;

View File

@@ -44,7 +44,7 @@ namespace Wox.Infrastructure.Storage
public bool Any()
{
return _items.Any();
return !_items.IsEmpty;
}
public void Add(T insertedItem)

View File

@@ -29,6 +29,8 @@ namespace Wox.Infrastructure
public static StringMatcher Instance { get; internal set; }
private static readonly char[] Separator = new[] { ' ' };
[Obsolete("This method is obsolete and should not be used. Please use the static function StringMatcher.FuzzySearch")]
public static int Score(string source, string target)
{
@@ -104,7 +106,7 @@ namespace Wox.Infrastructure
var fullStringToCompareWithoutCase = opt.IgnoreCase ? stringToCompare.ToUpper(CultureInfo.InvariantCulture) : stringToCompare;
var queryWithoutCase = opt.IgnoreCase ? query.ToUpper(CultureInfo.InvariantCulture) : query;
var querySubstrings = queryWithoutCase.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
var querySubstrings = queryWithoutCase.Split(Separator, StringSplitOptions.RemoveEmptyEntries);
int currentQuerySubstringIndex = 0;
var currentQuerySubstring = querySubstrings[currentQuerySubstringIndex];
var currentQuerySubstringCharacterIndex = 0;