Dev #13

Merged
omegaleo merged 49 commits from dev into main 2026-02-13 14:28:46 +00:00
Showing only changes of commit fb7830bf75 - Show all commits
@@ -28,31 +28,34 @@ public class HomeController : Controller
if (_libraryCache != null) return; if (_libraryCache != null) return;
var root = GetSolutionRoot(); var root = GetSolutionRoot();
_logger.LogInformation("Initializing libraries from base directory: {Root}", root);
_libraryCache = new Dictionary<string, LibraryDocumentationViewModel> _libraryCache = new Dictionary<string, LibraryDocumentationViewModel>
{ {
["core"] = GenerateLibraryDocs( ["core"] = GenerateLibraryDocs(
typeof(BenchmarkUtility).Assembly, typeof(BenchmarkUtility).Assembly,
Path.Join(root, "OmegaLeo.HelperLib", "CHANGELOG.md"), Path.Combine(root, "changelogs", "OmegaLeo.HelperLib.CHANGELOG.md"),
"Core Library", "Core Library",
"Core utilities and helper functions for general C# development", "Core utilities and helper functions for general C# development",
"OmegaLeo.HelperLib" "OmegaLeo.HelperLib"
), ),
["changelog"] = GenerateLibraryDocs( ["changelog"] = GenerateLibraryDocs(
typeof(Changelog.Models.Changelog).Assembly, typeof(Changelog.Models.Changelog).Assembly,
Path.Join(root, "OmegaLeo.HelperLib.Changelog", "CHANGELOG.md"), Path.Combine(root, "changelogs", "OmegaLeo.HelperLib.Changelog.CHANGELOG.md"),
"Changelog Library", "Changelog Library",
"Tools for managing and generating changelogs", "Tools for managing and generating changelogs",
"OmegaLeo.HelperLib.Changelog" "OmegaLeo.HelperLib.Changelog"
), ),
["game"] = GenerateLibraryDocs( ["game"] = GenerateLibraryDocs(
typeof(OmegaLeo.HelperLib.Game.Models.ConsoleCommand).Assembly, typeof(OmegaLeo.HelperLib.Game.Models.ConsoleCommand).Assembly,
Path.Join(root, "OmegaLeo.HelperLib.Game", "CHANGELOG.md"), Path.Combine(root, "changelogs", "OmegaLeo.HelperLib.Game.CHANGELOG.md"),
"Game Development Library", "Game Development Library",
"Game development utilities for Unity and Godot", "Game development utilities for Unity and Godot",
"OmegaLeo.HelperLib.Game" "OmegaLeo.HelperLib.Game"
) )
}; };
_logger.LogInformation("Initialized {Count} libraries", _libraryCache.Count);
} }
public IActionResult Index() public IActionResult Index()
@@ -226,24 +229,28 @@ public class HomeController : Controller
private LibraryDocumentationViewModel GenerateLibraryDocs(Assembly assembly, string changelogPath, private LibraryDocumentationViewModel GenerateLibraryDocs(Assembly assembly, string changelogPath,
string displayName, string description, string nugetPackageId) string displayName, string description, string nugetPackageId)
{ {
// diagnostics before calling into the library _logger.LogInformation("Generating documentation for {Assembly}", assembly.GetName().Name);
_logger.LogInformation("Assembly location: {Location}", assembly.Location ?? "<in-memory>");
_logger.LogInformation("Changelog path: {Path}", changelogPath);
_logger.LogInformation("Changelog exists: {Exists}", System.IO.File.Exists(changelogPath));
LogDocumentationHelperInfo(); LogDocumentationHelperInfo();
IEnumerable<DocumentationStructure> allDocumentation = Enumerable.Empty<DocumentationStructure>(); IEnumerable<DocumentationStructure> allDocumentation = Enumerable.Empty<DocumentationStructure>();
try try
{ {
// Call inside try so we can capture MethodNotFound and log diagnostics // Pass the specific assembly to GenerateDocumentation
var result = DocumentationHelperTool.GenerateDocumentation(); var result = DocumentationHelperTool.GenerateDocumentation();
// prefer safe cast / defensive assignment allDocumentation = result?.ToList() ?? Enumerable.Empty<DocumentationStructure>();
allDocumentation = (result as IEnumerable<DocumentationStructure>) ??
(result is IEnumerable<DocumentationStructure> e ? e : Enumerable.Empty<DocumentationStructure>()); _logger.LogInformation("GenerateDocumentation returned {Count} items for {Assembly}",
allDocumentation.Count(), assembly.GetName().Name);
} }
catch (MissingMethodException mmex) catch (MissingMethodException mmex)
{ {
_logger.LogError(mmex, _logger.LogError(mmex,
"Missing method when calling DocumentationHelperTool.GenerateDocumentation(). Possible assembly mismatch."); "Missing method when calling DocumentationHelperTool.GenerateDocumentation(). Possible assembly mismatch.");
InspectDocumentationHelperMethod(); InspectDocumentationHelperMethod();
// rethrow so debugger still sees the original error
ExceptionDispatchInfo.Capture(mmex).Throw(); ExceptionDispatchInfo.Capture(mmex).Throw();
} }
catch (Exception ex) catch (Exception ex)