diff --git a/.editorconfig b/.editorconfig index ad50735..c77b16a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -12,21 +12,77 @@ insert_final_newline = false indent_style = space indent_size = 2 -[{*.csproj,*.sln,*.Build.props}] +[{*.csproj,*.slnx,*.sln,*.Build.props}] # Project file properties indent_style = space indent_size = 2 ij_xml_space_inside_empty_tag = true [{*.cs,*.cshtml,*.razor}] -# CSharp properties +# CSharp file properties trim_trailing_whitespace = true insert_final_newline = true indent_size = 4 -max_line_length = 140 +max_line_length = 120 -# Microsoft .NET properties +# CSharp style rules +csharp_keep_blank_lines_in_code = 1 +csharp_keep_blank_lines_in_declarations = 1 +csharp_blank_lines_after_multiline_statements = 1 +csharp_blank_lines_after_block_statements = 1 +csharp_blank_lines_after_case = 0 +csharp_blank_lines_after_control_transfer_statements = 0 +csharp_blank_lines_after_file_scoped_namespace_directive = 1 +csharp_blank_lines_after_start_comment = 1 +csharp_blank_lines_after_using_list = 1 +csharp_blank_lines_around_accessor = 1 +csharp_blank_lines_around_auto_property = 1 +csharp_blank_lines_around_block_case_section = 1 +csharp_blank_lines_around_field = 1 +csharp_blank_lines_around_invocable = 1 +csharp_blank_lines_around_local_method = 1 +csharp_blank_lines_around_multiline_case_section = 0 +csharp_blank_lines_around_namespace = 1 +csharp_blank_lines_around_property = 1 +csharp_blank_lines_around_region = 1 +csharp_blank_lines_around_single_line_accessor = 0 +csharp_blank_lines_around_single_line_auto_property = 1 +csharp_blank_lines_around_single_line_field = 0 +csharp_blank_lines_around_single_line_invocable = 0 +csharp_blank_lines_around_single_line_local_method = 1 +csharp_blank_lines_around_single_line_property = 0 +csharp_blank_lines_around_single_line_type = 1 +csharp_blank_lines_around_type = 1 +csharp_blank_lines_inside_region = 0 +csharp_blank_lines_inside_type = 0 +csharp_blank_lines_before_case = 0 +csharp_blank_lines_before_block_statements = 1 +csharp_blank_lines_before_control_transfer_statements = 1 +csharp_blank_lines_before_multiline_statements = 1 +csharp_remove_blank_lines_near_braces_in_code = true +csharp_remove_blank_lines_near_braces_in_declarations = true +csharp_braces_for_ifelse = not_required_for_both # actually behaves as `required for either` +csharp_braces_for_using = required_for_multiline +csharp_braces_for_while = required_for_multiline +csharp_empty_block_style = together_same_line +csharp_indent_preprocessor_if = usual_indent +csharp_instance_members_qualify_declared_in = base_class +csharp_keep_existing_declaration_parens_arrangement = false +csharp_keep_existing_embedded_arrangement = false +csharp_keep_existing_expr_member_arrangement = false +csharp_keep_existing_invocation_parens_arrangement = false +csharp_keep_existing_linebreaks = false +csharp_keep_existing_list_patterns_arrangement = false +csharp_keep_existing_primary_constructor_declaration_parens_arrangement = false +csharp_keep_existing_property_patterns_arrangement = false +csharp_nested_ternary_style = expanded csharp_new_line_before_members_in_object_initializers = true +csharp_object_creation_when_type_not_evident = target_typed +csharp_place_accessorholder_attribute_on_same_line = false +csharp_place_expr_method_on_single_line = false +csharp_place_simple_embedded_statement_on_same_line = false +csharp_place_simple_list_pattern_on_single_line = true +csharp_place_type_constraints_on_same_line = false csharp_preferred_modifier_order = public, private, protected, internal, file, new, static, abstract, virtual, sealed, readonly, override, extern, unsafe, volatile, async, required:suggestion csharp_style_expression_bodied_accessors = true:suggestion csharp_style_expression_bodied_methods = true:none @@ -34,6 +90,25 @@ csharp_style_expression_bodied_properties = true:suggestion csharp_style_var_elsewhere = true:suggestion csharp_style_var_for_built_in_types = true:suggestion csharp_style_var_when_type_is_apparent = true:suggestion +csharp_trailing_comma_in_multiline_lists = true +csharp_trailing_comma_in_singleline_lists = false +csharp_wrap_array_initializer_style = chop_if_long +csharp_wrap_after_declaration_lpar = true +csharp_wrap_after_property_in_chained_method_calls = true +csharp_wrap_arguments_style = chop_if_long +csharp_wrap_before_first_method_call = true +csharp_wrap_before_primary_constructor_declaration_rpar = true +csharp_wrap_chained_binary_expressions = chop_if_long +csharp_wrap_chained_binary_patterns = chop_if_long +csharp_wrap_chained_method_calls = chop_always +csharp_wrap_extends_list_style = chop_if_long +csharp_wrap_list_pattern = chop_if_long +csharp_wrap_multiple_type_parameter_constraints_style = chop_always +csharp_wrap_object_and_collection_initializer_style = chop_always +csharp_wrap_parameters_style = chop_if_long +csharp_wrap_ternary_expr_style = chop_always + +# .NET style rules dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:none dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:none dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:none @@ -44,54 +119,9 @@ dotnet_style_qualification_for_field = false:suggestion dotnet_style_qualification_for_method = false:suggestion dotnet_style_qualification_for_property = false:suggestion dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion - -# ReSharper properties -resharper_blank_lines_after_multiline_statements = 1 -resharper_blank_lines_around_single_line_auto_property = 1 -resharper_blank_lines_before_block_statements = 1 -resharper_blank_lines_before_control_transfer_statements = 1 -resharper_blank_lines_before_multiline_statements = 1 -resharper_blank_lines_before_single_line_comment = 1 -resharper_braces_for_ifelse = not_required_for_both # actually behaves as `required for either` -resharper_braces_for_using = required_for_multiline -resharper_braces_for_while = required_for_multiline -resharper_csharp_blank_lines_around_single_line_invocable = 1 -resharper_csharp_empty_block_style = together_same_line -resharper_csharp_place_type_constraints_on_same_line = false -resharper_csharp_trailing_comma_in_multiline_lists = true -resharper_csharp_trailing_comma_in_singleline_lists = false -resharper_csharp_wrap_after_declaration_lpar = true -resharper_csharp_wrap_arguments_style = chop_if_long -resharper_csharp_wrap_extends_list_style = chop_if_long -resharper_csharp_wrap_multiple_type_parameter_constraints_style = chop_always -resharper_csharp_wrap_object_and_collection_initializer_style = chop_always -resharper_csharp_wrap_parameters_style = chop_if_long -resharper_csharp_wrap_ternary_expr_style = chop_always -resharper_indent_preprocessor_if = usual_indent -resharper_instance_members_qualify_declared_in = base_class -resharper_keep_existing_declaration_parens_arrangement = false -resharper_keep_existing_embedded_arrangement = false -resharper_keep_existing_expr_member_arrangement = false -resharper_keep_existing_invocation_parens_arrangement = false -resharper_keep_existing_linebreaks = false -resharper_keep_existing_list_patterns_arrangement = false -resharper_keep_existing_primary_constructor_declaration_parens_arrangement = false -resharper_keep_existing_property_patterns_arrangement = false -resharper_csharp_keep_existing_linebreaks = false -resharper_nested_ternary_style = expanded -resharper_object_creation_when_type_not_evident = target_typed -resharper_place_accessorholder_attribute_on_same_line = false -resharper_place_expr_method_on_single_line = false -resharper_place_simple_embedded_statement_on_same_line = false -resharper_place_simple_list_pattern_on_single_line = true -resharper_trailing_comma_in_multiline_lists = true -resharper_wrap_after_property_in_chained_method_calls = true -resharper_wrap_before_first_method_call = true -resharper_wrap_before_primary_constructor_declaration_rpar = true -resharper_wrap_chained_binary_expressions = chop_if_long -resharper_wrap_chained_binary_patterns = chop_if_long -resharper_wrap_chained_method_calls = chop_always -resharper_wrap_list_pattern = chop_if_long +dotnet_style_prefer_collection_expression = true +dotnet_separate_import_directive_groups = false +dotnet_sort_system_directives_first = true [*.{received,verified}.{txt,xml,json}] # Verify settings diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml index 0f9bb84..55dee6b 100644 --- a/.github/workflows/Build.yml +++ b/.github/workflows/Build.yml @@ -1,5 +1,6 @@ name: Build +permissions: { } on: workflow_dispatch: release: @@ -8,6 +9,8 @@ on: push: branches: - 'main' + - 'feature/**' + - 'patch/**' jobs: @@ -26,13 +29,13 @@ jobs: fetch-depth: 0 - uses: actions/setup-dotnet@v4 with: - dotnet-version: '9.0.x' + dotnet-version: '10.0.x' - name: SetupBuildInfo id: SetupBuildInfo run: dotnet run --project _atom/_atom.csproj SetupBuildInfo --skip --headless - PackRez: + Pack: runs-on: ubuntu-latest steps: @@ -42,33 +45,17 @@ jobs: fetch-depth: 0 - uses: actions/setup-dotnet@v4 with: - dotnet-version: '9.0.x' + dotnet-version: '10.0.x' - - name: PackRez - id: PackRez - run: dotnet run --project _atom/_atom.csproj PackRez --skip --headless + - name: Pack + id: Pack + run: dotnet run --project _atom/_atom.csproj Pack --skip --headless - name: Upload DecSm.Rez uses: actions/upload-artifact@v4 with: name: DecSm.Rez path: "${{ github.workspace }}/.github/publish/DecSm.Rez" - - PackRezConfiguration: - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: actions/setup-dotnet@v4 - with: - dotnet-version: '9.0.x' - - - name: PackRezConfiguration - id: PackRezConfiguration - run: dotnet run --project _atom/_atom.csproj PackRezConfiguration --skip --headless - name: Upload DecSm.Rez.Configuration uses: actions/upload-artifact@v4 @@ -76,30 +63,44 @@ jobs: name: DecSm.Rez.Configuration path: "${{ github.workspace }}/.github/publish/DecSm.Rez.Configuration" - TestRez: - runs-on: ubuntu-latest + Test: + strategy: + matrix: + job-runs-on: [ windows-latest, ubuntu-latest, macos-latest ] + test-framework: [ net8.0, net9.0, net10.0 ] + runs-on: ${{ matrix.job-runs-on }} steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: '10.0.x' + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.0.x' - uses: actions/setup-dotnet@v4 with: dotnet-version: '9.0.x' - - name: TestRez - id: TestRez - run: dotnet run --project _atom/_atom.csproj TestRez --skip --headless + - name: Test + id: Test + run: dotnet run --project _atom/_atom.csproj Test --skip --headless + env: + job-runs-on: ${{ matrix.job-runs-on }} + test-framework: ${{ matrix.test-framework }} + build-slice: ${{ matrix.job-runs-on }}-${{ matrix.test-framework }} - - name: Upload DecSm.Rez.UnitTests + - name: Upload DecSm.Rez.Tests uses: actions/upload-artifact@v4 with: - name: DecSm.Rez.UnitTests - path: "${{ github.workspace }}/.github/publish/DecSm.Rez.UnitTests" + name: DecSm.Rez.Tests-${{ matrix.job-runs-on }}-${{ matrix.test-framework }} + path: "${{ github.workspace }}/.github/publish/DecSm.Rez.Tests" PushToNuget: - needs: [ PackRez, PackRezConfiguration ] + needs: [ Test, Pack ] runs-on: ubuntu-latest steps: @@ -109,7 +110,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-dotnet@v4 with: - dotnet-version: '9.0.x' + dotnet-version: '10.0.x' - name: Download DecSm.Rez uses: actions/download-artifact@v4 @@ -130,9 +131,11 @@ jobs: nuget-push-api-key: ${{ secrets.NUGET_PUSH_API_KEY }} PushToRelease: - needs: [ PackRez, PackRezConfiguration, SetupBuildInfo ] + needs: [ Pack, Test, SetupBuildInfo ] runs-on: ubuntu-latest if: contains(needs.SetupBuildInfo.outputs.build-version, '-') == false + permissions: + contents: write steps: - name: Checkout @@ -141,7 +144,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-dotnet@v4 with: - dotnet-version: '9.0.x' + dotnet-version: '10.0.x' - name: Download DecSm.Rez uses: actions/download-artifact@v4 @@ -155,6 +158,60 @@ jobs: name: DecSm.Rez.Configuration path: "${{ github.workspace }}/.github/artifacts/DecSm.Rez.Configuration" + - name: Download DecSm.Rez.Tests + uses: actions/download-artifact@v4 + with: + name: DecSm.Rez.Tests-windows-latest-net8.0 + path: "${{ github.workspace }}/.github/artifacts/DecSm.Rez.Tests" + + - name: Download DecSm.Rez.Tests + uses: actions/download-artifact@v4 + with: + name: DecSm.Rez.Tests-windows-latest-net9.0 + path: "${{ github.workspace }}/.github/artifacts/DecSm.Rez.Tests" + + - name: Download DecSm.Rez.Tests + uses: actions/download-artifact@v4 + with: + name: DecSm.Rez.Tests-windows-latest-net10.0 + path: "${{ github.workspace }}/.github/artifacts/DecSm.Rez.Tests" + + - name: Download DecSm.Rez.Tests + uses: actions/download-artifact@v4 + with: + name: DecSm.Rez.Tests-ubuntu-latest-net8.0 + path: "${{ github.workspace }}/.github/artifacts/DecSm.Rez.Tests" + + - name: Download DecSm.Rez.Tests + uses: actions/download-artifact@v4 + with: + name: DecSm.Rez.Tests-ubuntu-latest-net9.0 + path: "${{ github.workspace }}/.github/artifacts/DecSm.Rez.Tests" + + - name: Download DecSm.Rez.Tests + uses: actions/download-artifact@v4 + with: + name: DecSm.Rez.Tests-ubuntu-latest-net10.0 + path: "${{ github.workspace }}/.github/artifacts/DecSm.Rez.Tests" + + - name: Download DecSm.Rez.Tests + uses: actions/download-artifact@v4 + with: + name: DecSm.Rez.Tests-macos-latest-net8.0 + path: "${{ github.workspace }}/.github/artifacts/DecSm.Rez.Tests" + + - name: Download DecSm.Rez.Tests + uses: actions/download-artifact@v4 + with: + name: DecSm.Rez.Tests-macos-latest-net9.0 + path: "${{ github.workspace }}/.github/artifacts/DecSm.Rez.Tests" + + - name: Download DecSm.Rez.Tests + uses: actions/download-artifact@v4 + with: + name: DecSm.Rez.Tests-macos-latest-net10.0 + path: "${{ github.workspace }}/.github/artifacts/DecSm.Rez.Tests" + - name: PushToRelease id: PushToRelease run: dotnet run --project _atom/_atom.csproj PushToRelease --skip --headless diff --git a/.github/workflows/Validate.yml b/.github/workflows/Validate.yml index 96898a0..0f6ca1c 100644 --- a/.github/workflows/Validate.yml +++ b/.github/workflows/Validate.yml @@ -1,5 +1,6 @@ name: Validate +permissions: { } on: workflow_dispatch: pull_request: @@ -23,13 +24,13 @@ jobs: fetch-depth: 0 - uses: actions/setup-dotnet@v4 with: - dotnet-version: '9.0.x' + dotnet-version: '10.0.x' - name: SetupBuildInfo id: SetupBuildInfo run: dotnet run --project _atom/_atom.csproj SetupBuildInfo --skip --headless - PackRez: + Pack: runs-on: ubuntu-latest steps: @@ -39,14 +40,18 @@ jobs: fetch-depth: 0 - uses: actions/setup-dotnet@v4 with: - dotnet-version: '9.0.x' + dotnet-version: '10.0.x' - - name: PackRez - id: PackRez - run: dotnet run --project _atom/_atom.csproj PackRez --skip --headless + - name: Pack + id: Pack + run: dotnet run --project _atom/_atom.csproj Pack --skip --headless - PackRezConfiguration: - runs-on: ubuntu-latest + Test: + strategy: + matrix: + job-runs-on: [ windows-latest, ubuntu-latest, macos-latest ] + test-framework: [ net8.0, net9.0, net10.0 ] + runs-on: ${{ matrix.job-runs-on }} steps: - name: Checkout @@ -55,30 +60,18 @@ jobs: fetch-depth: 0 - uses: actions/setup-dotnet@v4 with: - dotnet-version: '9.0.x' - - - name: PackRezConfiguration - id: PackRezConfiguration - run: dotnet run --project _atom/_atom.csproj PackRezConfiguration --skip --headless - - TestRez: - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v4 + dotnet-version: '10.0.x' + - uses: actions/setup-dotnet@v4 with: - fetch-depth: 0 + dotnet-version: '8.0.x' - uses: actions/setup-dotnet@v4 with: dotnet-version: '9.0.x' - - name: TestRez - id: TestRez - run: dotnet run --project _atom/_atom.csproj TestRez --skip --headless - - - name: Upload DecSm.Rez.UnitTests - uses: actions/upload-artifact@v4 - with: - name: DecSm.Rez.UnitTests - path: "${{ github.workspace }}/.github/publish/DecSm.Rez.UnitTests" + - name: Test + id: Test + run: dotnet run --project _atom/_atom.csproj Test --skip --headless + env: + job-runs-on: ${{ matrix.job-runs-on }} + test-framework: ${{ matrix.test-framework }} + build-slice: ${{ matrix.job-runs-on }}-${{ matrix.test-framework }} diff --git a/.gitignore b/.gitignore index aa9a516..cbf5f8f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,3 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. -## -## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore - # Atom atom-publish @@ -399,4 +394,8 @@ FodyWeavers.xsd *.msp # JetBrains Rider -*.sln.iml \ No newline at end of file +*.sln.iml +.idea + +# VS Code +.vscode/ \ No newline at end of file diff --git a/DecSm.Rez.Configuration/DecSm.Rez.Configuration.csproj b/DecSm.Rez.Configuration/DecSm.Rez.Configuration.csproj index b7b09b6..f01ef35 100644 --- a/DecSm.Rez.Configuration/DecSm.Rez.Configuration.csproj +++ b/DecSm.Rez.Configuration/DecSm.Rez.Configuration.csproj @@ -1,19 +1,19 @@ - net9.0;net8.0;netstandard2.0 + net10.0;net9.0;net8.0;net48;netstandard2.0 - - - + + + - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -21,15 +21,11 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/DecSm.Rez.Configuration/IResolvableConfig.cs b/DecSm.Rez.Configuration/IResolvableConfig.cs index 72f52e8..498c7f7 100644 --- a/DecSm.Rez.Configuration/IResolvableConfig.cs +++ b/DecSm.Rez.Configuration/IResolvableConfig.cs @@ -4,7 +4,7 @@ namespace DecSm.Rez.Configuration; [PublicAPI] public interface IResolvableConfig : IConfigurationRoot { - public IResolver Resolver { get; } + IResolver Resolver { get; } - public string? Resolve(string? value); + string? Resolve(string? value); } diff --git a/DecSm.Rez.Configuration/ResolvableConfigurationSection.cs b/DecSm.Rez.Configuration/ResolvableConfigurationSection.cs index ab9ecf4..774bc78 100644 --- a/DecSm.Rez.Configuration/ResolvableConfigurationSection.cs +++ b/DecSm.Rez.Configuration/ResolvableConfigurationSection.cs @@ -2,7 +2,8 @@ namespace DecSm.Rez.Configuration; /// [UsedImplicitly] -internal sealed class ResolvableConfigurationSection(IConfigurationSection target, IResolver resolver) : IConfigurationSection +internal sealed class ResolvableConfigurationSection(IConfigurationSection target, IResolver resolver) + : IConfigurationSection { public IConfigurationSection GetSection(string key) => new ResolvableConfigurationSection(target.GetSection(key), resolver); diff --git a/DecSm.Rez.Configuration/Setup.cs b/DecSm.Rez.Configuration/Setup.cs index 4844e14..af7958c 100644 --- a/DecSm.Rez.Configuration/Setup.cs +++ b/DecSm.Rez.Configuration/Setup.cs @@ -5,5 +5,6 @@ public static class Setup { public static IServiceCollection AddResolvableConfiguration(this IServiceCollection services) => services.AddSingleton(x => - new ResolvableConfigurationRoot(x.GetRequiredService(), x.GetRequiredService())); + new ResolvableConfigurationRoot(x.GetRequiredService(), + x.GetRequiredService())); } diff --git a/DecSm.Rez.UnitTests/Compiler/ExecutorTests.cs b/DecSm.Rez.Tests/Compiler/ExecutorTests.cs similarity index 98% rename from DecSm.Rez.UnitTests/Compiler/ExecutorTests.cs rename to DecSm.Rez.Tests/Compiler/ExecutorTests.cs index f33af99..59ae556 100644 --- a/DecSm.Rez.UnitTests/Compiler/ExecutorTests.cs +++ b/DecSm.Rez.Tests/Compiler/ExecutorTests.cs @@ -1,4 +1,4 @@ -namespace DecSm.Rez.UnitTests.Compiler; +namespace DecSm.Rez.Tests.Compiler; [TestFixture] [SuppressMessage("ReSharper", "ConvertToLocalFunction")] diff --git a/DecSm.Rez.UnitTests/Compiler/LexerTests.cs b/DecSm.Rez.Tests/Compiler/LexerTests.cs similarity index 99% rename from DecSm.Rez.UnitTests/Compiler/LexerTests.cs rename to DecSm.Rez.Tests/Compiler/LexerTests.cs index 98eb40c..14d6d2a 100644 --- a/DecSm.Rez.UnitTests/Compiler/LexerTests.cs +++ b/DecSm.Rez.Tests/Compiler/LexerTests.cs @@ -1,4 +1,4 @@ -namespace DecSm.Rez.UnitTests.Compiler; +namespace DecSm.Rez.Tests.Compiler; [TestFixture] public class LexerTests diff --git a/DecSm.Rez.UnitTests/Compiler/RendererTests.cs b/DecSm.Rez.Tests/Compiler/RendererTests.cs similarity index 95% rename from DecSm.Rez.UnitTests/Compiler/RendererTests.cs rename to DecSm.Rez.Tests/Compiler/RendererTests.cs index 7797f23..f8cd561 100644 --- a/DecSm.Rez.UnitTests/Compiler/RendererTests.cs +++ b/DecSm.Rez.Tests/Compiler/RendererTests.cs @@ -1,4 +1,4 @@ -namespace DecSm.Rez.UnitTests.Compiler; +namespace DecSm.Rez.Tests.Compiler; [TestFixture] public class RendererTests @@ -25,7 +25,10 @@ public void Render_Literal_Multiple() { const string inputText = "literalliteralliteral"; - Span tokens = [SyntaxToken.CreateLiteral(0, 7), SyntaxToken.CreateLiteral(7, 7), SyntaxToken.CreateLiteral(14, 7)]; + Span tokens = + [ + SyntaxToken.CreateLiteral(0, 7), SyntaxToken.CreateLiteral(7, 7), SyntaxToken.CreateLiteral(14, 7), + ]; Span outputText = stackalloc char[inputText.Length * 3]; var resolution = new Func(_ => "resolved"); diff --git a/DecSm.Rez.UnitTests/Compiler/TokenizerTests.cs b/DecSm.Rez.Tests/Compiler/TokenizerTests.cs similarity index 99% rename from DecSm.Rez.UnitTests/Compiler/TokenizerTests.cs rename to DecSm.Rez.Tests/Compiler/TokenizerTests.cs index 20b4b78..bb4184c 100644 --- a/DecSm.Rez.UnitTests/Compiler/TokenizerTests.cs +++ b/DecSm.Rez.Tests/Compiler/TokenizerTests.cs @@ -1,4 +1,4 @@ -namespace DecSm.Rez.UnitTests.Compiler; +namespace DecSm.Rez.Tests.Compiler; [TestFixture] public class TokenizerTests diff --git a/DecSm.Rez.UnitTests/DecSm.Rez.UnitTests.csproj b/DecSm.Rez.Tests/DecSm.Rez.Tests.csproj similarity index 79% rename from DecSm.Rez.UnitTests/DecSm.Rez.UnitTests.csproj rename to DecSm.Rez.Tests/DecSm.Rez.Tests.csproj index 4423978..dbbb363 100644 --- a/DecSm.Rez.UnitTests/DecSm.Rez.UnitTests.csproj +++ b/DecSm.Rez.Tests/DecSm.Rez.Tests.csproj @@ -1,7 +1,7 @@  - net9.0 + net10.0;net9.0;net8.0;net48 false @@ -15,9 +15,9 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + - + @@ -27,19 +27,15 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/DecSm.Rez.UnitTests/Implementation/RezzSourceTests.cs b/DecSm.Rez.Tests/Implementation/RezzSourceTests.cs similarity index 93% rename from DecSm.Rez.UnitTests/Implementation/RezzSourceTests.cs rename to DecSm.Rez.Tests/Implementation/RezzSourceTests.cs index 05ec51b..71ab870 100644 --- a/DecSm.Rez.UnitTests/Implementation/RezzSourceTests.cs +++ b/DecSm.Rez.Tests/Implementation/RezzSourceTests.cs @@ -1,4 +1,4 @@ -namespace DecSm.Rez.UnitTests.Implementation; +namespace DecSm.Rez.Tests.Implementation; [TestFixture] public class RezzSourceTests @@ -22,7 +22,8 @@ public void Constructor_NullSource_Throws() Should.Throw(() => new ResolverSource((IEnumerable>)null!)); - Should.Throw(() => new ResolverSource((IEnumerable>>)null!)); + Should.Throw(() => + new ResolverSource((IEnumerable>>)null!)); } [Test] diff --git a/DecSm.Rez.UnitTests/Implementation/RezzStoreTests.cs b/DecSm.Rez.Tests/Implementation/RezzStoreTests.cs similarity index 96% rename from DecSm.Rez.UnitTests/Implementation/RezzStoreTests.cs rename to DecSm.Rez.Tests/Implementation/RezzStoreTests.cs index b381f87..49135b1 100644 --- a/DecSm.Rez.UnitTests/Implementation/RezzStoreTests.cs +++ b/DecSm.Rez.Tests/Implementation/RezzStoreTests.cs @@ -1,4 +1,4 @@ -namespace DecSm.Rez.UnitTests.Implementation; +namespace DecSm.Rez.Tests.Implementation; [TestFixture] public class RezzStoreTests diff --git a/DecSm.Rez.UnitTests/Implementation/RezzerTests.cs b/DecSm.Rez.Tests/Implementation/RezzerTests.cs similarity index 94% rename from DecSm.Rez.UnitTests/Implementation/RezzerTests.cs rename to DecSm.Rez.Tests/Implementation/RezzerTests.cs index 9b7c8d4..e2c7425 100644 --- a/DecSm.Rez.UnitTests/Implementation/RezzerTests.cs +++ b/DecSm.Rez.Tests/Implementation/RezzerTests.cs @@ -1,4 +1,4 @@ -namespace DecSm.Rez.UnitTests.Implementation; +namespace DecSm.Rez.Tests.Implementation; [TestFixture] public class RezzerTests @@ -68,7 +68,9 @@ public void Resolve_NestedVariableReference_Returns_Value() resolver.AddSource(new ResolverSource(new KeyValuePair[] { - new("variableName1", "variableName2"), new("variableName2", "variableName3"), new("variableName3", "value"), + new("variableName1", "variableName2"), + new("variableName2", "variableName3"), + new("variableName3", "value"), })); var result = resolver.Resolve("prefix_{{{variableName1}}}_postfix"); @@ -111,7 +113,8 @@ public void Resolve_MultipleFunctionReferences_Returns_Value() : string.Empty), })); - var result = resolver.Resolve("prefix_{functionName1(correctParam)}_middle_{functionName2(correctParam)}_postfix"); + var result = + resolver.Resolve("prefix_{functionName1(correctParam)}_middle_{functionName2(correctParam)}_postfix"); result.ShouldBe("prefix_value1_middle_value2_postfix"); } @@ -188,7 +191,8 @@ public void Resolve_FunctionReferenceWithNestedVariableReference_Returns_Value() { var resolver = new Resolver(); - resolver.AddSource(new ResolverSource([new("variableName1", "{variableName2}"), new("variableName2", "correctParam")], + resolver.AddSource(new ResolverSource( + [new("variableName1", "{variableName2}"), new("variableName2", "correctParam")], new List>> { new("functionName", diff --git a/DecSm.Rez.UnitTests/_usings.cs b/DecSm.Rez.Tests/_usings.cs similarity index 100% rename from DecSm.Rez.UnitTests/_usings.cs rename to DecSm.Rez.Tests/_usings.cs diff --git a/DecSm.Rez.sln b/DecSm.Rez.sln deleted file mode 100644 index fecb52e..0000000 --- a/DecSm.Rez.sln +++ /dev/null @@ -1,36 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DecSm.Rez", "DecSm.Rez\DecSm.Rez.csproj", "{43E6486E-5DE5-4C00-A634-81A8A16184DE}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DecSm.Rez.Configuration", "DecSm.Rez.Configuration\DecSm.Rez.Configuration.csproj", "{F87639BF-B5CB-4BB8-AA8F-F6D01BF780BA}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "_atom", "_atom\_atom.csproj", "{24AC005C-BA33-446B-AEC8-FE3316E690E6}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DecSm.Rez.UnitTests", "DecSm.Rez.UnitTests\DecSm.Rez.UnitTests.csproj", "{36B970B7-BF7B-4CB7-B2BC-310CA38913AF}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {43E6486E-5DE5-4C00-A634-81A8A16184DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {43E6486E-5DE5-4C00-A634-81A8A16184DE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {43E6486E-5DE5-4C00-A634-81A8A16184DE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {43E6486E-5DE5-4C00-A634-81A8A16184DE}.Release|Any CPU.Build.0 = Release|Any CPU - {F87639BF-B5CB-4BB8-AA8F-F6D01BF780BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F87639BF-B5CB-4BB8-AA8F-F6D01BF780BA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F87639BF-B5CB-4BB8-AA8F-F6D01BF780BA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F87639BF-B5CB-4BB8-AA8F-F6D01BF780BA}.Release|Any CPU.Build.0 = Release|Any CPU - {24AC005C-BA33-446B-AEC8-FE3316E690E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {24AC005C-BA33-446B-AEC8-FE3316E690E6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {24AC005C-BA33-446B-AEC8-FE3316E690E6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {24AC005C-BA33-446B-AEC8-FE3316E690E6}.Release|Any CPU.Build.0 = Release|Any CPU - {36B970B7-BF7B-4CB7-B2BC-310CA38913AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {36B970B7-BF7B-4CB7-B2BC-310CA38913AF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {36B970B7-BF7B-4CB7-B2BC-310CA38913AF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {36B970B7-BF7B-4CB7-B2BC-310CA38913AF}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - EndGlobalSection -EndGlobal diff --git a/DecSm.Rez.slnx b/DecSm.Rez.slnx new file mode 100644 index 0000000..8369302 --- /dev/null +++ b/DecSm.Rez.slnx @@ -0,0 +1,6 @@ + + + + + + diff --git a/DecSm.Rez/Compiler/Executor.cs b/DecSm.Rez/Compiler/Executor.cs index ade2a45..ef98cec 100644 --- a/DecSm.Rez/Compiler/Executor.cs +++ b/DecSm.Rez/Compiler/Executor.cs @@ -48,7 +48,10 @@ internal static class Executor var lexemeLength = Lexer.Lex(sourceBuffer[..inputLength], lexemeBuffer); var tokenLength = Tokenizer.TokenizeLexemes(lexemeBuffer[..lexemeLength], tokenBuffer); - outputLength = Renderer.Render(tokenBuffer[..tokenLength], sourceBuffer[..inputLength], destBuffer, resolution); + outputLength = Renderer.Render(tokenBuffer[..tokenLength], + sourceBuffer[..inputLength], + destBuffer, + resolution); swapBuffer = !swapBuffer; diff --git a/DecSm.Rez/Compiler/Lexer.cs b/DecSm.Rez/Compiler/Lexer.cs index ea789cd..3e44dbb 100644 --- a/DecSm.Rez/Compiler/Lexer.cs +++ b/DecSm.Rez/Compiler/Lexer.cs @@ -20,6 +20,7 @@ public static int Lex(ReadOnlySpan input, Span output) continue; } + case '{' when !escaped: { if (workingIndex > checkpointIndex) @@ -31,6 +32,7 @@ public static int Lex(ReadOnlySpan input, Span output) continue; } + case '}' when !escaped: { if (workingIndex > checkpointIndex) @@ -42,6 +44,7 @@ public static int Lex(ReadOnlySpan input, Span output) continue; } + default: { escaped = false; diff --git a/DecSm.Rez/DecSm.Rez.csproj b/DecSm.Rez/DecSm.Rez.csproj index 3ac515b..ab77b91 100644 --- a/DecSm.Rez/DecSm.Rez.csproj +++ b/DecSm.Rez/DecSm.Rez.csproj @@ -1,17 +1,17 @@ - net9.0;net8.0;netstandard2.0 + net10.0;net9.0;net8.0;net48;netstandard2.0 - + - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -21,15 +21,11 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/DecSm.Rez/Implementation/ResolverSource.cs b/DecSm.Rez/Implementation/ResolverSource.cs index 9f31235..76915bf 100644 --- a/DecSm.Rez/Implementation/ResolverSource.cs +++ b/DecSm.Rez/Implementation/ResolverSource.cs @@ -7,7 +7,9 @@ public sealed class ResolverSource : IResolverSource private readonly Dictionary> _functions; private readonly Dictionary _variables; - public ResolverSource(Dictionary variables, Dictionary> functions) + public ResolverSource( + Dictionary variables, + Dictionary> functions) { _variables = variables ?? throw new ArgumentNullException(nameof(variables)); _functions = functions ?? throw new ArgumentNullException(nameof(functions)); diff --git a/DecSm.Rez/_usings.cs b/DecSm.Rez/_usings.cs index 2aa3c02..7cfb9d1 100644 --- a/DecSm.Rez/_usings.cs +++ b/DecSm.Rez/_usings.cs @@ -6,4 +6,4 @@ global using JetBrains.Annotations; global using System.Runtime.CompilerServices; -[assembly: InternalsVisibleTo("DecSm.Rez.UnitTests")] +[assembly: InternalsVisibleTo("DecSm.Rez.Tests")] diff --git a/Directory.Build.props b/Directory.Build.props index 7702375..f7f7267 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -10,11 +10,11 @@ true true - 13 + 14 enable enable true - $(NoWarn);CS1591;NU5104;RCS1001;RCS1003;RCS1123; + $(NoWarn);CA1873;CS1591;NU5104;RCS1001;RCS1003;RCS1123; diff --git a/GitVersion.yml b/GitVersion.yml index ed21eb1..8926f0c 100644 --- a/GitVersion.yml +++ b/GitVersion.yml @@ -1,121 +1,113 @@ -assembly-versioning-scheme: MajorMinorPatch -assembly-file-versioning-scheme: MajorMinorPatch -assembly-informational-format: '{Major}.{Minor}.{Patch}{PreReleaseTagWithDash}' -assembly-file-versioning-format: '{Major}.{Minor}.{Patch}.{PreReleaseNumber}' +assembly-informational-format: '{Major}.{Minor}.{Patch}{PreReleaseTagWithDash}' +assembly-file-versioning-format: '{Major}.{Minor}.{Patch}.{WeightedPreReleaseNumber ?? 0}' +mode: ContinuousDelivery tag-prefix: '[vV]?' -version-in-branch-pattern: (?[vV]?\d+(\.\d+)?(\.\d+)?).* -next-version: 1.0.0 + major-version-bump-message: '^(breaking|major)\(?[A-Za-z0-9\-]*\)?:' minor-version-bump-message: '^(feat|feature|minor)\(?[A-Za-z0-9\-]*\)?:' patch-version-bump-message: '^(fix|patch)\(?[A-Za-z0-9\-]*\)?:' no-bump-message: '^(semver-none|semver-skip)' -tag-pre-release-weight: 60000 -commit-date-format: yyyy-MM-dd -merge-message-formats: { } -update-build-number: true -semantic-version-format: Strict -strategies: - - Fallback - - ConfiguredNextVersion - - MergeMessage - - TaggedCommit - - TrackReleaseBranches - - VersionInBranchName + +# Tagged releases get the highest band +tag-pre-release-weight: 6000 + branches: - main: - label: 'rc' - increment: Minor - prevent-increment: - of-merged-branch: true - track-merge-target: false - track-merge-message: true - regex: ^master$|^main$ - source-branches: [ ] - is-source-branch-for: [ ] - tracks-release-branches: false - is-release-branch: false - is-main-branch: true - pre-release-weight: 40000 - develop: - mode: ContinuousDelivery - label: 'preview' - increment: Minor - prevent-increment: - when-current-commit-tagged: false - track-merge-target: true - track-merge-message: true - regex: ^dev(elop)?(ment)?$ - source-branches: - - main - is-source-branch-for: [ ] - tracks-release-branches: true - is-release-branch: false - is-main-branch: false - pre-release-weight: 30000 - pull-request: - mode: ContinuousDelivery - label: 'pr' - increment: Inherit - prevent-increment: - of-merged-branch: true - when-current-commit-tagged: false - track-merge-message: true - regex: ^(pull|pull\-requests|pr)[/-] - source-branches: - - main - - develop - is-source-branch-for: [ ] - pre-release-weight: 20000 - beta-minor: - mode: ContinuousDelivery - label: beta.{BranchName} - increment: Minor - prevent-increment: - when-current-commit-tagged: false - track-merge-target: true - track-merge-message: true - regex: ^(feat|feature|features|improvement|chore)?[/-](?.+) - source-branches: - - main - - develop - is-source-branch-for: [ ] - tracks-release-branches: true - is-release-branch: false - is-main-branch: false - pre-release-weight: 10000 - beta-patch: - mode: ContinuousDelivery - label: beta.{BranchName} - increment: Patch - prevent-increment: - when-current-commit-tagged: false - track-merge-target: true - track-merge-message: true - regex: ^(fix|bugfix|hotfix|patch)?[/-](?.+) - source-branches: - - main - - develop - is-source-branch-for: [ ] - tracks-release-branches: true - is-release-branch: false - is-main-branch: false - pre-release-weight: 10000 - alpha: - mode: ContinuousDelivery - label: alpha.{BranchName} - increment: Minor - prevent-increment: - when-current-commit-tagged: false - track-merge-target: true - track-merge-message: true - regex: (?.+) - source-branches: - - main - - develop - is-source-branch-for: [ ] - tracks-release-branches: true - is-release-branch: false - is-main-branch: false - pre-release-weight: 0 -ignore: - sha: [ ] \ No newline at end of file + + # Prevent default GitFlow configs from matching + feature: + regex: ^$ + release: + regex: ^$ + hotfix: + regex: ^$ + support: + regex: ^$ + + ##################################### + # RELEASE BRANCHES + ##################################### + + patch: + label: 'rc' + increment: Patch + prevent-increment: + of-merged-branch: true + when-current-commit-tagged: true + track-merge-target: false + track-merge-message: true + regex: ^patch[/-] + is-release-branch: true + is-main-branch: false + pre-release-weight: 5000 # 5,000–5,999 + + main: + label: 'rc' + increment: Minor + prevent-increment: + of-merged-branch: true + track-merge-target: false + track-merge-message: true + regex: ^master$|^main$ + is-release-branch: false + is-main-branch: true + pre-release-weight: 4000 # 4,000–4,999 + + ##################################### + # MAINLINE BRANCHES + ##################################### + + develop: + label: 'preview' + increment: Minor + prevent-increment: + when-current-commit-tagged: false + track-merge-target: true + track-merge-message: true + regex: ^dev(elop)?(ment)?$ + is-release-branch: false + is-main-branch: false + pre-release-weight: 3000 # 3,000–3,999 + + ##################################### + # FEATURE BRANCHES + ##################################### + + beta-minor: + label: beta.{BranchType}-{BranchName} + increment: Minor + prevent-increment: + when-current-commit-tagged: false + track-merge-target: true + track-merge-message: true + regex: ^(?chore|feat|feature|features|fix|improvement|refactor)[/-](?.+) + is-release-branch: false + is-main-branch: false + pre-release-weight: 2000 # 2,000–2,999 + + ##################################### + # OTHER + ##################################### + + alpha: + label: alpha.{BranchName} + increment: None + prevent-increment: + when-current-commit-tagged: false + track-merge-target: true + track-merge-message: true + regex: (?.+) + is-release-branch: false + is-main-branch: false + pre-release-weight: 1000 # 1,000–1,999 + + pull-request: + label: 'pr' + increment: Inherit + prevent-increment: + of-merged-branch: true + when-current-commit-tagged: false + track-merge-message: true + regex: ^(pull|pull\-requests|pr)[/-] + is-release-branch: false + is-main-branch: false + pre-release-weight: 0 # 0–999 \ No newline at end of file diff --git a/_atom/Build.cs b/_atom/Build.cs index 1539a33..e532ea9 100644 --- a/_atom/Build.cs +++ b/_atom/Build.cs @@ -2,46 +2,79 @@ [BuildDefinition] [GenerateEntryPoint] -internal partial class Build : DefaultBuildDefinition, IGithubWorkflows, IGitVersion, ITargets +[GenerateSolutionModel] +internal partial class Build : BuildDefinition, IGithubWorkflows, IGitVersion, ITargets { + public static readonly string[] PlatformNames = + [ + IJobRunsOn.WindowsLatestTag, IJobRunsOn.UbuntuLatestTag, IJobRunsOn.MacOsLatestTag, + ]; + + public static readonly string[] FrameworkNames = ["net8.0", "net9.0", "net10.0"]; + + private static readonly MatrixDimension TestFrameworkMatrix = new(nameof(ITargets.TestFramework)) + { + Values = FrameworkNames, + }; + public override IReadOnlyList GlobalWorkflowOptions => [ - UseGitVersionForBuildId.Enabled, new SetupDotnetStep("9.0.x"), + UseGitVersionForBuildId.Enabled, new SetupDotnetStep("10.0.x"), ]; public override IReadOnlyList Workflows => [ new("Validate") { - Triggers = [GitPullRequestTrigger.IntoMain, ManualTrigger.Empty], + Triggers = [ManualTrigger.Empty, GitPullRequestTrigger.IntoMain], Targets = [ - Targets.SetupBuildInfo, - Targets.PackRez.WithSuppressedArtifactPublishing, - Targets.PackRezConfiguration.WithSuppressedArtifactPublishing, - Targets.TestRez, + WorkflowTargets.SetupBuildInfo.WithSuppressedArtifactPublishing, + WorkflowTargets.Pack.WithSuppressedArtifactPublishing, + WorkflowTargets + .Test + .WithSuppressedArtifactPublishing + .WithGithubRunnerMatrix(PlatformNames) + .WithMatrixDimensions(TestFrameworkMatrix) + .WithOptions(new SetupDotnetStep("8.0.x"), new SetupDotnetStep("9.0.x")), ], WorkflowTypes = [Github.WorkflowType], + Options = [GithubTokenPermissionsOption.NoneAll], }, new("Build") { - Triggers = [GitPushTrigger.ToMain, GithubReleaseTrigger.OnReleased, ManualTrigger.Empty], + Triggers = + [ + ManualTrigger.Empty, + new GitPushTrigger + { + IncludedBranches = ["main", "feature/**", "patch/**"], + }, + GithubReleaseTrigger.OnReleased, + ], Targets = [ - Targets.SetupBuildInfo, - Targets.PackRez, - Targets.PackRezConfiguration, - Targets.TestRez, - Targets.PushToNuget.WithOptions(WorkflowSecretInjection.Create(Params.NugetApiKey)), - Targets + WorkflowTargets.SetupBuildInfo, + WorkflowTargets.Pack, + WorkflowTargets + .Test + .WithGithubRunnerMatrix(PlatformNames) + .WithMatrixDimensions(TestFrameworkMatrix) + .WithOptions(new SetupDotnetStep("8.0.x"), new SetupDotnetStep("9.0.x")), + WorkflowTargets.PushToNuget.WithOptions(WorkflowSecretInjection.Create(Params.NugetApiKey)), + WorkflowTargets .PushToRelease - .WithGithubTokenInjection() - .WithOptions(GithubIf.Create(new ConsumedVariableExpression(nameof(Targets.SetupBuildInfo), - ParamDefinitions[nameof(ISetupBuildInfo.BuildVersion)].ArgName) + .WithGithubTokenInjection(new() + { + Contents = GithubTokenPermission.Write, + }) + .WithOptions(GithubIf.Create(new ConsumedVariableExpression(nameof(ISetupBuildInfo.SetupBuildInfo), + ParamDefinitions[nameof(IBuildInfo.BuildVersion)].ArgName) .Contains(new StringExpression("-")) .EqualTo("false"))), ], WorkflowTypes = [Github.WorkflowType], + Options = [GithubTokenPermissionsOption.NoneAll], }, Github.DependabotDefaultWorkflow(), ]; diff --git a/_atom/ITargets.cs b/_atom/ITargets.cs index f436ce8..ba538be 100644 --- a/_atom/ITargets.cs +++ b/_atom/ITargets.cs @@ -1,39 +1,48 @@ -namespace Atom; +namespace Atom; -[PublicAPI] internal interface ITargets : IDotnetPackHelper, IDotnetTestHelper, INugetHelper, IGithubReleaseHelper, ISetupBuildInfo { - const string RezProjectName = "DecSm.Rez"; - const string RezConfigurationProjectName = "DecSm.Rez.Configuration"; - const string RezTestProjectName = "DecSm.Rez.UnitTests"; + static readonly string[] ProjectsToPack = [Projects.DecSm_Rez.Name, Projects.DecSm_Rez_Configuration.Name]; + static readonly string[] ProjectsToTest = [Projects.DecSm_Rez_Tests.Name]; - [ParamDefinition("nuget-push-feed", "The Nuget feed to push to.", "https://api.nuget.org/v3/index.json")] + [ParamDefinition("test-framework", "Test framework to use for unit tests")] + string TestFramework => GetParam(() => TestFramework, "net10.0"); + + [ParamDefinition("nuget-push-feed", "The Nuget feed to push to.")] string NugetFeed => GetParam(() => NugetFeed, "https://api.nuget.org/v3/index.json"); [SecretDefinition("nuget-push-api-key", "The API key to use to push to Nuget.")] string? NugetApiKey => GetParam(() => NugetApiKey); - Target PackRez => - d => d - .DescribedAs("Builds the DecSm.Rez project into a NuGet package") - .ProducesArtifact(RezProjectName) - .Executes(async () => await DotnetPackProject(new(RezProjectName))); - - Target PackRezConfiguration => - d => d - .DescribedAs("Builds the DecSm.Rez.Configuration project into a NuGet package") - .ProducesArtifact(RezConfigurationProjectName) - .Executes(async () => await DotnetPackProject(new(RezConfigurationProjectName))); + Target Pack => + t => t + .DescribedAs("Packs NuGet packages") + .ProducesArtifacts(ProjectsToPack) + .Executes(async cancellationToken => + { + foreach (var projectName in ProjectsToPack) + await DotnetPackAndStage(projectName, cancellationToken: cancellationToken); + }); - Target TestRez => + Target Test => d => d - .DescribedAs("Runs the DecSm.Rez.UnitTests tests") - .ProducesArtifact(RezTestProjectName) - .Executes(async () => + .DescribedAs("Runs all unit tests") + .RequiresParam(nameof(TestFramework)) + .ProducesArtifacts(ProjectsToTest) + .Executes(async cancellationToken => { var exitCode = 0; - exitCode += await RunDotnetUnitTests(new(RezTestProjectName)); + foreach (var projectName in ProjectsToTest) + exitCode += await DotnetTestAndStage(projectName, + new() + { + TestOptions = new() + { + Framework = TestFramework, + }, + }, + cancellationToken); if (exitCode != 0) throw new StepFailedException("One or more unit tests failed"); @@ -41,35 +50,29 @@ internal interface ITargets : IDotnetPackHelper, IDotnetTestHelper, INugetHelper Target PushToNuget => d => d - .DescribedAs("Pushes the Atom projects to Nuget") - .RequiresParam(nameof(NugetFeed)) - .RequiresParam(nameof(NugetApiKey)) - .ConsumesArtifact(nameof(PackRez), RezProjectName) - .ConsumesArtifact(nameof(PackRezConfiguration), RezConfigurationProjectName) - .Executes(async () => + .DescribedAs("Pushes packages to Nuget") + .RequiresParam(nameof(NugetFeed), nameof(NugetApiKey)) + .ConsumesArtifacts(nameof(Pack), ProjectsToPack) + .DependsOn(nameof(Test)) + .Executes(async cancellationToken => { - await PushProject(RezProjectName, NugetFeed, NugetApiKey!); - await PushProject(RezConfigurationProjectName, NugetFeed, NugetApiKey!); + foreach (var projectName in ProjectsToPack) + await PushProject(projectName, NugetFeed, NugetApiKey!, cancellationToken: cancellationToken); }); Target PushToRelease => d => d - .DescribedAs("Pushes the package to the release feed.") + .DescribedAs("Pushes artifacts to a GitHub release") .RequiresParam(nameof(GithubToken)) .ConsumesVariable(nameof(SetupBuildInfo), nameof(BuildVersion)) - .ConsumesArtifact(nameof(PackRez), RezProjectName) - .ConsumesArtifact(nameof(PackRezConfiguration), RezConfigurationProjectName) + .RequiresParam(nameof(NugetFeed), nameof(NugetApiKey)) + .ConsumesArtifacts(nameof(Pack), ProjectsToPack) + .ConsumesArtifacts(nameof(Test), + ProjectsToTest, + PlatformNames.SelectMany(platform => FrameworkNames.Select(framework => $"{platform}-{framework}"))) .Executes(async () => { - if (BuildVersion.IsPreRelease) - { - Logger.LogInformation("Skipping release push for pre-release version"); - - return; - } - - var releaseTag = $"v{BuildVersion}"; - await UploadArtifactToRelease(RezProjectName, releaseTag); - await UploadArtifactToRelease(RezConfigurationProjectName, releaseTag); + foreach (var projectName in ProjectsToPack.Concat(ProjectsToTest)) + await UploadArtifactToRelease(projectName, $"v{BuildVersion}"); }); } diff --git a/_atom/_atom.csproj b/_atom/_atom.csproj index 1d3d5a0..4222fa2 100644 --- a/_atom/_atom.csproj +++ b/_atom/_atom.csproj @@ -1,25 +1,25 @@  - net9.0 + net10.0 Atom - - - - + + + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/_atom/_usings.cs b/_atom/_usings.cs index 87a14f8..65b075a 100644 --- a/_atom/_usings.cs +++ b/_atom/_usings.cs @@ -1,13 +1 @@ -global using DecSm.Atom; -global using DecSm.Atom.Build.Definition; -global using DecSm.Atom.Hosting; -global using DecSm.Atom.Module.Dotnet; -global using DecSm.Atom.Module.GithubWorkflows; -global using DecSm.Atom.Module.GithubWorkflows.Generation.Options; -global using DecSm.Atom.Module.GitVersion; -global using DecSm.Atom.Params; -global using DecSm.Atom.Workflows.Definition; -global using DecSm.Atom.Workflows.Definition.Options; -global using DecSm.Atom.Workflows.Definition.Triggers; -global using DecSm.Atom.Workflows.Options; -global using JetBrains.Annotations; +global using DecSm.Atom.Module.Dotnet.Helpers; diff --git a/global.json b/global.json index 941e7a1..87c3416 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "9.0.0", + "version": "10.0.0", "rollForward": "latestMajor", "allowPrerelease": false }