.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

@@ -20,7 +20,7 @@ namespace ColorPicker.Behaviors
private static readonly TimeSpan _animationTimeSmaller = _animationTime;
private static readonly IEasingFunction _easeFunctionSmaller = new QuadraticEase() { EasingMode = EasingMode.EaseIn };
private static void CustomAnimation(DependencyProperty prop, IAnimatable sender, double fromValue, double toValue)
private static void CustomAnimation(DependencyProperty prop, FrameworkElement sender, double fromValue, double toValue)
{
// if the animation is to/from a value of 0, it will cancel the current animation
DoubleAnimation move = null;

View File

@@ -329,7 +329,7 @@ namespace ColorPicker.Controls
newHexString = newHexString.ToLowerInvariant();
// Return only with hashtag if user typed it before
bool addHashtag = oldValue.StartsWith("#", StringComparison.InvariantCulture);
bool addHashtag = oldValue.StartsWith('#');
return addHashtag ? "#" + newHexString : newHexString;
}
@@ -348,7 +348,7 @@ namespace ColorPicker.Controls
else
{
// Hex with or without hashtag and six characters
return hexCodeText.StartsWith("#", StringComparison.InvariantCulture) ? hexCodeText : "#" + hexCodeText;
return hexCodeText.StartsWith('#') ? hexCodeText : "#" + hexCodeText;
}
}

View File

@@ -8,6 +8,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Windows.Media;
using ColorPicker.Models;
@@ -21,6 +22,9 @@ namespace ColorPicker.Helpers
internal static class SerializationHelper
{
public static readonly JsonSerializerOptions DefaultOptions = new JsonSerializerOptions { WriteIndented = false };
public static readonly JsonSerializerOptions IndentedOptions = new JsonSerializerOptions { WriteIndented = true };
public static Dictionary<string, Dictionary<string, string>> ConvertToDesiredColorFormats(
IList colorsToExport,
IEnumerable<ColorFormatModel> colorRepresentations,
@@ -116,10 +120,7 @@ namespace ColorPicker.Helpers
public static string ToJson(this Dictionary<string, Dictionary<string, string>> source, bool indented = true)
{
var options = new JsonSerializerOptions
{
WriteIndented = indented,
};
var options = indented ? IndentedOptions : DefaultOptions;
return JsonSerializer.Serialize(source, options);
}

View File

@@ -91,7 +91,7 @@ namespace ColorPicker.Helpers
ShowZoomWindow(point);
}
private static BitmapSource BitmapToImageSource(Bitmap bitmap)
private static BitmapImage BitmapToImageSource(Bitmap bitmap)
{
using (MemoryStream memory = new MemoryStream())
{

View File

@@ -22,7 +22,7 @@ namespace ColorPicker.Settings
[Export(typeof(IUserSettings))]
public class UserSettings : IUserSettings
{
private readonly ISettingsUtils _settingsUtils;
private readonly SettingsUtils _settingsUtils;
private const string ColorPickerModuleName = "ColorPicker";
private const string ColorPickerHistoryFilename = "colorHistory.json";
private const string DefaultActivationShortcut = "Ctrl + Break";
@@ -36,6 +36,11 @@ namespace ColorPicker.Settings
private bool _loadingColorsHistory;
private static readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions
{
WriteIndented = true,
};
[ImportingConstructor]
public UserSettings(Helpers.IThrottledActionInvoker throttledActionInvoker)
{
@@ -58,7 +63,7 @@ namespace ColorPicker.Settings
{
if (!_loadingColorsHistory)
{
_settingsUtils.SaveSettings(JsonSerializer.Serialize(ColorHistory, new JsonSerializerOptions { WriteIndented = true }), ColorPickerModuleName, ColorPickerHistoryFilename);
_settingsUtils.SaveSettings(JsonSerializer.Serialize(ColorHistory, _serializerOptions), ColorPickerModuleName, ColorPickerHistoryFilename);
}
}