[Plugin.Folder] Enable analyzer and fix warnings (#16997)

This commit is contained in:
CleanCodeDeveloper
2022-03-14 16:45:40 +01:00
committed by GitHub
parent 561882c2f1
commit 3e9c7f83c8
3 changed files with 14 additions and 14 deletions

View File

@@ -13,6 +13,8 @@
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath> <AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<Platforms>x64</Platforms> <Platforms>x64</Platforms>
<NeutralLanguage>en-US</NeutralLanguage> <NeutralLanguage>en-US</NeutralLanguage>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisMode>Recommended</AnalysisMode>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">

View File

@@ -6,12 +6,10 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Globalization; using System.Globalization;
using System.IO;
using System.IO.Abstractions; using System.IO.Abstractions;
using System.Linq; using System.Linq;
using ManagedCommon; using ManagedCommon;
using Microsoft.Plugin.Folder.Sources.Result; using Microsoft.Plugin.Folder.Sources.Result;
using Wox.Plugin;
namespace Microsoft.Plugin.Folder.Sources namespace Microsoft.Plugin.Folder.Sources
{ {
@@ -85,21 +83,21 @@ namespace Microsoft.Plugin.Folder.Sources
return (search, incompleteName); return (search, incompleteName);
} }
public IEnumerable<IItemResult> Query(string querySearch) public IEnumerable<IItemResult> Query(string search)
{ {
if (querySearch == null) if (search == null)
{ {
throw new ArgumentNullException(nameof(querySearch)); throw new ArgumentNullException(nameof(search));
} }
var processed = Process(querySearch); var processed = Process(search);
if (processed == default) if (processed == default)
{ {
yield break; yield break;
} }
var (search, incompleteName) = processed; var (querySearch, incompleteName) = processed;
var isRecursive = RecursiveSearch(incompleteName); var isRecursive = RecursiveSearch(incompleteName);
if (isRecursive) if (isRecursive)
@@ -111,22 +109,22 @@ namespace Microsoft.Plugin.Folder.Sources
} }
else else
{ {
incompleteName = "*" + incompleteName.Substring(1); incompleteName = string.Concat("*", incompleteName.AsSpan(1));
} }
} }
yield return new CreateOpenCurrentFolderResult(search); yield return new CreateOpenCurrentFolderResult(querySearch);
// Note: Take 1000 is so that you don't search the whole system before you discard // Note: Take 1000 is so that you don't search the whole system before you discard
var lookup = _queryFileSystemInfo.MatchFileSystemInfo(search, incompleteName, isRecursive) var lookup = _queryFileSystemInfo.MatchFileSystemInfo(querySearch, incompleteName, isRecursive)
.Take(1000) .Take(1000)
.ToLookup(r => r.Type); .ToLookup(r => r.Type);
var folderList = lookup[DisplayType.Directory].ToImmutableArray(); var folderList = lookup[DisplayType.Directory].ToImmutableArray();
var fileList = lookup[DisplayType.File].ToImmutableArray(); var fileList = lookup[DisplayType.File].ToImmutableArray();
var fileSystemResult = GenerateFolderResults(search, folderList) var fileSystemResult = GenerateFolderResults(querySearch, folderList)
.Concat<IItemResult>(GenerateFileResults(search, fileList)) .Concat<IItemResult>(GenerateFileResults(querySearch, fileList))
.ToImmutableArray(); .ToImmutableArray();
foreach (var result in fileSystemResult) foreach (var result in fileSystemResult)

View File

@@ -15,14 +15,14 @@ namespace Microsoft.Plugin.Folder.Sources
{ {
public class ShellAction : IShellAction public class ShellAction : IShellAction
{ {
public bool Execute(string path, IPublicAPI contextApi) public bool Execute(string sanitizedPath, IPublicAPI contextApi)
{ {
if (contextApi == null) if (contextApi == null)
{ {
throw new ArgumentNullException(nameof(contextApi)); throw new ArgumentNullException(nameof(contextApi));
} }
return OpenFileOrFolder(path, contextApi); return OpenFileOrFolder(sanitizedPath, contextApi);
} }
public bool ExecuteSanitized(string search, IPublicAPI contextApi) public bool ExecuteSanitized(string search, IPublicAPI contextApi)