diff --git a/.editorconfig b/.editorconfig index 29226e9..534c820 100644 --- a/.editorconfig +++ b/.editorconfig @@ -187,6 +187,20 @@ dotnet_diagnostic.CA2007.severity = none # CA2227: Collection properties should be read only dotnet_diagnostic.CA2227.severity = none +# IDE ruleset +# IDE0160: Namespace declaration preferences. +dotnet_diagnostic.IDE0160.severity = none +# IDE0161: Namespace declaration preferences. +dotnet_diagnostic.IDE0161.severity = none +# IDE0028: Simplify collection initialization +dotnet_diagnostic.IDE0028.severity = none +# IDE0305: Use collection expression for fluent +dotnet_diagnostic.IDE0305.severity = none +# IDE0290: Use primary constructor +dotnet_diagnostic.IDE0290.severity = none +# IDE0078: Use pattern matching +dotnet_diagnostic.IDE0078.severity = none + # C# Test file [**/{tests,test,Tests,Test}/**.cs] diff --git a/build.ps1 b/build.ps1 index f567e3f..7e7e27d 100644 --- a/build.ps1 +++ b/build.ps1 @@ -16,12 +16,13 @@ if (Test-Path -Path $solution.assetZipPath) { # Build all dotnet projects into $solution.targetFolder as single exe's. Skip Test projects. foreach ($sln in (Get-ChildItem -Recurse src\*\*.csproj -Exclude *.Test.*)) { - Write-Host "Start building $($sln.FullName)" + Write-Host "Building $($sln.FullName)" & dotnet publish $sln.FullName -c Release -r win-x64 /p:PublishSingleFile=true /p:CopyOutputSymbolsToPublishDirectory=false --self-contained false -o $solution.targetFolder + Write-Host "Packing $($sln.FullName)" + & dotnet pack $sln.FullName -c Release -p:PackAsTool=true -o ./artifacts } -# Package NuGet packages -dotnet pack ./src/DocFxCompanionTools.sln -c Release -p:PackAsTool=true -o ./artifacts +Get-ChildItem ./artifacts # remove possible generated XML documentation files Remove-Item "$($solution.targetFolder)\*.xml" diff --git a/src/DocFxCompanionTools.sln b/src/DocFxCompanionTools.sln index 75623ca..a95f91d 100644 --- a/src/DocFxCompanionTools.sln +++ b/src/DocFxCompanionTools.sln @@ -7,14 +7,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DocLinkChecker", "DocLinkCh EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DocLinkChecker", "DocLinkChecker\DocLinkChecker\DocLinkChecker.csproj", "{AEB14801-AC47-4A41-8F37-D026D587A9EC}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DocLinkChecker.Test", "DocLinkChecker\DocLinkChecker.Test\DocLinkChecker.Test.csproj", "{CA07843C-47DF-459C-93CE-32D26FF0A839}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DocFxTocGenerator", "DocFxTocGenerator", "{7D8D6D5C-86A8-49E7-A3B0-B55FA4FDA2E3}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DocFxTocGenerator", "DocFxTocGenerator\DocFxTocGenerator\DocFxTocGenerator.csproj", "{665A85C1-3050-4B3D-9402-366C7C575090}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DocFxTocGenerator.Test", "DocFxTocGenerator\DocFxTocGenerator.Test\DocFxTocGenerator.Test.csproj", "{A9EF2D5A-8F18-4EC4-87FB-1EFE2DAD1C30}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DocFxOpenApi", "DocFxOpenApi", "{93989765-5AA6-48AB-8687-008A7577070F}" ProjectSection(SolutionItems) = preProject DocFxOpenApi\DocFxOpenApi.csproj = DocFxOpenApi\DocFxOpenApi.csproj @@ -34,18 +30,10 @@ Global {AEB14801-AC47-4A41-8F37-D026D587A9EC}.Debug|Any CPU.Build.0 = Debug|Any CPU {AEB14801-AC47-4A41-8F37-D026D587A9EC}.Release|Any CPU.ActiveCfg = Release|Any CPU {AEB14801-AC47-4A41-8F37-D026D587A9EC}.Release|Any CPU.Build.0 = Release|Any CPU - {CA07843C-47DF-459C-93CE-32D26FF0A839}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CA07843C-47DF-459C-93CE-32D26FF0A839}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CA07843C-47DF-459C-93CE-32D26FF0A839}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CA07843C-47DF-459C-93CE-32D26FF0A839}.Release|Any CPU.Build.0 = Release|Any CPU {665A85C1-3050-4B3D-9402-366C7C575090}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {665A85C1-3050-4B3D-9402-366C7C575090}.Debug|Any CPU.Build.0 = Debug|Any CPU {665A85C1-3050-4B3D-9402-366C7C575090}.Release|Any CPU.ActiveCfg = Release|Any CPU {665A85C1-3050-4B3D-9402-366C7C575090}.Release|Any CPU.Build.0 = Release|Any CPU - {A9EF2D5A-8F18-4EC4-87FB-1EFE2DAD1C30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A9EF2D5A-8F18-4EC4-87FB-1EFE2DAD1C30}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A9EF2D5A-8F18-4EC4-87FB-1EFE2DAD1C30}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A9EF2D5A-8F18-4EC4-87FB-1EFE2DAD1C30}.Release|Any CPU.Build.0 = Release|Any CPU {8F404B68-0C29-4AE7-BC23-203841FF2825}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8F404B68-0C29-4AE7-BC23-203841FF2825}.Debug|Any CPU.Build.0 = Debug|Any CPU {8F404B68-0C29-4AE7-BC23-203841FF2825}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -56,9 +44,7 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {AEB14801-AC47-4A41-8F37-D026D587A9EC} = {B8688D6A-F828-4A54-A5A8-95137FED9902} - {CA07843C-47DF-459C-93CE-32D26FF0A839} = {B8688D6A-F828-4A54-A5A8-95137FED9902} {665A85C1-3050-4B3D-9402-366C7C575090} = {7D8D6D5C-86A8-49E7-A3B0-B55FA4FDA2E3} - {A9EF2D5A-8F18-4EC4-87FB-1EFE2DAD1C30} = {7D8D6D5C-86A8-49E7-A3B0-B55FA4FDA2E3} {8F404B68-0C29-4AE7-BC23-203841FF2825} = {D9BD64D8-35E7-4EAE-9A15-E127A48E179B} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/DocFxTocGenerator/DocFxTocGenerator.Test/ConfigFilesServiceTests.cs b/src/DocFxTocGenerator/DocFxTocGenerator.Test/ConfigFilesServiceTests.cs index 72ef83d..23c6de4 100644 --- a/src/DocFxTocGenerator/DocFxTocGenerator.Test/ConfigFilesServiceTests.cs +++ b/src/DocFxTocGenerator/DocFxTocGenerator.Test/ConfigFilesServiceTests.cs @@ -32,7 +32,7 @@ public ConfigFilesServiceTests(ITestOutputHelper outputHelper) public void OrderList_GetExistingFile_ShouldBeValid() { // arrange - ConfigFilesService service = new(camelCasing: false, _fileService, _logger); + ConfigFilesService service = new(_fileService, _logger); // act var mockfile = _fileService.GetOrderFile(); @@ -58,7 +58,7 @@ public void OrderList_GetExistingFile_ShouldBeValid() public void OrderList_GetNonExisting_ShouldBeInitialized() { // arrange - ConfigFilesService service = new(camelCasing: false, _fileService, _logger); + ConfigFilesService service = new(_fileService, _logger); string folder = _fileService.AddFolder("temp"); // act @@ -79,7 +79,7 @@ public void OrderList_GetNonExisting_ShouldBeInitialized() public void OrderList_GetExistingWithIndex_ShouldBeOrderedCorrectly() { // arrange - ConfigFilesService service = new(camelCasing: false, _fileService, _logger); + ConfigFilesService service = new(_fileService, _logger); string folder = _fileService.AddFolder("temp"); _fileService.AddFile(folder, ".order", @"readme @@ -105,7 +105,7 @@ public void OrderList_GetExistingWithIndex_ShouldBeOrderedCorrectly() public void IgnoreList_GetExistingFile_ShouldBeValid() { // arrange - ConfigFilesService service = new(camelCasing: false, _fileService, _logger); + ConfigFilesService service = new(_fileService, _logger); // act var mockfile = _fileService.GetIgnoreFile(); @@ -128,7 +128,7 @@ public void IgnoreList_GetExistingFile_ShouldBeValid() public void IgnoreList_GetNonExisting_ShouldBeInitialized() { // arrange - ConfigFilesService service = new(camelCasing: false, _fileService, _logger); + ConfigFilesService service = new(_fileService, _logger); string folder = _fileService.AddFolder("temp"); // act @@ -145,7 +145,7 @@ public void IgnoreList_GetNonExisting_ShouldBeInitialized() public void OverrideList_GetExistingFile_ShouldBeValid() { // arrange - ConfigFilesService service = new(camelCasing: false, _fileService, _logger); + ConfigFilesService service = new(_fileService, _logger); // act var mockfile = _fileService.GetOverrideFile(); @@ -170,7 +170,7 @@ public void OverrideList_GetExistingFile_ShouldBeValid() public void OverrideList_GetNonExisting_ShouldBeInitialized() { // arrange - ConfigFilesService service = new(camelCasing: false, _fileService, _logger); + ConfigFilesService service = new(_fileService, _logger); string folder = _fileService.AddFolder("temp"); // act diff --git a/src/DocFxTocGenerator/DocFxTocGenerator.Test/IndexServiceTests.cs b/src/DocFxTocGenerator/DocFxTocGenerator.Test/IndexServiceTests.cs index 32c075c..92467f6 100644 --- a/src/DocFxTocGenerator/DocFxTocGenerator.Test/IndexServiceTests.cs +++ b/src/DocFxTocGenerator/DocFxTocGenerator.Test/IndexServiceTests.cs @@ -25,7 +25,7 @@ public IndexServiceTests() { _fileService.FillDemoSet(); _logger = _mockLogger.Logger; - _config = new(camelCasing: false, _fileService, _logger); + _config = new(_fileService, _logger); } [Fact] diff --git a/src/DocFxTocGenerator/DocFxTocGenerator.Test/LiquidServiceTests.cs b/src/DocFxTocGenerator/DocFxTocGenerator.Test/LiquidServiceTests.cs index 5077a87..76f8344 100644 --- a/src/DocFxTocGenerator/DocFxTocGenerator.Test/LiquidServiceTests.cs +++ b/src/DocFxTocGenerator/DocFxTocGenerator.Test/LiquidServiceTests.cs @@ -28,7 +28,7 @@ public LiquidServiceTests(ITestOutputHelper outputHelper) _outputHelper = outputHelper; _fileService.FillDemoSet(); _logger = _mockLogger.Logger; - _config = new(camelCasing: false, _fileService, _logger); + _config = new(_fileService, _logger); } [Fact] diff --git a/src/DocFxTocGenerator/DocFxTocGenerator.Test/TableOfContentsServiceTests.cs b/src/DocFxTocGenerator/DocFxTocGenerator.Test/TableOfContentsServiceTests.cs index dfb9bef..221e857 100644 --- a/src/DocFxTocGenerator/DocFxTocGenerator.Test/TableOfContentsServiceTests.cs +++ b/src/DocFxTocGenerator/DocFxTocGenerator.Test/TableOfContentsServiceTests.cs @@ -26,7 +26,7 @@ public TableOfContentsServiceTests() { _fileService.FillDemoSet(); _logger = _mockLogger.Logger; - _config = new(camelCasing: false, _fileService, _logger); + _config = new(_fileService, _logger); } [Fact] diff --git a/src/DocFxTocGenerator/DocFxTocGenerator/Actions/ContentInventoryAction.cs b/src/DocFxTocGenerator/DocFxTocGenerator/Actions/ContentInventoryAction.cs index 52838e1..8d10cd2 100644 --- a/src/DocFxTocGenerator/DocFxTocGenerator/Actions/ContentInventoryAction.cs +++ b/src/DocFxTocGenerator/DocFxTocGenerator/Actions/ContentInventoryAction.cs @@ -57,7 +57,7 @@ public ContentInventoryAction( _fileService = fileService; _logger = logger; - _configService = new(camelCasing, fileService, logger); + _configService = new(fileService, logger); _fileDataService = new(camelCasing, fileService, logger); } @@ -162,7 +162,7 @@ public Task RunAsync() private void AddFiles(FolderData folder, string dirPath) { - string[] patterns = { "*.md", "*.swagger.json" }; + string[] patterns = ["*.md", "*.swagger.json"]; string patternsJoined = string.Join(", ", patterns); EnumerationOptions caseSetting = new EnumerationOptions { MatchCasing = MatchCasing.CaseInsensitive }; diff --git a/src/DocFxTocGenerator/DocFxTocGenerator/Actions/EnsureIndexAction.cs b/src/DocFxTocGenerator/DocFxTocGenerator/Actions/EnsureIndexAction.cs index b8ccd20..d3648ca 100644 --- a/src/DocFxTocGenerator/DocFxTocGenerator/Actions/EnsureIndexAction.cs +++ b/src/DocFxTocGenerator/DocFxTocGenerator/Actions/EnsureIndexAction.cs @@ -54,7 +54,7 @@ public EnsureIndexAction( /// 0 on success, 1 on warning, 2 on error. public Task RunAsync() { - ReturnCode ret = ReturnCode.Normal; + ReturnCode ret; _logger.LogInformation($"\n*** ENSURE INDEX STAGE."); try diff --git a/src/DocFxTocGenerator/DocFxTocGenerator/ConfigFiles/ConfigFilesService.cs b/src/DocFxTocGenerator/DocFxTocGenerator/ConfigFiles/ConfigFilesService.cs index 6063d4f..036dea1 100644 --- a/src/DocFxTocGenerator/DocFxTocGenerator/ConfigFiles/ConfigFilesService.cs +++ b/src/DocFxTocGenerator/DocFxTocGenerator/ConfigFiles/ConfigFilesService.cs @@ -12,24 +12,18 @@ namespace DocFxTocGenerator.ConfigFiles; /// public class ConfigFilesService { - private readonly bool _camelCasing; private readonly IFileService _fileService; private readonly ILogger _logger; - private readonly FileInfoService _fileData; /// /// Initializes a new instance of the class. /// - /// Use camel casing for titles. /// File service. /// Logger. - public ConfigFilesService(bool camelCasing, IFileService fileService, ILogger logger) + public ConfigFilesService(IFileService fileService, ILogger logger) { - _camelCasing = camelCasing; _fileService = fileService; _logger = logger; - - _fileData = new(_camelCasing, _fileService, _logger); } /// diff --git a/src/DocFxTocGenerator/DocFxTocGenerator/DocFxTocGenerator.csproj b/src/DocFxTocGenerator/DocFxTocGenerator/DocFxTocGenerator.csproj index 4f03cea..0bde33a 100644 --- a/src/DocFxTocGenerator/DocFxTocGenerator/DocFxTocGenerator.csproj +++ b/src/DocFxTocGenerator/DocFxTocGenerator/DocFxTocGenerator.csproj @@ -36,7 +36,7 @@ - + diff --git a/src/DocFxTocGenerator/DocFxTocGenerator/FileService/FileInfoService.cs b/src/DocFxTocGenerator/DocFxTocGenerator/FileService/FileInfoService.cs index 97df253..8dec1b4 100644 --- a/src/DocFxTocGenerator/DocFxTocGenerator/FileService/FileInfoService.cs +++ b/src/DocFxTocGenerator/DocFxTocGenerator/FileService/FileInfoService.cs @@ -4,7 +4,6 @@ // using System.Text.RegularExpressions; using Markdig; -using Markdig.Helpers; using Markdig.Syntax; using Markdig.Syntax.Inlines; using Microsoft.Extensions.Logging; diff --git a/src/DocFxTocGenerator/DocFxTocGenerator/TableOfContents/TableOfContentsService.cs b/src/DocFxTocGenerator/DocFxTocGenerator/TableOfContents/TableOfContentsService.cs index d484770..c178acc 100644 --- a/src/DocFxTocGenerator/DocFxTocGenerator/TableOfContents/TableOfContentsService.cs +++ b/src/DocFxTocGenerator/DocFxTocGenerator/TableOfContents/TableOfContentsService.cs @@ -3,7 +3,6 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. // using System.CodeDom.Compiler; -using System.Xml.Linq; using DocFxTocGenerator.FileService; using Microsoft.Extensions.Logging; diff --git a/src/DocLinkChecker/DocLinkChecker/DocLinkChecker.csproj b/src/DocLinkChecker/DocLinkChecker/DocLinkChecker.csproj index 6ddcd17..7e8c91d 100644 --- a/src/DocLinkChecker/DocLinkChecker/DocLinkChecker.csproj +++ b/src/DocLinkChecker/DocLinkChecker/DocLinkChecker.csproj @@ -22,12 +22,20 @@ - - - - - - - + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive +