diff --git a/.vscode/launch.json b/.vscode/launch.json index ecf6947..a819ec8 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -11,6 +11,12 @@ "preLaunchTask": "build", "program": "${workspaceFolder}/bin/Debug/net8.0/win-x64/File-Folder-Helper.dll", "args": [ + "s", + "X", + "L:/DevOps/Mesa_FI/MesaFabApproval", + "Day-Helper-2024-01-08", + "L:/DevOps/Mesa_FI/MesaFabApproval/Fab2ApprovalSystem/Controllers", + "true", "s", "X", "D:/5-Other-Small/Kanban-mestsa003/ART-SPS/2024/PI4/Sprint-4.1/126448-User-Story/.files/638675719896500885", diff --git a/ADO2024/PI1/Helper-2024-01-08.cs b/ADO2024/PI1/Helper-2024-01-08.cs index 21ee9c2..8a5ed66 100644 --- a/ADO2024/PI1/Helper-2024-01-08.cs +++ b/ADO2024/PI1/Helper-2024-01-08.cs @@ -277,12 +277,18 @@ internal static partial class Helper20240108 return result; } - private static bool SortFile(ILogger logger, string cSharpFile, string[] lines) + private static bool SortFile(ILogger logger, bool logOnly, string cSharpFile, string[] lines) { bool result; ReadOnlyCollection methods = GetMethods(cSharpFile, logger, lines); if (methods.Count == 0) result = false; + else if (logOnly) + { + foreach (Method method in methods.OrderBy(l => l.Name)) + logger.LogInformation("{cSharpFile} - {Name} has {lines} line(s)", cSharpFile, method.Name, (method.EndLine - method.StartLine).ToString("000000")); + result = false; + } else result = WriteAllLines(cSharpFile, lines, methods); return result; @@ -295,11 +301,12 @@ internal static partial class Helper20240108 string[] lines; bool usePathCombine = true; long ticks = DateTime.Now.Ticks; + bool logOnly = bool.Parse(args[3]); logger.LogInformation("{ticks}", ticks); string directory = Path.GetFullPath(args[2]); string repositoryDirectory = Path.GetFullPath(args[0]); string[] cSharpFiles = Directory.GetFiles(directory, "*.cs", SearchOption.AllDirectories); - ReadOnlyCollection gitOthersModifiedAndDeletedExcludingStandardFiles = Helpers.HelperGit.GetOthersModifiedAndDeletedExcludingStandardFiles(repositoryDirectory, usePathCombine, cancellationToken); + ReadOnlyCollection gitOthersModifiedAndDeletedExcludingStandardFiles = logOnly ? new(cSharpFiles) : Helpers.HelperGit.GetOthersModifiedAndDeletedExcludingStandardFiles(repositoryDirectory, usePathCombine, cancellationToken); for (int i = 0; i < 10; i++) { foreach (string cSharpFile in cSharpFiles) @@ -307,11 +314,11 @@ internal static partial class Helper20240108 if (!gitOthersModifiedAndDeletedExcludingStandardFiles.Contains(cSharpFile)) continue; lines = File.ReadAllLines(cSharpFile); - check = SortFile(logger, cSharpFile, lines); + check = SortFile(logger, logOnly, cSharpFile, lines); if (check && !result) result = true; } - if (!result) + if (logOnly || !result) break; } } diff --git a/File-Folder-Helper.csproj b/File-Folder-Helper.csproj index fcde3a9..cae3ae1 100644 --- a/File-Folder-Helper.csproj +++ b/File-Folder-Helper.csproj @@ -17,7 +17,7 @@ - +