From 1b9afcd0c6bde28b1a2f8fccc18ea8846ccde7f3 Mon Sep 17 00:00:00 2001 From: Alexa <53471801+Alexa-RR@users.noreply.github.com> Date: Mon, 15 Jun 2026 13:04:45 +0300 Subject: [PATCH] Harden December route cases --- tools/DorkNet.ApiRouteCoverage/Program.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tools/DorkNet.ApiRouteCoverage/Program.cs b/tools/DorkNet.ApiRouteCoverage/Program.cs index 154ba34..5710454 100644 --- a/tools/DorkNet.ApiRouteCoverage/Program.cs +++ b/tools/DorkNet.ApiRouteCoverage/Program.cs @@ -5,6 +5,10 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Routing; var serverAssembly = LoadServerAssembly(args); +var serverAssemblyWriteTime = File.GetLastWriteTimeUtc(serverAssembly.Location); +Console.WriteLine($"Using server assembly: {serverAssembly.Location}"); +Console.WriteLine($"Server assembly timestamp (UTC): {serverAssemblyWriteTime:O}"); + var routes = DiscoverRoutes(serverAssembly).OrderBy(r => r.Method).ThenBy(r => r.Template).ToArray(); var failures = new List(); @@ -51,15 +55,23 @@ static Assembly LoadServerAssembly(string[] args) Path.Combine(repositoryRoot, "DorkNet.Server", "bin", "Release", "net9.0", "DorkNet.Server.dll") }; - var serverAssemblyPath = candidates.FirstOrDefault(File.Exists); - if (serverAssemblyPath is null) + var existingCandidates = candidates.Where(File.Exists).ToArray(); + if (existingCandidates.Length == 0) { throw new FileNotFoundException( "Could not find a built DorkNet.Server assembly. Build DorkNet.Server first or pass the DLL path as the first argument.", string.Join(Environment.NewLine, candidates)); } - return LoadAssemblyFromPath(serverAssemblyPath); + if (existingCandidates.Length > 1) + { + throw new InvalidOperationException( + "Multiple DorkNet.Server assemblies were found. Pass the DLL path as the first argument so route coverage validates the intended build." + + Environment.NewLine + + string.Join(Environment.NewLine, existingCandidates)); + } + + return LoadAssemblyFromPath(existingCandidates[0]); } static Assembly LoadAssemblyFromPath(string assemblyPath)