diff --git a/.editorconfig b/.editorconfig index 131b58e..3b97902 100644 --- a/.editorconfig +++ b/.editorconfig @@ -17,6 +17,9 @@ resharper_comment_typo_highlighting = none resharper_identifier_typo_highlighting = none resharper_string_literal_typo_highlighting = none +[Directory.Packages.props] +insert_final_newline = false + [dotnet-tools.json] insert_final_newline = false @@ -87,6 +90,7 @@ csharp_style_prefer_local_over_anonymous_function = true : suggestion csharp_style_prefer_not_pattern = true : suggestion csharp_style_prefer_null_check_over_type_check = true : suggestion csharp_style_prefer_pattern_matching = true : suggestion +csharp_style_prefer_primary_constructors = true : suggestion csharp_style_prefer_range_operator = true : suggestion csharp_style_prefer_switch_expression = true : suggestion csharp_style_prefer_tuple_swap = true : warning @@ -203,7 +207,9 @@ dotnet_diagnostic.IDE0160.severity = suggestion dotnet_diagnostic.IDE0161.severity = suggestion dotnet_diagnostic.IDE0170.severity = suggestion dotnet_diagnostic.IDE0180.severity = warning +dotnet_diagnostic.IDE0290.severity = suggestion dotnet_diagnostic.IDE1005.severity = suggestion +dotnet_diagnostic.NUnit2045.severity = suggestion dotnet_diagnostic.SA0001.severity = none dotnet_diagnostic.SA1003.severity = none dotnet_diagnostic.SA1008.severity = none @@ -326,6 +332,7 @@ resharper_arrange_missing_parentheses_highlighting = hint resharper_arrange_trailing_comma_in_multiline_lists_highlighting = warning resharper_comment_typo_highlighting = none resharper_compare_of_floats_by_equality_operator_highlighting = suggestion +resharper_convert_to_primary_constructor_highlighting = hint resharper_csharp_align_first_arg_by_paren = false resharper_csharp_align_linq_query = false resharper_csharp_align_multiline_argument = false @@ -347,6 +354,7 @@ resharper_csharp_indent_anonymous_method_block = false resharper_csharp_indent_nested_for_stmt = true resharper_csharp_indent_nested_foreach_stmt = true resharper_csharp_indent_nested_while_stmt = true +resharper_csharp_indent_raw_literal_string = indent resharper_csharp_int_align = false resharper_csharp_keep_existing_arrangement = true resharper_csharp_nested_ternary_style = simple_wrap diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index da56fbe..a313bbb 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,24 +1,20 @@ name: Build + on: - workflow_dispatch: push: - paths-ignore: - - '*.md' - - 'docs/**' - branches: - - 'master' - tags-ignore: - - '**' + branches: [master] + tags-ignore: ['**'] pull_request: - paths-ignore: - - '*.md' - - 'docs/**' + workflow_dispatch: + env: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_NOLOGO: 1 DOTNET_CLI_TELEMETRY_OPTOUT: 1 + defaults: run: shell: pwsh + jobs: build: runs-on: ${{ matrix.os }} @@ -26,14 +22,16 @@ jobs: matrix: os: [ubuntu-latest, windows-latest, macos-latest] steps: + - name: Install .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: | + 6.0.x + 8.0.x - name: Check out code uses: actions/checkout@v3 with: - fetch-depth: 0 - - name: Set up .NET 7 - uses: actions/setup-dotnet@v3 - with: - dotnet-version: 7.0.x + fetch-depth: 0 # required to publish docs - name: Restore run: .\build.ps1 restore - name: Build diff --git a/.github/workflows/publish-docs.yaml b/.github/workflows/publish-docs.yaml new file mode 100644 index 0000000..ca0e689 --- /dev/null +++ b/.github/workflows/publish-docs.yaml @@ -0,0 +1,31 @@ +name: Publish Docs + +on: + workflow_dispatch: + +env: + DOTNET_NOLOGO: 1 + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + +defaults: + run: + shell: pwsh + +jobs: + publish-docs: + runs-on: windows-latest + steps: + - name: Install .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: | + 6.0.x + 8.0.x + - name: Check out code + uses: actions/checkout@v3 + with: + fetch-depth: 0 # required to publish docs + - name: Publish Docs + env: + BUILD_BOT_PASSWORD: ${{ secrets.BUILD_BOT_PASSWORD }} + run: .\build.ps1 publish --no-test --trigger publish-docs diff --git a/.gitignore b/.gitignore index 4aa6cfb..a2ad192 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1,16 @@ +.vs/ +.idea/ +artifacts/ bin/ obj/ release/ -.vs/ -.idea/ -Thumbs.db + *.cache -*.user -*.userprefs +*.log *.ncrunchproject *.ncrunchsolution +*.user +launchSettings.json nCrunchTemp* _ReSharper* .DS_Store -launchSettings.json diff --git a/Directory.Build.props b/Directory.Build.props index e065ef6..9e0394f 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,12 +2,13 @@ 2.8.0 - 11.0 + 2.8.0 + 12.0 enable enable true + $(NoWarn);1591;1998;NU1507;NU5105 en-US - $(NoWarn);1591;1998;NU5105 embedded FacilityApi FacilityMarkdown @@ -20,11 +21,16 @@ true true true - AllEnabledByDefault + latest-all true true false false + false + true + true + true + true @@ -32,14 +38,4 @@ true - - 2.11.0 - - - - - - - - diff --git a/Directory.Packages.props b/Directory.Packages.props new file mode 100644 index 0000000..4b68f9f --- /dev/null +++ b/Directory.Packages.props @@ -0,0 +1,20 @@ + + + true + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/FacilityMarkdown.sln b/FacilityMarkdown.sln index 99ead65..4a7a15b 100644 --- a/FacilityMarkdown.sln +++ b/FacilityMarkdown.sln @@ -11,7 +11,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution build.ps1 = build.ps1 .github\workflows\build.yaml = .github\workflows\build.yaml Directory.Build.props = Directory.Build.props - dotnet-tools.json = dotnet-tools.json + Directory.Packages.props = Directory.Packages.props + global.json = global.json LICENSE = LICENSE nuget.config = nuget.config README.md = README.md diff --git a/LICENSE b/LICENSE index 2fd22c4..df586e7 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright 2022 Ed Ball +Copyright 2024 Ed Ball Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/build.ps1 b/build.ps1 index 21a0bb6..9b32821 100755 --- a/build.ps1 +++ b/build.ps1 @@ -2,14 +2,9 @@ $ErrorActionPreference = 'Stop' Push-Location $PSScriptRoot try { - if (-not (Test-Path ./tools/bin/Build) -or - (Get-ChildItem ./tools/Build/* | Measure-Object LastWriteTime -Maximum).Maximum -gt - (Get-ChildItem ./tools/bin/Build/* | Measure-Object LastWriteTime -Maximum).Maximum) { - if (Test-Path ./tools/bin/Build) { Remove-Item ./tools/bin/Build -Recurse } - dotnet publish ./tools/Build/Build.csproj --output ./tools/bin/Build --nologo --verbosity quiet - if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } - } - dotnet ./tools/bin/Build/Build.dll $args + dotnet publish ./tools/Build/Build.csproj --artifacts-path ./artifacts --nologo --verbosity quiet + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + dotnet ./artifacts/publish/Build/release/Build.dll $args if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } } finally { diff --git a/global.json b/global.json new file mode 100644 index 0000000..391ba3c --- /dev/null +++ b/global.json @@ -0,0 +1,6 @@ +{ + "sdk": { + "version": "8.0.100", + "rollForward": "latestFeature" + } +} diff --git a/nuget.config b/nuget.config index 3d2c236..6873eb9 100644 --- a/nuget.config +++ b/nuget.config @@ -1,4 +1,5 @@ - + + diff --git a/src/Facility.CodeGen.Markdown/Facility.CodeGen.Markdown.csproj b/src/Facility.CodeGen.Markdown/Facility.CodeGen.Markdown.csproj index 03140f2..e5fd355 100644 --- a/src/Facility.CodeGen.Markdown/Facility.CodeGen.Markdown.csproj +++ b/src/Facility.CodeGen.Markdown/Facility.CodeGen.Markdown.csproj @@ -9,8 +9,8 @@ - - + + diff --git a/src/Facility.CodeGen.Markdown/MarkdownGenerator.cs b/src/Facility.CodeGen.Markdown/MarkdownGenerator.cs index b226ac3..3c752f2 100644 --- a/src/Facility.CodeGen.Markdown/MarkdownGenerator.cs +++ b/src/Facility.CodeGen.Markdown/MarkdownGenerator.cs @@ -41,7 +41,7 @@ public override CodeGenOutput GenerateOutput(ServiceInfo service) return new CodeGenOutput( files: files.Select(x => new CodeGenFile(x.Name, x.Text)).ToList(), - patternsToClean: new[] { new CodeGenPattern($"{service.Name}/*.md", CodeGenUtility.GetCodeGenComment(GeneratorName ?? "")) }); + patternsToClean: [new CodeGenPattern($"{service.Name}/*.md", CodeGenUtility.GetCodeGenComment(GeneratorName ?? ""))]); } /// diff --git a/src/fsdgenmd/FsdGenMarkdownApp.cs b/src/fsdgenmd/FsdGenMarkdownApp.cs index 8de69cd..613ccf5 100644 --- a/src/fsdgenmd/FsdGenMarkdownApp.cs +++ b/src/fsdgenmd/FsdGenMarkdownApp.cs @@ -9,18 +9,18 @@ public sealed class FsdGenMarkdownApp : CodeGeneratorApp { public static int Main(string[] args) => new FsdGenMarkdownApp().Run(args); - protected override IReadOnlyList Description => new[] - { + protected override IReadOnlyList Description => + [ "Generates Markdown for a Facility Service Definition.", - }; + ]; - protected override IReadOnlyList ExtraUsage => new[] - { + protected override IReadOnlyList ExtraUsage => + [ " --no-http", " Omit HTTP documentation.", " --template ", " Override the default template.", - }; + ]; protected override CodeGenerator CreateGenerator() => new MarkdownGenerator(); diff --git a/src/fsdgenmd/fsdgenmd.csproj b/src/fsdgenmd/fsdgenmd.csproj index 7deb4b4..63a580b 100644 --- a/src/fsdgenmd/fsdgenmd.csproj +++ b/src/fsdgenmd/fsdgenmd.csproj @@ -11,7 +11,7 @@ - + diff --git a/tests/Facility.CodeGen.Markdown.UnitTests/Facility.CodeGen.Markdown.UnitTests.csproj b/tests/Facility.CodeGen.Markdown.UnitTests/Facility.CodeGen.Markdown.UnitTests.csproj index 76cb964..cc892fa 100644 --- a/tests/Facility.CodeGen.Markdown.UnitTests/Facility.CodeGen.Markdown.UnitTests.csproj +++ b/tests/Facility.CodeGen.Markdown.UnitTests/Facility.CodeGen.Markdown.UnitTests.csproj @@ -9,10 +9,10 @@ - - - - + + + + diff --git a/tests/Facility.CodeGen.Markdown.UnitTests/MarkdownGeneratorTests.cs b/tests/Facility.CodeGen.Markdown.UnitTests/MarkdownGeneratorTests.cs index 502eed0..7abb862 100644 --- a/tests/Facility.CodeGen.Markdown.UnitTests/MarkdownGeneratorTests.cs +++ b/tests/Facility.CodeGen.Markdown.UnitTests/MarkdownGeneratorTests.cs @@ -14,7 +14,7 @@ public void GenerateExampleApiSuccess() const string fileName = "Facility.CodeGen.Markdown.UnitTests.ConformanceApi.fsd"; var parser = new FsdParser(); var stream = GetType().GetTypeInfo().Assembly.GetManifestResourceStream(fileName); - Assert.IsNotNull(stream); + Assert.That(stream, Is.Not.Null); using (var reader = new StreamReader(stream!)) service = parser.ParseDefinition(new ServiceDefinitionText(Path.GetFileName(fileName), reader.ReadToEnd())); @@ -38,8 +38,8 @@ public void DtoWithExternDataType() var output = generator.GenerateOutput(service); var file = output.Files.First(x => x.Name == "TestApi/Test.md"); - StringAssert.Contains("\"thing\": (Thing)", file.Text); - StringAssert.Contains("| thing | Thing | This is a description. |", file.Text); + Assert.That(file.Text, Does.Contain("\"thing\": (Thing)")); + Assert.That(file.Text, Does.Contain("| thing | Thing | This is a description. |")); } [Test] @@ -55,7 +55,7 @@ public void DtoWithExternEnumType() var output = generator.GenerateOutput(service); var file = output.Files.First(x => x.Name == "TestApi/Test.md"); - StringAssert.Contains("\"kind\": (Kind)", file.Text); - StringAssert.Contains("| kind | Kind | This is a description. |", file.Text); + Assert.That(file.Text, Does.Contain("\"kind\": (Kind)")); + Assert.That(file.Text, Does.Contain("| kind | Kind | This is a description. |")); } } diff --git a/tools/Build/Build.csproj b/tools/Build/Build.csproj index 3fda495..94c9978 100644 --- a/tools/Build/Build.csproj +++ b/tools/Build/Build.csproj @@ -2,11 +2,11 @@ Exe - net7.0 + net8.0 - + diff --git a/tools/XmlDocGen/XmlDocGen.csproj b/tools/XmlDocGen/XmlDocGen.csproj index 5665596..a55a484 100644 --- a/tools/XmlDocGen/XmlDocGen.csproj +++ b/tools/XmlDocGen/XmlDocGen.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 @@ -10,7 +10,7 @@ - +