diff --git a/.github/instructions/default.instructions.md b/.github/instructions/default.instructions.md index 53f0d258..a7170412 100644 --- a/.github/instructions/default.instructions.md +++ b/.github/instructions/default.instructions.md @@ -6,7 +6,7 @@ RefDocGen is a **reference documentation generator for .NET**, installed as a .N ## Tech Stack -- **.NET 8** (target framework: `net8.0`) +- **.NET 10** (target framework: `net10.0`) - **C#** with nullable reference types enabled and implicit usings - **Razor SDK** (`Microsoft.NET.Sdk.Razor`) — used for server-side HTML rendering via `HtmlRenderer`, not as a web app - **Key libraries**: AngleSharp (HTML parsing), CommandLineParser (CLI), Markdig (Markdown), YamlDotNet (YAML config), Serilog (logging), Microsoft.Build (MSBuild integration) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index e7a65683..f4205a4e 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -31,7 +31,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 8.0.x + dotnet-version: 10.0.x - name: Restore dependencies run: dotnet restore diff --git a/README.md b/README.md index eead485b..f5624127 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Default UI: ## Installation Prerequisites: -- .NET 8 (or higher) +- .NET 10 (or higher) Install as a .NET global tool from [NuGet](https://www.nuget.org/packages/RefDocGen): diff --git a/docs/index.md b/docs/index.md index 3f3e4563..7a14a9de 100644 --- a/docs/index.md +++ b/docs/index.md @@ -22,7 +22,7 @@ RefDocGen is a reference documentation generator for .NET. ## Installation Prerequisites: -- .NET 8 (or higher) +- .NET 10 (or higher) Install as a .NET global tool from [NuGet](https://www.nuget.org/packages/RefDocGen): diff --git a/src/RefDocGen/AssemblyAnalysis/AssemblyTypeExtractor.cs b/src/RefDocGen/AssemblyAnalysis/AssemblyTypeExtractor.cs index 763bb57c..1493e5f7 100644 --- a/src/RefDocGen/AssemblyAnalysis/AssemblyTypeExtractor.cs +++ b/src/RefDocGen/AssemblyAnalysis/AssemblyTypeExtractor.cs @@ -8,6 +8,7 @@ using RefDocGen.CodeElements.Types.Concrete; using RefDocGen.CodeElements.Types.Concrete.Delegate; using RefDocGen.CodeElements.Types.Concrete.Enum; +using RefDocGen.Tools.Logging; using RefDocGen.Tools.Exceptions; using System.Reflection; @@ -135,11 +136,11 @@ internal TypeRegistry GetDeclaredTypes() types.AddRange(assembly.GetTypes()); includedAssemblies.Add(assemblyPath); - logger.LogInformation("Assembly {Name} loaded", assemblyPath); + RefDocGenLogMessages.LogAssemblyLoaded(logger, assemblyPath); } else { - logger.LogInformation("Assembly {Name} excluded", assemblyPath); + RefDocGenLogMessages.LogAssemblyExcluded(logger, assemblyPath); } } diff --git a/src/RefDocGen/CodeElements/Members/Concrete/MethodData.cs b/src/RefDocGen/CodeElements/Members/Concrete/MethodData.cs index 2cdaa3e8..63260ee3 100644 --- a/src/RefDocGen/CodeElements/Members/Concrete/MethodData.cs +++ b/src/RefDocGen/CodeElements/Members/Concrete/MethodData.cs @@ -92,7 +92,7 @@ internal MethodData( public bool IsFinal => MethodInfo.IsFinal; /// - public bool IsAsync => MethodInfo.GetCustomAttribute(typeof(AsyncStateMachineAttribute)) != null; + public bool IsAsync => MethodInfo.GetCustomAttribute() != null; /// public bool IsSealed => OverridesAnotherMember && IsFinal; diff --git a/src/RefDocGen/CodeElements/Members/Concrete/ParameterData.cs b/src/RefDocGen/CodeElements/Members/Concrete/ParameterData.cs index d05bea3b..ef0d0166 100644 --- a/src/RefDocGen/CodeElements/Members/Concrete/ParameterData.cs +++ b/src/RefDocGen/CodeElements/Members/Concrete/ParameterData.cs @@ -46,7 +46,7 @@ public ParameterData( public ITypeNameData Type { get; } /// - public bool IsParamsCollection => ParameterInfo.GetCustomAttribute(typeof(ParamArrayAttribute)) != null; + public bool IsParamsCollection => ParameterInfo.GetCustomAttribute() != null; /// public bool IsInput => ParameterInfo.IsIn; diff --git a/src/RefDocGen/DocExtraction/DocCommentExtractor.cs b/src/RefDocGen/DocExtraction/DocCommentExtractor.cs index ce5dfa9e..1f9873a8 100644 --- a/src/RefDocGen/DocExtraction/DocCommentExtractor.cs +++ b/src/RefDocGen/DocExtraction/DocCommentExtractor.cs @@ -7,6 +7,7 @@ using RefDocGen.DocExtraction.Handlers.Types; using RefDocGen.DocExtraction.InheritDoc; using RefDocGen.DocExtraction.Tools; +using RefDocGen.Tools.Logging; using RefDocGen.Tools.Xml; using System.Xml.Linq; @@ -133,7 +134,7 @@ internal void AddComments() { // load the document (preserve the whitespace, as the documentation is to be converted into HTML) xmlDocument = XDocument.Load(xmlPath, LoadOptions.PreserveWhitespace); - logger.LogInformation("XML documentation file {Name} loaded", xmlPath); + RefDocGenLogMessages.LogXmlDocFileLoaded(logger, xmlPath); } catch (FileNotFoundException) { diff --git a/src/RefDocGen/Program.cs b/src/RefDocGen/Program.cs index 90577de9..f3a61b71 100644 --- a/src/RefDocGen/Program.cs +++ b/src/RefDocGen/Program.cs @@ -10,6 +10,7 @@ using RefDocGen.TemplateProcessors.Default; using RefDocGen.TemplateProcessors.Shared.Languages; using RefDocGen.Tools.Exceptions; +using RefDocGen.Tools.Logging; using Serilog; using Serilog.Events; using System.Globalization; @@ -143,7 +144,7 @@ private static async Task Run(IProgramConfiguration config) if (config.SaveConfig) // save the configuration { YamlFileConfiguration.SaveToFile(config); - logger.LogInformation("Configuration saved into {File} file", YamlFileConfiguration.FileName); + RefDocGenLogMessages.LogConfigurationSaved(logger, YamlFileConfiguration.FileName); } Console.WriteLine($"Documentation generated in the '{config.OutputDir}' folder"); diff --git a/src/RefDocGen/RefDocGen.csproj b/src/RefDocGen/RefDocGen.csproj index 5c98caa0..7c960cbc 100644 --- a/src/RefDocGen/RefDocGen.csproj +++ b/src/RefDocGen/RefDocGen.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net10.0 enable enable recommended @@ -12,7 +12,7 @@ true refdocgen ./nupkg - 1.0.6 + 1.1.0 Vojtěch Lengál RefDocGen Reference Documentation Generator for .NET @@ -24,22 +24,22 @@ - + - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - - + + - - - + + + diff --git a/src/RefDocGen/TemplateProcessors/Shared/DocComments/Html/DocCommentTransformer.cs b/src/RefDocGen/TemplateProcessors/Shared/DocComments/Html/DocCommentTransformer.cs index c57dbeeb..e1b9c3c3 100644 --- a/src/RefDocGen/TemplateProcessors/Shared/DocComments/Html/DocCommentTransformer.cs +++ b/src/RefDocGen/TemplateProcessors/Shared/DocComments/Html/DocCommentTransformer.cs @@ -32,9 +32,6 @@ internal class DocCommentTransformer : IDocCommentTransformer /// private readonly IDocCommentHtmlConfiguration htmlConfiguration; - /// - private TypeUrlResolver? typeUrlResolver; - /// private ITypeRegistry? typeRegistry; @@ -89,8 +86,8 @@ public ITypeRegistry TypeRegistry /// private TypeUrlResolver TypeUrlResolver { - get => typeUrlResolver ?? throw new InvalidOperationException("Type registry not provided"); - set => typeUrlResolver = value; + get => field ?? throw new InvalidOperationException("Type registry not provided"); + set; } /// diff --git a/src/RefDocGen/TemplateProcessors/Shared/DocVersioning/DocVersionManager.cs b/src/RefDocGen/TemplateProcessors/Shared/DocVersioning/DocVersionManager.cs index 6ee1620a..ef42eaee 100644 --- a/src/RefDocGen/TemplateProcessors/Shared/DocVersioning/DocVersionManager.cs +++ b/src/RefDocGen/TemplateProcessors/Shared/DocVersioning/DocVersionManager.cs @@ -135,10 +135,7 @@ private void UpdateOlderPageVersions(string pagePath) var versionList = document.GetElementById(versionListElementId); - if (versionList is not null) - { - versionList.InnerHtml = JsonSerializer.Serialize(versions); // add the current version to the 'Version list' element - } + _ = (versionList?.InnerHtml = JsonSerializer.Serialize(versions)); // add the current version to the 'Version list' element File.WriteAllText(olderVersionFile, document.ToHtml()); // Write the updated HTML } diff --git a/src/RefDocGen/TemplateProcessors/Shared/RazorTemplateProcessor.cs b/src/RefDocGen/TemplateProcessors/Shared/RazorTemplateProcessor.cs index bf01a515..dd70f398 100644 --- a/src/RefDocGen/TemplateProcessors/Shared/RazorTemplateProcessor.cs +++ b/src/RefDocGen/TemplateProcessors/Shared/RazorTemplateProcessor.cs @@ -19,6 +19,7 @@ using RefDocGen.TemplateProcessors.Shared.Tools; using RefDocGen.Tools; using RefDocGen.Tools.Exceptions; +using RefDocGen.Tools.Logging; namespace RefDocGen.TemplateProcessors.Shared; @@ -200,7 +201,10 @@ public void ProcessTemplates(ITypeRegistry typeRegistry, string outputDirectory, _ = Directory.CreateDirectory(this.outputDirectory); } - this.logger?.LogInformation("Generating documentation in {Folder} folder", this.outputDirectory); + if (this.logger is not null) + { + RefDocGenLogMessages.LogGeneratingDocumentation(this.logger, this.outputDirectory); + } CopyStaticPages(); @@ -357,11 +361,17 @@ private void CopyStaticTemplateFilesDirectory() if (staticFilesDir.Exists) { staticFilesDir.CopyTo(outputDirPath, true); - logger?.LogInformation("A directory containing static template data copied to {Directory}", outputDirPath); + if (logger is not null) + { + RefDocGenLogMessages.LogStaticTemplateDataCopied(logger, outputDirPath); + } } else { - logger?.LogInformation("No directory containing static template data found at path {Directory}", staticFilesDir); + if (logger is not null) + { + RefDocGenLogMessages.LogNoStaticTemplateDataFound(logger, staticFilesDir.FullName); + } } } @@ -430,7 +440,11 @@ private void CopyStaticPages() foreach (var page in pages) // wrap each page in the static page template, process it, and copy it into the output directory { - logger?.LogInformation("Static page {Path} found", Path.Combine(staticPagesDirectory, page.FullName)); + if (logger is not null) + { + RefDocGenLogMessages.LogStaticPageFound(logger, staticPagesDirectory, page.FullName); + } + string outputPath = Path.Combine(outputDirectory, page.PageDirectory); var paramDictionary = new Dictionary() @@ -486,7 +500,10 @@ private void ProcessTemplate(Dictionary customTempla File.WriteAllText(outputFileName, html); _ = pagesGenerated.Add(pagePath); - logger?.LogInformation("Page {Name} created", outputFileName); + if (logger is not null) + { + RefDocGenLogMessages.LogPageCreated(logger, outputFileName); + } } catch (Exception ex) // Template compilation failed -> delete the directory & throw an exception { diff --git a/src/RefDocGen/TemplateProcessors/Shared/StaticPages/StaticPageProcessor.cs b/src/RefDocGen/TemplateProcessors/Shared/StaticPages/StaticPageProcessor.cs index 52016f2e..b9d101fd 100644 --- a/src/RefDocGen/TemplateProcessors/Shared/StaticPages/StaticPageProcessor.cs +++ b/src/RefDocGen/TemplateProcessors/Shared/StaticPages/StaticPageProcessor.cs @@ -3,6 +3,7 @@ using AngleSharp.Html.Dom; using Markdig; using Microsoft.Extensions.Logging; +using RefDocGen.Tools.Logging; using RefDocGen.Tools.Exceptions; namespace RefDocGen.TemplateProcessors.Shared.StaticPages; @@ -120,7 +121,10 @@ internal void CopyNonPageFiles(string outputDirectory) } File.Copy(file.FullName, outputPath, true); - logger?.LogInformation("Static file {FilePath} copied to {OutputPath}", filePath, outputPath); + if (logger is not null) + { + RefDocGenLogMessages.LogStaticFileCopied(logger, filePath, outputPath); + } } } } diff --git a/src/RefDocGen/Tools/Logging/RefDocGenLogMessages.cs b/src/RefDocGen/Tools/Logging/RefDocGenLogMessages.cs new file mode 100644 index 00000000..6f1506f6 --- /dev/null +++ b/src/RefDocGen/Tools/Logging/RefDocGenLogMessages.cs @@ -0,0 +1,39 @@ +using Microsoft.Extensions.Logging; + +namespace RefDocGen.Tools.Logging; + +/// +/// Source-generated logging methods used across the application. +/// +internal static partial class RefDocGenLogMessages +{ + [LoggerMessage(Level = LogLevel.Information, Message = "Assembly {Name} loaded")] + internal static partial void LogAssemblyLoaded(ILogger logger, string name); + + [LoggerMessage(Level = LogLevel.Information, Message = "Assembly {Name} excluded")] + internal static partial void LogAssemblyExcluded(ILogger logger, string name); + + [LoggerMessage(Level = LogLevel.Information, Message = "XML documentation file {Name} loaded")] + internal static partial void LogXmlDocFileLoaded(ILogger logger, string name); + + [LoggerMessage(Level = LogLevel.Information, Message = "Configuration saved into {File} file")] + internal static partial void LogConfigurationSaved(ILogger logger, string file); + + [LoggerMessage(Level = LogLevel.Information, Message = "Generating documentation in {Folder} folder")] + internal static partial void LogGeneratingDocumentation(ILogger logger, string folder); + + [LoggerMessage(Level = LogLevel.Information, Message = "A directory containing static template data copied to {Directory}")] + internal static partial void LogStaticTemplateDataCopied(ILogger logger, string directory); + + [LoggerMessage(Level = LogLevel.Information, Message = "No directory containing static template data found at path {Directory}")] + internal static partial void LogNoStaticTemplateDataFound(ILogger logger, string directory); + + [LoggerMessage(Level = LogLevel.Information, Message = "Static page {Directory}/{Page} found")] + internal static partial void LogStaticPageFound(ILogger logger, string directory, string page); + + [LoggerMessage(Level = LogLevel.Information, Message = "Page {Name} created")] + internal static partial void LogPageCreated(ILogger logger, string name); + + [LoggerMessage(Level = LogLevel.Information, Message = "Static file {FilePath} copied to {OutputPath}")] + internal static partial void LogStaticFileCopied(ILogger logger, string filePath, string outputPath); +} diff --git a/tests/RefDocGen.ExampleFSharpLibrary/RefDocGen.ExampleFSharpLibrary.fsproj b/tests/RefDocGen.ExampleFSharpLibrary/RefDocGen.ExampleFSharpLibrary.fsproj index c48d9a7d..12b8f151 100644 --- a/tests/RefDocGen.ExampleFSharpLibrary/RefDocGen.ExampleFSharpLibrary.fsproj +++ b/tests/RefDocGen.ExampleFSharpLibrary/RefDocGen.ExampleFSharpLibrary.fsproj @@ -1,7 +1,7 @@  - net8.0 + net10.0 true true diff --git a/tests/RefDocGen.ExampleLibrary/RefDocGen.ExampleLibrary.csproj b/tests/RefDocGen.ExampleLibrary/RefDocGen.ExampleLibrary.csproj index 774dd38e..522c33db 100644 --- a/tests/RefDocGen.ExampleLibrary/RefDocGen.ExampleLibrary.csproj +++ b/tests/RefDocGen.ExampleLibrary/RefDocGen.ExampleLibrary.csproj @@ -1,7 +1,7 @@  - net8.0 + net10.0 enable enable true diff --git a/tests/RefDocGen.ExampleVbLibrary/RefDocGen.ExampleVbLibrary.vbproj b/tests/RefDocGen.ExampleVbLibrary/RefDocGen.ExampleVbLibrary.vbproj index 9442cbad..554a171e 100644 --- a/tests/RefDocGen.ExampleVbLibrary/RefDocGen.ExampleVbLibrary.vbproj +++ b/tests/RefDocGen.ExampleVbLibrary/RefDocGen.ExampleVbLibrary.vbproj @@ -2,7 +2,7 @@ RefDocGen.ExampleVbLibrary - net8.0 + net10.0 true true diff --git a/tests/RefDocGen.IntegrationTests/Fixtures/DocumentationFixture.cs b/tests/RefDocGen.IntegrationTests/Fixtures/DocumentationFixture.cs index 9a5c8481..521a5838 100644 --- a/tests/RefDocGen.IntegrationTests/Fixtures/DocumentationFixture.cs +++ b/tests/RefDocGen.IntegrationTests/Fixtures/DocumentationFixture.cs @@ -69,9 +69,9 @@ public void GenerateDoc() var generator = new DocGenerator( [ - "../../../../RefDocGen.ExampleLibrary/bin/Debug/net8.0/RefDocGen.ExampleLibrary.dll", // ExampleLibrary - "../../../../RefDocGen.ExampleFSharpLibrary/bin/Debug/net8.0/RefDocGen.ExampleFSharpLibrary.dll", // ExampleFSharpLibrary - "../../../../RefDocGen.ExampleVbLibrary/bin/Debug/net8.0/RefDocGen.ExampleVbLibrary.dll", // ExampleVbLibrary + "../../../../RefDocGen.ExampleLibrary/bin/Debug/net10.0/RefDocGen.ExampleLibrary.dll", // ExampleLibrary + "../../../../RefDocGen.ExampleFSharpLibrary/bin/Debug/net10.0/RefDocGen.ExampleFSharpLibrary.dll", // ExampleFSharpLibrary + "../../../../RefDocGen.ExampleVbLibrary/bin/Debug/net10.0/RefDocGen.ExampleVbLibrary.dll", // ExampleVbLibrary ], templateProcessor, assemblyDataConfig, diff --git a/tests/RefDocGen.IntegrationTests/Fixtures/VersionedDocumentationFixture.cs b/tests/RefDocGen.IntegrationTests/Fixtures/VersionedDocumentationFixture.cs index 465697bc..c38b8d86 100644 --- a/tests/RefDocGen.IntegrationTests/Fixtures/VersionedDocumentationFixture.cs +++ b/tests/RefDocGen.IntegrationTests/Fixtures/VersionedDocumentationFixture.cs @@ -68,7 +68,7 @@ public void GenerateDoc() var logger = Substitute.For(); var generator = new DocGenerator( - ["../../../../RefDocGen.ExampleLibrary/bin/Debug/net8.0/RefDocGen.ExampleLibrary.dll"], // use only the ExampleLibrary + ["../../../../RefDocGen.ExampleLibrary/bin/Debug/net10.0/RefDocGen.ExampleLibrary.dll"], // use only the ExampleLibrary templateProcessor, assemblyDataConfig, outputDir, diff --git a/tests/RefDocGen.IntegrationTests/RefDocGen.IntegrationTests.csproj b/tests/RefDocGen.IntegrationTests/RefDocGen.IntegrationTests.csproj index 35a0a285..ef8a100e 100644 --- a/tests/RefDocGen.IntegrationTests/RefDocGen.IntegrationTests.csproj +++ b/tests/RefDocGen.IntegrationTests/RefDocGen.IntegrationTests.csproj @@ -1,7 +1,7 @@  - net8.0 + net10.0 enable enable recommended @@ -11,12 +11,12 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + runtime; build; native; contentfiles; analyzers; buildtransitive @@ -24,11 +24,11 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/RefDocGen.UnitTests/RefDocGen.UnitTests.csproj b/tests/RefDocGen.UnitTests/RefDocGen.UnitTests.csproj index 5cfd65ee..356d6d5d 100644 --- a/tests/RefDocGen.UnitTests/RefDocGen.UnitTests.csproj +++ b/tests/RefDocGen.UnitTests/RefDocGen.UnitTests.csproj @@ -1,7 +1,7 @@ - net8.0 + net10.0 enable enable recommended @@ -11,11 +11,11 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + runtime; build; native; contentfiles; analyzers; buildtransitive @@ -23,11 +23,11 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + runtime; build; native; contentfiles; analyzers; buildtransitive all