make lambdas static where possible

This commit is contained in:
Marcello 2024-11-10 10:53:23 +01:00
parent e09cfbffdd
commit 328cf7bf3c
Signed by: m-lamonaca
SSH key fingerprint: SHA256:8db8uii6Gweq7TbKixFBioW2T8CbgtyFETyYL3cr3zk
2 changed files with 8 additions and 11 deletions

View file

@ -2,9 +2,6 @@ using ScriptLauncher;
using Spectre.Console.Cli; using Spectre.Console.Cli;
var app = new CommandApp<RootCommand>(); var app = new CommandApp<RootCommand>();
app.Configure(x => app.Configure(static x => x.SetApplicationName("scrl"));
{
x.SetApplicationName("scrl");
});
return app.Run(args); return app.Run(args);

View file

@ -10,7 +10,7 @@ internal readonly struct ScriptFinder
public ScriptFinder(IEnumerable<string> extensions, string directory, int depth) public ScriptFinder(IEnumerable<string> extensions, string directory, int depth)
{ {
Extensions = extensions.ToHashSet().Select(x => $".{x.TrimStart('.')}"); Extensions = extensions.ToHashSet().Select(static x => $".{x.TrimStart('.')}");
Depth = depth; Depth = depth;
RootDirectory = directory; RootDirectory = directory;
@ -28,7 +28,7 @@ internal readonly struct ScriptFinder
try try
{ {
var filenames = Directory.GetFiles(RootDirectory, $"*{extension}", _options); var filenames = Directory.GetFiles(RootDirectory, $"*{extension}", _options);
return filenames.Select(x => new FileInfo(x)); return filenames.Select(static x => new FileInfo(x));
} }
catch (UnauthorizedAccessException) catch (UnauthorizedAccessException)
{ {
@ -37,13 +37,13 @@ internal readonly struct ScriptFinder
} }
public FileInfo[] GetScripts() => public FileInfo[] GetScripts() =>
Extensions.Select(GetScriptFilesWithExtension).SelectMany(x => x).ToArray(); Extensions.Select(GetScriptFilesWithExtension).SelectMany(static x => x).ToArray();
public IDictionary<DirectoryInfo, FileInfo[]> GetScriptsByDirectory() => public IDictionary<DirectoryInfo, FileInfo[]> GetScriptsByDirectory() =>
Extensions Extensions
.Select(GetScriptFilesWithExtension) .Select(GetScriptFilesWithExtension)
.SelectMany(x => x) .SelectMany(static x => x)
.GroupBy(x => x.DirectoryName!) .GroupBy(static x => x.DirectoryName!)
.OrderBy(x => x.Key) .OrderBy(static x => x.Key)
.ToDictionary(x => new DirectoryInfo(x.Key), x => x.ToArray()); .ToDictionary(static x => new DirectoryInfo(x.Key), static x => x.ToArray());
} }