Fixed DocumentationHelper package dependencies
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NetFlow.DocumentationHelper.Library" Version="1.1.2" />
|
||||
<PackageReference Include="NetFlow.DocumentationHelper.Library" Version="1.1.3" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -13,4 +13,8 @@
|
||||
<ProjectReference Include="..\OmegaLeo.HelperLib\OmegaLeo.HelperLib.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NetFlow.DocumentationHelper.Library" Version="1.1.3" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -13,4 +13,8 @@
|
||||
<ProjectReference Include="..\OmegaLeo.HelperLib\OmegaLeo.HelperLib.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NetFlow.DocumentationHelper.Library" Version="1.1.3" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
// File: `OmegaLeo.HelperLib.Web/Controllers/HomeController.cs`
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Runtime.ExceptionServices;
|
||||
using GameDevLibrary.Helpers;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NetFlow.DocumentationHelper.Library.Helpers;
|
||||
using NetFlow.DocumentationHelper.Library.Models;
|
||||
using OmegaLeo.HelperLib.Changelog.Tools;
|
||||
using OmegaLeo.HelperLib.Web.Models;
|
||||
|
||||
@@ -76,17 +79,209 @@ public class HomeController : Controller
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
}
|
||||
|
||||
private LibraryDocumentationViewModel GenerateLibraryDocs(Assembly assembly, string changelogPath, string displayName, string description, string nugetPackageId)
|
||||
private void LogDocumentationHelperInfo()
|
||||
{
|
||||
try
|
||||
{
|
||||
var allDocumentation = DocumentationHelperTool.GenerateDocumentation();
|
||||
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
var target = assemblies.FirstOrDefault(a =>
|
||||
a.GetName().Name.Equals("NetFlow.DocumentationHelper.Library", StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
_logger.LogWarning("NetFlow.DocumentationHelper.Library not loaded. Loaded assemblies ({Count}):",
|
||||
assemblies.Length);
|
||||
foreach (var a in assemblies.OrderBy(a => a.GetName().Name))
|
||||
{
|
||||
_logger.LogInformation(" {Name} {Version} => {Location}", a.GetName().Name, a.GetName().Version,
|
||||
SafeLocation(a));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Found {Name} {Version} at {Location}", target.GetName().Name,
|
||||
target.GetName().Version, SafeLocation(target));
|
||||
|
||||
Type attrType = null;
|
||||
try
|
||||
{
|
||||
attrType = target.GetType("NetFlow.DocumentationHelper.Library.Attributes.DocumentationAttribute",
|
||||
false, true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Failed to GetType for DocumentationAttribute in {Assembly}",
|
||||
target.GetName().Name);
|
||||
}
|
||||
|
||||
if (attrType == null)
|
||||
{
|
||||
_logger.LogWarning("Type 'DocumentationAttribute' not found in {Assembly}.", target.GetName().Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
var ctors = attrType.GetConstructors(BindingFlags.Public | BindingFlags.Instance |
|
||||
BindingFlags.NonPublic);
|
||||
if (!ctors.Any())
|
||||
_logger.LogWarning("No constructors found on DocumentationAttribute in {Assembly}.",
|
||||
target.GetName().Name);
|
||||
foreach (var ctor in ctors)
|
||||
{
|
||||
var sig = string.Join(", ", ctor.GetParameters().Select(p => p.ParameterType.Name + " " + p.Name));
|
||||
_logger.LogInformation("DocumentationAttribute ctor: ({Signature})", sig);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Failed to log DocumentationHelper assembly info.");
|
||||
}
|
||||
|
||||
static string SafeLocation(Assembly a)
|
||||
{
|
||||
try
|
||||
{
|
||||
return string.IsNullOrEmpty(a.Location) ? "<in-memory>" : a.Location;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "<unknown>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void InspectDocumentationHelperMethod()
|
||||
{
|
||||
try
|
||||
{
|
||||
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
Type helperType = null;
|
||||
foreach (var asm in assemblies)
|
||||
{
|
||||
try
|
||||
{
|
||||
var t = asm.GetTypes().FirstOrDefault(tt =>
|
||||
tt.Name.Equals("DocumentationHelperTool", StringComparison.OrdinalIgnoreCase)
|
||||
|| tt.FullName?.EndsWith(".DocumentationHelperTool") == true);
|
||||
if (t != null)
|
||||
{
|
||||
helperType = t;
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (ReflectionTypeLoadException rtlex)
|
||||
{
|
||||
_logger.LogDebug(rtlex, "Could not enumerate types in {Assembly}", asm.GetName().Name);
|
||||
foreach (var loaderEx in rtlex.LoaderExceptions ?? Array.Empty<Exception>())
|
||||
_logger.LogDebug(loaderEx, "Loader exception for {Assembly}", asm.GetName().Name);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogDebug(ex, "Failed enumerating types in {Assembly}", asm.GetName().Name);
|
||||
}
|
||||
}
|
||||
|
||||
if (helperType == null)
|
||||
{
|
||||
_logger.LogWarning("DocumentationHelperTool type not found in loaded assemblies.");
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("DocumentationHelperTool found: {Type} in {Assembly} ({Location})",
|
||||
helperType.FullName, helperType.Assembly.GetName().Name, SafeLocation(helperType.Assembly));
|
||||
|
||||
var method = helperType.GetMethod("GenerateDocumentation",
|
||||
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
|
||||
if (method == null)
|
||||
{
|
||||
_logger.LogWarning("GenerateDocumentation method not found on {Type}.", helperType.FullName);
|
||||
}
|
||||
else
|
||||
{
|
||||
var parameters = string.Join(", ",
|
||||
method.GetParameters().Select(p => p.ParameterType.Name + " " + p.Name));
|
||||
_logger.LogInformation("Method: {Name} ({Parameters}) -> {ReturnType}", method.Name, parameters,
|
||||
method.ReturnType.FullName);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Failed to inspect DocumentationHelperTool type/method.");
|
||||
}
|
||||
|
||||
static string SafeLocation(Assembly a)
|
||||
{
|
||||
try
|
||||
{
|
||||
return string.IsNullOrEmpty(a.Location) ? "<in-memory>" : a.Location;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "<unknown>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private LibraryDocumentationViewModel GenerateLibraryDocs(Assembly assembly, string changelogPath,
|
||||
string displayName, string description, string nugetPackageId)
|
||||
{
|
||||
// diagnostics before calling into the library
|
||||
LogDocumentationHelperInfo();
|
||||
|
||||
IEnumerable<DocumentationStructure> allDocumentation = Enumerable.Empty<DocumentationStructure>();
|
||||
try
|
||||
{
|
||||
// Call inside try so we can capture MethodNotFound and log diagnostics
|
||||
var result = DocumentationHelperTool.GenerateDocumentation();
|
||||
// prefer safe cast / defensive assignment
|
||||
allDocumentation = (result as IEnumerable<DocumentationStructure>) ??
|
||||
(result is IEnumerable<DocumentationStructure> e ? e : Enumerable.Empty<DocumentationStructure>());
|
||||
}
|
||||
catch (MissingMethodException mmex)
|
||||
{
|
||||
_logger.LogError(mmex,
|
||||
"Missing method when calling DocumentationHelperTool.GenerateDocumentation(). Possible assembly mismatch.");
|
||||
InspectDocumentationHelperMethod();
|
||||
// rethrow so debugger still sees the original error
|
||||
ExceptionDispatchInfo.Capture(mmex).Throw();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "DocumentationHelperTool.GenerateDocumentation threw an exception.");
|
||||
InspectDocumentationHelperMethod();
|
||||
throw;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var assemblyName = assembly.GetName().Name;
|
||||
|
||||
var filteredDocumentation = allDocumentation
|
||||
.Where(d => d.AssemblyName.Equals(assemblyName, StringComparison.OrdinalIgnoreCase))
|
||||
.OrderBy(d => d.ClassName)
|
||||
.ToList();
|
||||
List<DocumentationStructure> filteredDocumentation = allDocumentation
|
||||
.Where<DocumentationStructure>(d =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var prop = d.GetType().GetProperty("AssemblyName");
|
||||
return prop != null && string.Equals(prop.GetValue(d)?.ToString(), assemblyName,
|
||||
StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.OrderBy<DocumentationStructure, string>(d =>
|
||||
{
|
||||
try
|
||||
{
|
||||
return d.GetType().GetProperty("ClassName")?.GetValue(d)?.ToString() ?? "";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}).ToList<DocumentationStructure>();
|
||||
|
||||
string changelogMarkdown = "";
|
||||
if (System.IO.File.Exists(changelogPath))
|
||||
@@ -94,7 +289,8 @@ public class HomeController : Controller
|
||||
changelogMarkdown = ChangelogTool.GetMarkdown(assembly);
|
||||
}
|
||||
|
||||
string version = assembly.GetCustomAttribute<System.Reflection.AssemblyInformationalVersionAttribute>()?.InformationalVersion
|
||||
string version = assembly.GetCustomAttribute<System.Reflection.AssemblyInformationalVersionAttribute>()
|
||||
?.InformationalVersion
|
||||
?? assembly.GetName().Version?.ToString()
|
||||
?? "1.0.0";
|
||||
|
||||
@@ -115,7 +311,7 @@ public class HomeController : Controller
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine($"Failed to Generate Library Docs for {assembly.FullName}: {e.Message}");
|
||||
_logger.LogError(e, "Failed to process documentation for {Assembly}", assembly.FullName);
|
||||
return new LibraryDocumentationViewModel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,10 @@ var builder = WebApplication.CreateBuilder(args);
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllersWithViews();
|
||||
|
||||
// Configure logging
|
||||
builder.Logging.ClearProviders();
|
||||
builder.Logging.AddConsole();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADocumentationDescription_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003Fhome_003Fomegaleo_003F_002Econfig_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fe7ce68ea4d3540e4bc8ef1bd962ca30b3a00_003F46_003F1f9d3ace_003FDocumentationDescription_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADocumentationHelperTool_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003Fhome_003Fomegaleo_003F_002Econfig_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F165936b93b8c4f33b6ee955456d3fd6a3c00_003F08_003F718f7e37_003FDocumentationHelperTool_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AExceptionDispatchInfo_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003Fhome_003Fomegaleo_003F_002Econfig_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FSourcesCache_003Fbf9021a960b74107a7e141aa06bc9d8a0a53c929178c2fb95b1597be8af8dc_003FExceptionDispatchInfo_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AMonitor_002ECoreCLR_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003Fhome_003Fomegaleo_003F_002Econfig_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FSourcesCache_003F9ee76fb4aded5e9da6e66cc2dcb127fac08d3ec5ac84fc6db9d4ee1d2e38_003FMonitor_002ECoreCLR_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARuntimeHandles_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003Fhome_003Fomegaleo_003F_002Econfig_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FSourcesCache_003F42d5e9d0d54843a23887036cb9c33c9ce48bbc6f7c35ed3759154a95456c796_003FRuntimeHandles_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASafeFileHandle_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003Fhome_003Fomegaleo_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fc21672d0d37542808f219d7d1f059dc1b2e000_003Faf_003Fbed3a9b4_003FSafeFileHandle_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThrowHelper_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003Fhome_003Fomegaleo_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fc61cc76f205b4535a5b4f40700c07900b2d200_003Fe5_003F6b3ec67e_003FThrowHelper_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATreeChanges_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003Fhome_003Fomegaleo_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F7478b0ce6362feb345e793626f5c504bd9d7ffeb748226521658c85fc4e29_003FTreeChanges_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
|
||||
Reference in New Issue
Block a user