[PowerLauncher] Enable analyzer and fix warnings (#16900)

This commit is contained in:
CleanCodeDeveloper 2022-03-09 13:08:12 +01:00 committed by GitHub
parent eb961ee052
commit 46684966a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 7 deletions

View File

@ -17,13 +17,13 @@ namespace PowerLauncher.Converters
{
public class HighlightTextConverter : IMultiValueConverter
{
public object Convert(object[] value, Type targetType, object parameter, CultureInfo cultureInfo)
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
#pragma warning disable CA1062 // Validate arguments of public methods
var text = value[0] as string;
var text = values[0] as string;
#pragma warning restore CA1062 // Validate arguments of public methods
var highlightData = value[1] as List<int>;
var selected = value[2] as bool? == true;
var highlightData = values[1] as List<int>;
var selected = values[2] as bool? == true;
if (highlightData == null || !highlightData.Any())
{
@ -51,7 +51,7 @@ namespace PowerLauncher.Converters
return textBlock;
}
public object[] ConvertBack(object value, Type[] targetType, object parameter, CultureInfo culture)
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
return new[] { DependencyProperty.UnsetValue, DependencyProperty.UnsetValue };
}

View File

@ -24,6 +24,8 @@
<PackageTags>PowerToys</PackageTags>
<NeutralLanguage>en-US</NeutralLanguage>
<AssemblyName>PowerToys.PowerLauncher</AssemblyName>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisMode>Recommended</AnalysisMode>
</PropertyGroup>

View File

@ -80,6 +80,7 @@ namespace PowerLauncher
}
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1309:Use ordinal string comparison", Justification = "Using StringComparison.InvariantCulture since this is user facing")]
private void ToolTip_Opened(object sender, RoutedEventArgs e)
{
if (string.Equals(sender.GetType().FullName, "System.Windows.Controls.ToolTip", System.StringComparison.InvariantCulture))
@ -89,6 +90,7 @@ namespace PowerLauncher
}
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1309:Use ordinal string comparison", Justification = "Using StringComparison.InvariantCulture since this is user facing")]
private void SuggestionsListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (string.Equals(((ListView)e.OriginalSource).Name, "SuggestionsList", System.StringComparison.InvariantCulture))

View File

@ -27,6 +27,7 @@ using Wox.Plugin.Logger;
namespace PowerLauncher.ViewModel
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1309:Use ordinal string comparison", Justification = "Using CurrentCultureIgnoreCase for user facing strings. Each usage is attributed with a comment.")]
public class MainViewModel : BaseModel, ISavable, IDisposable
{
private string _currentQuery;
@ -1018,7 +1019,7 @@ namespace PowerLauncher.ViewModel
if (input.IndexOf(query, StringComparison.OrdinalIgnoreCase) == 0)
{
// Use the same case as the input query for the matched portion of the string
return query + input.Substring(query.Length);
return string.Concat(query, input.AsSpan(query.Length));
}
}
}
@ -1035,7 +1036,7 @@ namespace PowerLauncher.ViewModel
// Using OrdinalIgnoreCase since this is internal
if (input.IndexOf(query, StringComparison.OrdinalIgnoreCase) == 0)
{
return query + input.Substring(query.Length);
return string.Concat(query, input.AsSpan(query.Length));
}
}