.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

@@ -2,6 +2,7 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
@@ -157,12 +158,12 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter
/// </summary>
public static void FeetToFt(ref string[] split)
{
if (split[1].ToLowerInvariant() == "feet")
if (string.Equals(split[1], "feet", StringComparison.OrdinalIgnoreCase))
{
split[1] = "ft";
}
if (split[3].ToLowerInvariant() == "feet")
if (string.Equals(split[3], "feet", StringComparison.OrdinalIgnoreCase))
{
split[3] = "ft";
}
@@ -183,7 +184,8 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter
public static void GallonHandler(ref string[] split, CultureInfo culture)
{
HashSet<string> britishCultureNames = new HashSet<string>() { "en-AI", "en-VG", "en-GB", "en-KY", "en-MS", "en-AG", "en-DM", "en-GD", "en-KN", "en-LC", "en-VC", "en-IE", "en-GY", "en-AE" };
if (split[1].ToLowerInvariant() == "gal" || split[1].ToLowerInvariant() == "gallon")
if (string.Equals(split[1], "gal", StringComparison.OrdinalIgnoreCase) ||
string.Equals(split[1], "gallon", StringComparison.OrdinalIgnoreCase))
{
if (britishCultureNames.Contains(culture.Name))
{
@@ -195,7 +197,8 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter
}
}
if (split[3].ToLowerInvariant() == "gal" || split[3].ToLowerInvariant() == "gallon")
if (string.Equals(split[3], "gal", StringComparison.OrdinalIgnoreCase) ||
string.Equals(split[3], "gallon", StringComparison.OrdinalIgnoreCase))
{
if (britishCultureNames.Contains(culture.Name))
{

View File

@@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Windows;
using System.Windows.Input;
@@ -27,6 +28,8 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter
private static string _icon_path;
private bool _disposed;
private static readonly CompositeFormat CopyToClipboard = System.Text.CompositeFormat.Parse(Properties.Resources.copy_to_clipboard);
public void Init(PluginInitContext context)
{
ArgumentNullException.ThrowIfNull(context);
@@ -61,7 +64,7 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter
Title = result.ToString(null),
IcoPath = _icon_path,
Score = 300,
SubTitle = string.Format(CultureInfo.CurrentCulture, Properties.Resources.copy_to_clipboard, result.QuantityInfo.Name),
SubTitle = string.Format(CultureInfo.CurrentCulture, CopyToClipboard, result.QuantityInfo.Name),
Action = c =>
{
var ret = false;

View File

@@ -36,7 +36,8 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter
private static Enum GetUnitEnum(string unit, QuantityInfo unitInfo)
{
UnitInfo first = Array.Find(unitInfo.UnitInfos, info =>
unit.ToLowerInvariant() == info.Name.ToLowerInvariant() || unit.ToLowerInvariant() == info.PluralName.ToLowerInvariant());
string.Equals(unit, info.Name, StringComparison.OrdinalIgnoreCase) ||
string.Equals(unit, info.PluralName, StringComparison.OrdinalIgnoreCase));
if (first != null)
{