From 328cf7bf3ce964260fef181fcafc98e9c528a7f5 Mon Sep 17 00:00:00 2001 From: Marcello Lamonaca Date: Sun, 10 Nov 2024 10:53:23 +0100 Subject: [PATCH] make lambdas static where possible --- src/Program.cs | 5 +---- src/ScriptFinder.cs | 14 +++++++------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/Program.cs b/src/Program.cs index e57668c..836c56b 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -2,9 +2,6 @@ using ScriptLauncher; using Spectre.Console.Cli; var app = new CommandApp(); -app.Configure(x => -{ - x.SetApplicationName("scrl"); -}); +app.Configure(static x => x.SetApplicationName("scrl")); return app.Run(args); diff --git a/src/ScriptFinder.cs b/src/ScriptFinder.cs index 618701d..e7040f4 100644 --- a/src/ScriptFinder.cs +++ b/src/ScriptFinder.cs @@ -10,7 +10,7 @@ internal readonly struct ScriptFinder public ScriptFinder(IEnumerable extensions, string directory, int depth) { - Extensions = extensions.ToHashSet().Select(x => $".{x.TrimStart('.')}"); + Extensions = extensions.ToHashSet().Select(static x => $".{x.TrimStart('.')}"); Depth = depth; RootDirectory = directory; @@ -28,7 +28,7 @@ internal readonly struct ScriptFinder try { var filenames = Directory.GetFiles(RootDirectory, $"*{extension}", _options); - return filenames.Select(x => new FileInfo(x)); + return filenames.Select(static x => new FileInfo(x)); } catch (UnauthorizedAccessException) { @@ -37,13 +37,13 @@ internal readonly struct ScriptFinder } public FileInfo[] GetScripts() => - Extensions.Select(GetScriptFilesWithExtension).SelectMany(x => x).ToArray(); + Extensions.Select(GetScriptFilesWithExtension).SelectMany(static x => x).ToArray(); public IDictionary GetScriptsByDirectory() => Extensions .Select(GetScriptFilesWithExtension) - .SelectMany(x => x) - .GroupBy(x => x.DirectoryName!) - .OrderBy(x => x.Key) - .ToDictionary(x => new DirectoryInfo(x.Key), x => x.ToArray()); + .SelectMany(static x => x) + .GroupBy(static x => x.DirectoryName!) + .OrderBy(static x => x.Key) + .ToDictionary(static x => new DirectoryInfo(x.Key), static x => x.ToArray()); }