This commit is contained in:
Mike Phares 2024-11-22 17:51:40 -07:00
parent 446b5587be
commit ecc1cf3a62
3 changed files with 18 additions and 5 deletions

6
.vscode/launch.json vendored
View File

@ -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",

View File

@ -277,12 +277,18 @@ internal static partial class Helper20240108
return result;
}
private static bool SortFile(ILogger<Worker> logger, string cSharpFile, string[] lines)
private static bool SortFile(ILogger<Worker> logger, bool logOnly, string cSharpFile, string[] lines)
{
bool result;
ReadOnlyCollection<Method> 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<string> gitOthersModifiedAndDeletedExcludingStandardFiles = Helpers.HelperGit.GetOthersModifiedAndDeletedExcludingStandardFiles(repositoryDirectory, usePathCombine, cancellationToken);
ReadOnlyCollection<string> 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;
}
}

View File

@ -17,7 +17,7 @@
<PackageReference Include="MetadataExtractor" Version="2.8.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
<PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler" Version="8.0.10" />
<PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler" Version="8.0.11" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
<PackageReference Include="TextCopy" Version="6.2.1" />
<PackageReference Include="WindowsShortcutFactory" Version="1.2.0" />