From 3ffcda10b7f630ab9266e3f9452467a684f716b2 Mon Sep 17 00:00:00 2001 From: Ivan Maximov Date: Sun, 21 Jan 2024 09:43:58 +0300 Subject: [PATCH] Migrate to GitHub Actions --- .editorconfig | 240 +++++++++++++++++- .github/ISSUE_TEMPLATE/bug_report.md | 17 ++ .github/ISSUE_TEMPLATE/feature_request.md | 14 + .github/codecov.yml | 3 + .github/dependabot.yml | 12 + .github/labeler.yml | 21 ++ .github/workflows/benchmarks.yml | 45 ++++ .github/workflows/codeql-analysis.yml | 39 +++ .github/workflows/label.yml | 21 ++ .github/workflows/publish-preview.yml | 49 ++++ .github/workflows/publish-release.yml | 63 +++++ .github/workflows/stale.yml | 22 ++ .github/workflows/test.yml | 79 ++++++ .gitignore | 199 +-------------- Build.ps1 | 54 ---- Directory.Build.props | 13 - appveyor.yml | 16 -- key.snk => assets/Destructurama.snk | Bin destructurama-attributed.sln | 52 ---- destructurama-attributed.sln.DotSettings | 223 ---------------- global.json | 7 - src/Benchmarks/AttributedBenchmarks.cs | 31 +++ src/Benchmarks/Benchmarks.csproj | 18 ++ src/Benchmarks/Program.cs | 25 ++ src/Benchmarks/combine-bechmarks.csx | 57 +++++ .../AttributedDestructuringTests.cs | 0 .../Destructurama.Attributed.Tests.csproj | 12 +- .../IgnoreNullPropertiesTests.cs | 0 .../LogWithNameAttributedTests.cs | 0 .../MaskedAttributeTests.cs | 0 .../NotLoggedIfDefaultAttributeTests.cs | 0 .../ReplacedAttributeTests.cs | 0 .../Snippets.cs | 0 .../Support/DelegatingSink.cs | 0 .../Support/Extensions.cs | 0 .../Destructurama.Attributed.csproj | 18 +- src/Directory.Build.props | 38 +++ src/destructurama-attributed.sln | 79 ++++++ 38 files changed, 877 insertions(+), 590 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/codecov.yml create mode 100644 .github/dependabot.yml create mode 100644 .github/labeler.yml create mode 100644 .github/workflows/benchmarks.yml create mode 100644 .github/workflows/codeql-analysis.yml create mode 100644 .github/workflows/label.yml create mode 100644 .github/workflows/publish-preview.yml create mode 100644 .github/workflows/publish-release.yml create mode 100644 .github/workflows/stale.yml create mode 100644 .github/workflows/test.yml delete mode 100644 Build.ps1 delete mode 100644 Directory.Build.props delete mode 100644 appveyor.yml rename key.snk => assets/Destructurama.snk (100%) delete mode 100644 destructurama-attributed.sln delete mode 100644 destructurama-attributed.sln.DotSettings delete mode 100644 global.json create mode 100644 src/Benchmarks/AttributedBenchmarks.cs create mode 100644 src/Benchmarks/Benchmarks.csproj create mode 100644 src/Benchmarks/Program.cs create mode 100644 src/Benchmarks/combine-bechmarks.csx rename {test => src}/Destructurama.Attributed.Tests/AttributedDestructuringTests.cs (100%) rename {test => src}/Destructurama.Attributed.Tests/Destructurama.Attributed.Tests.csproj (69%) rename {test => src}/Destructurama.Attributed.Tests/IgnoreNullPropertiesTests.cs (100%) rename {test => src}/Destructurama.Attributed.Tests/LogWithNameAttributedTests.cs (100%) rename {test => src}/Destructurama.Attributed.Tests/MaskedAttributeTests.cs (100%) rename {test => src}/Destructurama.Attributed.Tests/NotLoggedIfDefaultAttributeTests.cs (100%) rename {test => src}/Destructurama.Attributed.Tests/ReplacedAttributeTests.cs (100%) rename {test => src}/Destructurama.Attributed.Tests/Snippets.cs (100%) rename {test => src}/Destructurama.Attributed.Tests/Support/DelegatingSink.cs (100%) rename {test => src}/Destructurama.Attributed.Tests/Support/Extensions.cs (100%) create mode 100644 src/Directory.Build.props create mode 100644 src/destructurama-attributed.sln diff --git a/.editorconfig b/.editorconfig index 536dae9..778e1d6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,27 +1,173 @@ +# EditorConfig is awesome: http://EditorConfig.org + +# Create portable, custom editor settings with EditorConfig +# https://docs.microsoft.com/en-us/visualstudio/ide/create-portable-custom-editor-options + +# .NET coding convention settings for EditorConfig +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference?view=vs-2019 + +# Language conventions +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019 + +# Formatting conventions +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-formatting-conventions?view=vs-2019 + +# .NET naming conventions for EditorConfig +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions?view=vs-2019 + +# Top-most EditorConfig file root = true +# Editor default newlines with a newline ending every file [*] -trim_trailing_whitespace = true insert_final_newline = true +charset = utf-8 indent_style = space +indent_size = 2 +trim_trailing_whitespace = true + +[*.json] +insert_final_newline = false + +[*.cs] indent_size = 4 -charset = utf-8 -end_of_line = lf -[*.{csproj,json,config,yml,props}] -indent_size = 2 +# Do not insert newline for ApiApprovalTests +[*.txt] +insert_final_newline = false -[*.sh] -end_of_line = lf +# Code files +[*.{cs,vb}] -[*.{cmd, bat}] -end_of_line = crlf +# .NET code style settings - "This." and "Me." qualifiers +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#this-and-me +dotnet_style_qualification_for_field = false:warning +dotnet_style_qualification_for_property = false:warning +dotnet_style_qualification_for_method = false:warning +dotnet_style_qualification_for_event = false:warning -# C# formatting settings - Namespace options -csharp_style_namespace_declarations = file_scoped:suggestion +# .NET code style settings - Language keywords instead of framework type names for type references +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#language-keywords +dotnet_style_predefined_type_for_locals_parameters_members = true:error +dotnet_style_predefined_type_for_member_access = true:error + +# .NET code style settings - Modifier preferences +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#normalize-modifiers +dotnet_style_require_accessibility_modifiers = always:warning +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:warning +dotnet_style_readonly_field = true:warning + +# .NET code style settings - Parentheses preferences +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#parentheses-preferences +dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:suggestion +dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:suggestion +dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary:suggestion +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:suggestion + +# .NET code style settings - Expression-level preferences +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#expression-level-preferences +dotnet_style_object_initializer = true:error +dotnet_style_collection_initializer = true:error +dotnet_style_explicit_tuple_names = true:warning +dotnet_style_prefer_inferred_tuple_names = true:suggestion +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion +dotnet_style_prefer_auto_properties = true:warning +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning +dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion +dotnet_style_prefer_conditional_expression_over_return = true:suggestion +dotnet_style_prefer_compound_assignment = true:warning + +# .NET code style settings - Null-checking preferences +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#null-checking-preferences +dotnet_style_coalesce_expression = true:warning +dotnet_style_null_propagation = true:error + +# .NET code quality settings - Parameter preferences +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#parameter-preferences +dotnet_code_quality_unused_parameters = all:warning + +# C# code style settings - Implicit and explicit types +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#implicit-and-explicit-types +csharp_style_var_for_built_in_types = false:suggestion +csharp_style_var_when_type_is_apparent = true:warning +csharp_style_var_elsewhere = true:suggestion + +# C# code style settings - Expression-bodied members +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#expression-bodied-members +csharp_style_expression_bodied_methods = when_on_single_line:suggestion +csharp_style_expression_bodied_constructors = false:warning +csharp_style_expression_bodied_operators = when_on_single_line:warning +csharp_style_expression_bodied_properties = when_on_single_line:warning +csharp_style_expression_bodied_indexers = when_on_single_line:warning +csharp_style_expression_bodied_accessors = when_on_single_line:warning +csharp_style_expression_bodied_lambdas = when_on_single_line:warning +csharp_style_expression_bodied_local_functions = when_on_single_line:warning + +# C# code style settings - Pattern matching +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#pattern-matching +csharp_style_pattern_matching_over_is_with_cast_check = true:error +csharp_style_pattern_matching_over_as_with_null_check = true:error + +# C# code style settings - Inlined variable declaration +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#inlined-variable-declarations +csharp_style_inlined_variable_declaration = true:error + +# C# code style settings - C# expression-level preferences +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#c-expression-level-preferences +csharp_prefer_simple_default_expression = true:suggestion + +# C# code style settings - C# null-checking preferences +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#c-null-checking-preferences +csharp_style_throw_expression = true:warning +csharp_style_conditional_delegate_call = true:warning +# C# code style settings - Code block preferences +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#code-block-preferences +csharp_prefer_braces = when_multiline:suggestion + +# C# code style - Unused value preferences +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#unused-value-preferences +csharp_style_unused_value_expression_statement_preference = discard_variable:suggestion +csharp_style_unused_value_assignment_preference = discard_variable:suggestion + +# C# code style - Index and range preferences +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#index-and-range-preferences +csharp_style_prefer_index_operator = true:warning +csharp_style_prefer_range_operator = true:warning + +# C# code style - Miscellaneous preferences +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#miscellaneous-preferences +csharp_style_deconstructed_variable_declaration = true:suggestion +csharp_style_pattern_local_over_anonymous_function = true:suggestion +csharp_using_directive_placement = outside_namespace:warning +csharp_prefer_static_local_function = true:suggestion +csharp_prefer_simple_using_statement = false:suggestion csharp_style_prefer_switch_expression = true:suggestion +# .NET formatting settings - Organize using directives +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-formatting-conventions?view=vs-2019#organize-using-directives +dotnet_sort_system_directives_first = true +dotnet_separate_import_directive_groups = false + +# C# formatting settings - New-line options +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-formatting-conventions?view=vs-2019#new-line-options +csharp_new_line_before_open_brace = all +csharp_new_line_before_else = true +csharp_new_line_before_catch = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_between_query_expression_clauses = true + +# C# formatting settings - Indentation options +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-formatting-conventions?view=vs-2019#indentation-options +csharp_indent_case_contents = true +csharp_indent_switch_labels = true +csharp_indent_labels = one_less_than_current +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents_when_block = false + # C# formatting settings - Spacing options csharp_space_after_cast = false csharp_space_after_keywords_in_control_flow_statements = true @@ -45,3 +191,75 @@ csharp_space_around_declaration_statements = false csharp_space_before_open_square_brackets = false csharp_space_between_empty_square_brackets = false csharp_space_between_square_brackets = false + +# C# formatting settings - Wrap options +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-formatting-conventions?view=vs-2019#wrap-options +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = false + +# C# formatting settings - Namespace options +csharp_style_namespace_declarations = file_scoped:warning + +########## name all private fields using camelCase with underscore prefix ########## +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions?view=vs-2019 +# dotnet_naming_rule..symbols = +dotnet_naming_rule.private_fields_with_underscore.symbols = private_fields + +# dotnet_naming_symbols.. = +dotnet_naming_symbols.private_fields.applicable_kinds = field +dotnet_naming_symbols.private_fields.applicable_accessibilities = private + +# dotnet_naming_rule..style = +dotnet_naming_rule.private_fields_with_underscore.style = prefix_underscore + +# dotnet_naming_style.. = +dotnet_naming_style.prefix_underscore.capitalization = camel_case +dotnet_naming_style.prefix_underscore.required_prefix = _ + +# dotnet_naming_rule..severity = +dotnet_naming_rule.private_fields_with_underscore.severity = warning + +########## name all constant fields using UPPER_CASE ########## +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions?view=vs-2019 +# dotnet_naming_rule..symbols = +dotnet_naming_rule.constant_fields_should_be_upper_case.symbols = constant_fields + +# dotnet_naming_symbols.. = +dotnet_naming_symbols.constant_fields.applicable_kinds = field +dotnet_naming_symbols.constant_fields.applicable_accessibilities = * +dotnet_naming_symbols.constant_fields.required_modifiers = const + +# dotnet_naming_rule..style = +dotnet_naming_rule.constant_fields_should_be_upper_case.style = upper_case_style + +# dotnet_naming_style.. = +dotnet_naming_style.upper_case_style.capitalization = all_upper +dotnet_naming_style.upper_case_style.word_separator = _ + +# dotnet_naming_rule..severity = +dotnet_naming_rule.constant_fields_should_be_upper_case.severity = warning + +########## Async methods should have "Async" suffix ########## +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions?view=vs-2019 +# dotnet_naming_rule..symbols = +dotnet_naming_rule.async_methods_end_in_async.symbols = any_async_methods + +# dotnet_naming_symbols.. = +dotnet_naming_symbols.any_async_methods.applicable_kinds = method +dotnet_naming_symbols.any_async_methods.applicable_accessibilities = * +dotnet_naming_symbols.any_async_methods.required_modifiers = async + +# dotnet_naming_rule..style = +dotnet_naming_rule.async_methods_end_in_async.style = end_in_async_style + +# dotnet_naming_style.. = +dotnet_naming_style.end_in_async_style.capitalization = pascal_case +dotnet_naming_style.end_in_async_style.word_separator = +dotnet_naming_style.end_in_async_style.required_prefix = +dotnet_naming_style.end_in_async_style.required_suffix = Async + +# dotnet_naming_rule..severity = +dotnet_naming_rule.async_methods_end_in_async.severity = warning + +# Remove unnecessary import https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0005 +dotnet_diagnostic.IDE0005.severity = warning diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..33725c9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,17 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: bug +assignees: sungam3r + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots and any additional context** +If applicable, add screenshots or any other context here to help explain your problem. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..7cbbb73 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,14 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: sungam3r + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. + +**Describe the solution you'd like** +This is optional description of what you want to happen. diff --git a/.github/codecov.yml b/.github/codecov.yml new file mode 100644 index 0000000..877c249 --- /dev/null +++ b/.github/codecov.yml @@ -0,0 +1,3 @@ +# https://docs.codecov.com/docs/codecov-yaml +comment: + behavior: new diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..67d247d --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 +updates: + +- package-ecosystem: "nuget" + directory: "/" + schedule: + interval: "daily" + +- package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000..129462d --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,21 @@ +tests: +- changed-files: + - any-glob-to-any-file: src/Destructurama.Attributed.Tests/**/* + +CI: +- changed-files: + - any-glob-to-any-file: + - .github/workflows/**/* + - .github/dependabot.yml + - .github/codecov.yml + - .github/labeler.yml + +code style: +- changed-files: + - any-glob-to-any-file: + - .editorconfig + +documentation: +- changed-files: + - any-glob-to-any-file: + - README.md diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml new file mode 100644 index 0000000..b10929a --- /dev/null +++ b/.github/workflows/benchmarks.yml @@ -0,0 +1,45 @@ +# https://github.com/benchmark-action/github-action-benchmark +name: Continuous benchmarking +on: + pull_request: + branches: + - master + push: + branches: + - master + +permissions: + contents: write + deployments: write + +jobs: + benchmark: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup .NET SDK + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + + - name: Run benchmarks + working-directory: src/Benchmarks + run: dotnet run -c Release --exporters json --filter '*' + + - name: Combine benchmarks results + working-directory: src/Benchmarks + run: dotnet tool install -g dotnet-script && dotnet script combine-bechmarks.csx + + - name: Store benchmarks results + uses: benchmark-action/github-action-benchmark@v1 + with: + name: Benchmarks + tool: 'benchmarkdotnet' + output-file-path: src/Benchmarks/BenchmarkDotNet.Artifacts/results/Combined.Benchmarks.json + github-token: ${{ secrets.GITHUB_TOKEN }} + alert-threshold: '101%' + comment-on-alert: true + - name: Push benchmarks results + if: github.event_name != 'pull_request' + run: git push 'https://${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git' gh-pages:gh-pages diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..880ece5 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,39 @@ +# https://github.com/github/codeql +# https://github.com/github/codeql-action +name: CodeQL analysis + +on: + push: + branches: [master, dev] + pull_request: + branches: [master, dev] + +jobs: + analyze: + runs-on: ubuntu-latest + + steps: + - name: Checkout source + uses: actions/checkout@v4 + + - name: Setup .NET SDK + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + queries: security-and-quality + languages: csharp + + - name: Install dependencies + working-directory: src + run: dotnet restore + + - name: Build solution + working-directory: src + run: dotnet build --no-restore + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml new file mode 100644 index 0000000..f34d7e1 --- /dev/null +++ b/.github/workflows/label.yml @@ -0,0 +1,21 @@ +# This workflow will triage pull requests and apply a label based on the +# paths that are modified in the pull request. +# +# To use this workflow, you will need to set up a .github/labeler.yml +# file with configuration. For more information, see: +# https://github.com/actions/labeler/blob/master/README.md + +name: Labeler +on: + pull_request_target: + types: + - opened # when PR is opened + +jobs: + label: + runs-on: ubuntu-latest + steps: + - uses: actions/labeler@v5 + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" + continue-on-error: true diff --git a/.github/workflows/publish-preview.yml b/.github/workflows/publish-preview.yml new file mode 100644 index 0000000..ceb498a --- /dev/null +++ b/.github/workflows/publish-preview.yml @@ -0,0 +1,49 @@ +name: Publish preview to GitHub registry + +# ==== NOTE: do not rename this yml file or the $GITHUB_RUN_NUMBER will be reset ==== + +on: + push: + branches: + - master + - dev + paths: + - src/** + - .github/workflows/** + +env: + DOTNET_NOLOGO: true + DOTNET_CLI_TELEMETRY_OPTOUT: true + +jobs: + pack: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup .NET SDK + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + source-url: https://nuget.pkg.github.com/destructurama/index.json + env: + NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} + - name: Install dependencies + working-directory: src + run: dotnet restore + - name: Build solution [Release] + working-directory: src + run: dotnet build --no-restore -c Release + - name: Pack solution [Release] + working-directory: src + run: dotnet pack --no-restore -c Release -o out + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: Nuget packages + path: | + src/out/* + - name: Publish Nuget packages to GitHub registry + working-directory: src + run: dotnet nuget push "out/*" -k ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 0000000..b75f83d --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,63 @@ +name: Publish release to Nuget registry + +on: + release: + types: + - published + +env: + DOTNET_NOLOGO: true + DOTNET_CLI_TELEMETRY_OPTOUT: true + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup .NET SDK + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + source-url: https://api.nuget.org/v3/index.json + env: + NUGET_AUTH_TOKEN: ${{secrets.NUGET_AUTH_TOKEN}} + - name: Install dependencies + working-directory: src + run: dotnet restore + - name: Build solution [Release] + working-directory: src + run: dotnet build --no-restore -c Release + - name: Pack solution [Release] + working-directory: src + run: dotnet pack --no-restore --no-build -c Release -o out + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: Nuget packages + path: | + src/out/* + - name: Publish Nuget packages to Nuget registry + working-directory: src + run: dotnet nuget push "out/*" -k ${{secrets.NUGET_AUTH_TOKEN}} + - name: Upload Nuget packages as release artifacts + uses: actions/github-script@v7 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + console.log('environment', process.versions); + const fs = require('fs').promises; + const { repo: { owner, repo }, sha } = context; + + for (let file of await fs.readdir('src/out')) { + console.log('uploading', file); + + await github.rest.repos.uploadReleaseAsset({ + owner, + repo, + release_id: ${{ github.event.release.id }}, + name: file, + data: await fs.readFile(`src/out/${file}`) + }); + } diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000..bd21f4d --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,22 @@ +name: Mark stale issues and pull requests + +on: + schedule: + - cron: "0 0 * * *" + +jobs: + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v9 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + stale-issue-message: 'This issue was marked as stale since it has not been active for a long time' + stale-pr-message: 'This pull request was marked as stale since it has not been active for a long time' + stale-issue-label: 'stale' + stale-pr-label: 'stale' + days-before-stale: 30 + days-before-close: 60 + exempt-issue-label: 'not so stale' + exempt-pr-label: 'not so stale' + operations-per-run: 30 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..51b9ad6 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,79 @@ +name: Run unit tests + +on: + pull_request: + branches: + - master + - dev + paths: + - src/** + - .github/workflows/** + # Upload code coverage results when PRs are merged + push: + branches: + - master + - dev + paths: + - src/** + - .github/workflows/** + +env: + DOTNET_NOLOGO: true + DOTNET_CLI_TELEMETRY_OPTOUT: true + +jobs: + test: + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + name: ${{ matrix.os }} + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup .NET SDKs + uses: actions/setup-dotnet@v4 + with: + dotnet-version: | + 6.0.x + 7.0.x + 8.0.x + source-url: https://nuget.pkg.github.com/destructurama/index.json + env: + NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} + - name: Install dependencies + working-directory: src + run: dotnet restore + - name: Check formatting + if: ${{ startsWith(matrix.os, 'ubuntu') }} + working-directory: src + run: | + dotnet format --no-restore --verify-no-changes --severity warn || (echo "Run 'dotnet format' to fix issues" && exit 1) + - name: Build solution [Release] + working-directory: src + run: dotnet build --no-restore -c Release + - name: Build solution [Debug] + working-directory: src + run: dotnet build --no-restore -c Debug + - name: Test solution [Debug] + working-directory: src + run: dotnet test --no-restore -p:CollectCoverage=true + - name: Upload coverage to codecov + if: ${{ startsWith(matrix.os, 'ubuntu') }} + uses: codecov/codecov-action@v3 + with: + files: .coverage/Destructurama.ByIgnoring.Tests/coverage.net8.opencover.xml + + buildcheck: + needs: + - test + runs-on: ubuntu-latest + if: always() + steps: + - name: Pass build check + if: ${{ needs.test.result == 'success' }} + run: exit 0 + - name: Fail build check + if: ${{ needs.test.result != 'success' }} + run: exit 1 diff --git a/.gitignore b/.gitignore index 0a1348b..e44dd1a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,198 +1,3 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -build/ -bld/ -[Bb]in/ -[Oo]bj/ - -# Visual Studo 2015 cache/options directory .vs/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding addin-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -_NCrunch_* -.*crunch*.local.xml - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# TODO: Comment the next line if you want to checkin your web deploy settings -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/packages/* -# except build/, which is used as an MSBuild target. -!**/packages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/packages/repositories.config - -# Windows Azure Build Output -csx/ -*.build.csdef - -# Windows Store app package directory -AppPackages/ - -# Others -*.[Cc]ache -ClientBin/ -[Ss]tyle[Cc]op.* -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.pfx -*.publishsettings -node_modules/ -bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -*.mdf -*.ldf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings - -# Microsoft Fakes -FakesAssemblies/ - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -.idea/ +obj/ +bin/ diff --git a/Build.ps1 b/Build.ps1 deleted file mode 100644 index 9b92612..0000000 --- a/Build.ps1 +++ /dev/null @@ -1,54 +0,0 @@ -echo "build: Build started" - -Push-Location $PSScriptRoot - -if(Test-Path .\artifacts) { - echo "build: Cleaning .\artifacts" - Remove-Item .\artifacts -Force -Recurse -} - -& dotnet restore --no-cache - -$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL]; -$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL]; -$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "master" -and $revision -ne "local"] -$commitHash = $(git rev-parse --short HEAD) -$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""] - -echo "build: Package version suffix is $suffix" -echo "build: Build version suffix is $buildSuffix" - -foreach ($src in ls src/*) { - Push-Location $src - - echo "build: Packaging project in $src" - - if ($buildSuffix) { - & dotnet build -c Release --version-suffix=$buildSuffix - } else { - & dotnet build -c Release - } - if($LASTEXITCODE -ne 0) { exit 1 } - - if ($suffix) { - & dotnet pack -c Release --include-symbols -o ..\..\artifacts --version-suffix=$suffix --no-build - } else { - & dotnet pack -c Release --include-symbols -o ..\..\artifacts --no-build - } - if($LASTEXITCODE -ne 0) { exit 1 } - - Pop-Location -} - -foreach ($test in ls test/*.Tests) { - Push-Location $test - - echo "build: Testing project in $test" - - & dotnet test -c Release - if($LASTEXITCODE -ne 0) { exit 3 } - - Pop-Location -} - -Pop-Location diff --git a/Directory.Build.props b/Directory.Build.props deleted file mode 100644 index 5d24e03..0000000 --- a/Directory.Build.props +++ /dev/null @@ -1,13 +0,0 @@ - - - - latest - true - embedded - true - $(MSBuildThisFileDirectory)key.snk - false - true - enable - - \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 8fc6156..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,16 +0,0 @@ -version: '{build}' -skip_tags: true -image: Visual Studio 2022 -configuration: Release -test: off -build_script: -- ps: ./Build.ps1 -artifacts: -- path: artifacts/Destructurama.*.nupkg -deploy: -- provider: NuGet - api_key: - secure: Oa5/xyLBrdomUyVn2gbtmAxMHjoR/xlKpLLHWks/uV5YZjEkDEBx73JQtdbsUiL9 - skip_symbols: true - on: - branch: /^(master|dev)$/ diff --git a/key.snk b/assets/Destructurama.snk similarity index 100% rename from key.snk rename to assets/Destructurama.snk diff --git a/destructurama-attributed.sln b/destructurama-attributed.sln deleted file mode 100644 index b59937d..0000000 --- a/destructurama-attributed.sln +++ /dev/null @@ -1,52 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31507.150 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Destructurama.Attributed", "src\Destructurama.Attributed\Destructurama.Attributed.csproj", "{A79F906E-0298-49DC-93EC-CE4F1F5D13E2}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Destructurama.Attributed.Tests", "test\Destructurama.Attributed.Tests\Destructurama.Attributed.Tests.csproj", "{182ECDA3-A97D-4BB6-BC6F-60A137478B92}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "global", "global", "{A195B0EF-8A8C-4B5C-8A9D-743B95C8356A}" - ProjectSection(SolutionItems) = preProject - .gitattributes = .gitattributes - .gitignore = .gitignore - appveyor.yml = appveyor.yml - Build.ps1 = Build.ps1 - CHANGES.md = CHANGES.md - Directory.Build.props = Directory.Build.props - LICENSE = LICENSE - README.md = README.md - global.json = global.json - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{677924A1-EB38-4E04-9D13-3DD4C3C9C514}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{F56115EE-0998-40B3-9FA7-734D83DCF884}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A79F906E-0298-49DC-93EC-CE4F1F5D13E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A79F906E-0298-49DC-93EC-CE4F1F5D13E2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A79F906E-0298-49DC-93EC-CE4F1F5D13E2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A79F906E-0298-49DC-93EC-CE4F1F5D13E2}.Release|Any CPU.Build.0 = Release|Any CPU - {182ECDA3-A97D-4BB6-BC6F-60A137478B92}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {182ECDA3-A97D-4BB6-BC6F-60A137478B92}.Debug|Any CPU.Build.0 = Debug|Any CPU - {182ECDA3-A97D-4BB6-BC6F-60A137478B92}.Release|Any CPU.ActiveCfg = Release|Any CPU - {182ECDA3-A97D-4BB6-BC6F-60A137478B92}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {A79F906E-0298-49DC-93EC-CE4F1F5D13E2} = {677924A1-EB38-4E04-9D13-3DD4C3C9C514} - {182ECDA3-A97D-4BB6-BC6F-60A137478B92} = {F56115EE-0998-40B3-9FA7-734D83DCF884} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {F09D8B7B-37C6-417E-B8DA-296735211A4E} - EndGlobalSection -EndGlobal diff --git a/destructurama-attributed.sln.DotSettings b/destructurama-attributed.sln.DotSettings deleted file mode 100644 index d98a03d..0000000 --- a/destructurama-attributed.sln.DotSettings +++ /dev/null @@ -1,223 +0,0 @@ - - True - True - True - True - False - SOLUTION - DO_NOT_SHOW - DO_NOT_SHOW - DO_NOT_SHOW - ERROR - DO_NOT_SHOW - DO_NOT_SHOW - DO_NOT_SHOW - DO_NOT_SHOW - ERROR - ERROR - WARNING - ERROR - HINT - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - DO_NOT_SHOW - DO_NOT_SHOW - DO_NOT_SHOW - DO_NOT_SHOW - HINT - DO_NOT_SHOW - HINT - ERROR - WARNING - ERROR - ERROR - ERROR - HINT - ERROR - ERROR - ERROR - ERROR - ERROR - WARNING - HINT - ERROR - SUGGESTION - ERROR - ERROR - ERROR - ERROR - SUGGESTION - DO_NOT_SHOW - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - SUGGESTION - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - WARNING - ERROR - ERROR - ERROR - DoHide - DoHide - DoHide - DoHide - DoHide - DoHide - DoHide - DoHide - DoHide - DoHide - DoHide - DoHide - DoHide - DoHide - DoHide - DoHide - DoHide - DoHide - DoHide - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - DO_NOT_SHOW - SUGGESTION - ERROR - HINT - ERROR - ERROR - ERROR - ERROR - HINT - <?xml version="1.0" encoding="utf-16"?><Profile name="Format My Code Using &quot;Particular&quot; conventions"><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSUseVar><BehavourStyle>CAN_CHANGE_TO_IMPLICIT</BehavourStyle><LocalVariableStyle>ALWAYS_IMPLICIT</LocalVariableStyle><ForeachVariableStyle>ALWAYS_IMPLICIT</ForeachVariableStyle></CSUseVar><CSOptimizeUsings><OptimizeUsings>True</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSReformatCode>True</CSReformatCode><CSReorderTypeMembers>True</CSReorderTypeMembers><JsInsertSemicolon>True</JsInsertSemicolon><JsReformatCode>True</JsReformatCode><CssReformatCode>True</CssReformatCode><CSArrangeThisQualifier>True</CSArrangeThisQualifier><RemoveCodeRedundancies>True</RemoveCodeRedundancies><CSUseAutoProperty>True</CSUseAutoProperty><HtmlReformatCode>True</HtmlReformatCode><CSShortenReferences>True</CSShortenReferences><CSharpFormatDocComments>True</CSharpFormatDocComments><CssAlphabetizeProperties>True</CssAlphabetizeProperties></Profile> - Default: Reformat Code - Format My Code Using "Particular" conventions - Implicit - Implicit - False - DO_NOT_CHANGE - DO_NOT_CHANGE - DO_NOT_CHANGE - DO_NOT_CHANGE - DO_NOT_CHANGE - NEVER - False - False - False - CHOP_ALWAYS - False - CHOP_ALWAYS - CHOP_ALWAYS - True - True - CustomLayout - True - False - True - False - False - False - True - Automatic property - True - False - False - False - AD - DB - DTC - GT - ID - NSB - SLA - $object$_On$event$ - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="I" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="T" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - $object$_On$event$ - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="I" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="T" Suffix="" Style="AaBb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> - True - True - True - True - True - True - True - True - True - True - True - True - True - True - True - <data /> - <data><IncludeFilters /><ExcludeFilters /></data> - True - True - True - True - True - True - True - True - \ No newline at end of file diff --git a/global.json b/global.json deleted file mode 100644 index d497446..0000000 --- a/global.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "sdk": { - "version": "7.0.306", - "allowPrerelease": false, - "rollForward": "latestFeature" - } -} diff --git a/src/Benchmarks/AttributedBenchmarks.cs b/src/Benchmarks/AttributedBenchmarks.cs new file mode 100644 index 0000000..5872bfa --- /dev/null +++ b/src/Benchmarks/AttributedBenchmarks.cs @@ -0,0 +1,31 @@ +// Copyright 2017 Serilog Contributors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using BenchmarkDotNet.Attributes; + +namespace Benchmarks; + +public class AttributedBenchmarks +{ + [GlobalSetup] + public void Setup() + { + } + + //[Benchmark] + public void Execute() + { + //TODO: implement + } +} diff --git a/src/Benchmarks/Benchmarks.csproj b/src/Benchmarks/Benchmarks.csproj new file mode 100644 index 0000000..31f21ff --- /dev/null +++ b/src/Benchmarks/Benchmarks.csproj @@ -0,0 +1,18 @@ + + + + Exe + net8.0 + $(NoWarn);1591 + false + + + + + + + + + + + diff --git a/src/Benchmarks/Program.cs b/src/Benchmarks/Program.cs new file mode 100644 index 0000000..f66753c --- /dev/null +++ b/src/Benchmarks/Program.cs @@ -0,0 +1,25 @@ +// Copyright 2017 Serilog Contributors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using BenchmarkDotNet.Configs; +using BenchmarkDotNet.Diagnosers; +using BenchmarkDotNet.Running; +using Benchmarks; + +new AttributedBenchmarks().Setup(); +var config = ManualConfig + .Create(DefaultConfig.Instance) + .AddDiagnoser(MemoryDiagnoser.Default); + +BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args, config); diff --git a/src/Benchmarks/combine-bechmarks.csx b/src/Benchmarks/combine-bechmarks.csx new file mode 100644 index 0000000..f257195 --- /dev/null +++ b/src/Benchmarks/combine-bechmarks.csx @@ -0,0 +1,57 @@ +// Copyright 2017 Serilog Contributors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System.IO; +using System.Linq; +using System.Text.Json.Nodes; + +string resultsDir = "./BenchmarkDotNet.Artifacts/results"; +string resultsFile = "Combined.Benchmarks"; +string searchPattern = "*-report-full-compressed.json"; + +var resultsPath = Path.Combine(resultsDir, resultsFile + ".json"); + +if (!Directory.Exists(resultsDir)) +{ + throw new DirectoryNotFoundException($"Directory not found '{resultsDir}'"); +} + +if (File.Exists(resultsPath)) +{ + File.Delete(resultsPath); +} + +var reports = Directory.GetFiles(resultsDir, searchPattern, SearchOption.TopDirectoryOnly).ToArray(); +if (!reports.Any()) +{ + throw new FileNotFoundException($"Reports not found '{searchPattern}'"); +} + +var combinedReport = JsonNode.Parse(File.ReadAllText(reports.First()))!; +var title = combinedReport["Title"]!; +var benchmarks = combinedReport["Benchmarks"]!.AsArray(); +// Rename title whilst keeping original timestamp +combinedReport["Title"] = $"{resultsFile}{title.GetValue()[^16..]}"; + +foreach (var report in reports.Skip(1)) +{ + var array = JsonNode.Parse(File.ReadAllText(report))!["Benchmarks"]!.AsArray(); + foreach (var benchmark in array) + { + // Double parse avoids "The node already has a parent" exception + benchmarks.Add(JsonNode.Parse(benchmark!.ToJsonString())!); + } +} + +File.WriteAllText(resultsPath, combinedReport.ToString()); diff --git a/test/Destructurama.Attributed.Tests/AttributedDestructuringTests.cs b/src/Destructurama.Attributed.Tests/AttributedDestructuringTests.cs similarity index 100% rename from test/Destructurama.Attributed.Tests/AttributedDestructuringTests.cs rename to src/Destructurama.Attributed.Tests/AttributedDestructuringTests.cs diff --git a/test/Destructurama.Attributed.Tests/Destructurama.Attributed.Tests.csproj b/src/Destructurama.Attributed.Tests/Destructurama.Attributed.Tests.csproj similarity index 69% rename from test/Destructurama.Attributed.Tests/Destructurama.Attributed.Tests.csproj rename to src/Destructurama.Attributed.Tests/Destructurama.Attributed.Tests.csproj index b5abf50..63168b9 100644 --- a/test/Destructurama.Attributed.Tests/Destructurama.Attributed.Tests.csproj +++ b/src/Destructurama.Attributed.Tests/Destructurama.Attributed.Tests.csproj @@ -1,14 +1,20 @@ - + + - net5.0;net48 + net48;net5.0;net6.0;net7.0;net8.0 + false + $(NoWarn);1591 - + + + + diff --git a/test/Destructurama.Attributed.Tests/IgnoreNullPropertiesTests.cs b/src/Destructurama.Attributed.Tests/IgnoreNullPropertiesTests.cs similarity index 100% rename from test/Destructurama.Attributed.Tests/IgnoreNullPropertiesTests.cs rename to src/Destructurama.Attributed.Tests/IgnoreNullPropertiesTests.cs diff --git a/test/Destructurama.Attributed.Tests/LogWithNameAttributedTests.cs b/src/Destructurama.Attributed.Tests/LogWithNameAttributedTests.cs similarity index 100% rename from test/Destructurama.Attributed.Tests/LogWithNameAttributedTests.cs rename to src/Destructurama.Attributed.Tests/LogWithNameAttributedTests.cs diff --git a/test/Destructurama.Attributed.Tests/MaskedAttributeTests.cs b/src/Destructurama.Attributed.Tests/MaskedAttributeTests.cs similarity index 100% rename from test/Destructurama.Attributed.Tests/MaskedAttributeTests.cs rename to src/Destructurama.Attributed.Tests/MaskedAttributeTests.cs diff --git a/test/Destructurama.Attributed.Tests/NotLoggedIfDefaultAttributeTests.cs b/src/Destructurama.Attributed.Tests/NotLoggedIfDefaultAttributeTests.cs similarity index 100% rename from test/Destructurama.Attributed.Tests/NotLoggedIfDefaultAttributeTests.cs rename to src/Destructurama.Attributed.Tests/NotLoggedIfDefaultAttributeTests.cs diff --git a/test/Destructurama.Attributed.Tests/ReplacedAttributeTests.cs b/src/Destructurama.Attributed.Tests/ReplacedAttributeTests.cs similarity index 100% rename from test/Destructurama.Attributed.Tests/ReplacedAttributeTests.cs rename to src/Destructurama.Attributed.Tests/ReplacedAttributeTests.cs diff --git a/test/Destructurama.Attributed.Tests/Snippets.cs b/src/Destructurama.Attributed.Tests/Snippets.cs similarity index 100% rename from test/Destructurama.Attributed.Tests/Snippets.cs rename to src/Destructurama.Attributed.Tests/Snippets.cs diff --git a/test/Destructurama.Attributed.Tests/Support/DelegatingSink.cs b/src/Destructurama.Attributed.Tests/Support/DelegatingSink.cs similarity index 100% rename from test/Destructurama.Attributed.Tests/Support/DelegatingSink.cs rename to src/Destructurama.Attributed.Tests/Support/DelegatingSink.cs diff --git a/test/Destructurama.Attributed.Tests/Support/Extensions.cs b/src/Destructurama.Attributed.Tests/Support/Extensions.cs similarity index 100% rename from test/Destructurama.Attributed.Tests/Support/Extensions.cs rename to src/Destructurama.Attributed.Tests/Support/Extensions.cs diff --git a/src/Destructurama.Attributed/Destructurama.Attributed.csproj b/src/Destructurama.Attributed/Destructurama.Attributed.csproj index 0eb5fcf..8084988 100644 --- a/src/Destructurama.Attributed/Destructurama.Attributed.csproj +++ b/src/Destructurama.Attributed/Destructurama.Attributed.csproj @@ -1,25 +1,15 @@ - + netstandard2.0 - 3.1.0 - Destructurama - True - Serilog Contributors Use attributes to control how complex types are logged to Serilog. - https://github.com/destructurama - Apache-2.0 - icon.png - serilog;attributed - true - true + Destructurama + true - - - + diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 0000000..6f5c415 --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,38 @@ + + + + latest + true + true + true + $([System.DateTime]::Now.ToString(yyyy)) + Destructurama Contributors, Serilog Contributors + Copyright © Serilog Contributors 2017-$(CurrentYear) + Apache-2.0 + false + icon.png + git + embedded + true + true + + True + serilog;attributed + enable + README.md + true + enable + true + ../../assets/Destructurama.snk + + ../../../../../../assets/Destructurama.snk + + + + + + + + + + diff --git a/src/destructurama-attributed.sln b/src/destructurama-attributed.sln new file mode 100644 index 0000000..9430b87 --- /dev/null +++ b/src/destructurama-attributed.sln @@ -0,0 +1,79 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34330.188 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{446E3BA7-97CF-43CF-B708-78C51EB45FC9}" + ProjectSection(SolutionItems) = preProject + ..\.editorconfig = ..\.editorconfig + ..\.gitattributes = ..\.gitattributes + ..\.gitignore = ..\.gitignore + ..\CHANGES.md = ..\CHANGES.md + ..\assets\Destructurama.snk = ..\assets\Destructurama.snk + Directory.Build.props = Directory.Build.props + ..\assets\icon.png = ..\assets\icon.png + ..\LICENSE = ..\LICENSE + ..\mdsnippets.json = ..\mdsnippets.json + ..\README.md = ..\README.md + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{36896219-827B-40F7-B74E-FA02C5454361}" + ProjectSection(SolutionItems) = preProject + ..\.github\codecov.yml = ..\.github\codecov.yml + ..\.github\dependabot.yml = ..\.github\dependabot.yml + ..\.github\labeler.yml = ..\.github\labeler.yml + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ISSUE_TEMPLATE", "ISSUE_TEMPLATE", "{5E865875-D5D8-4308-86B2-8035BDDB7833}" + ProjectSection(SolutionItems) = preProject + ..\.github\ISSUE_TEMPLATE\bug_report.md = ..\.github\ISSUE_TEMPLATE\bug_report.md + ..\.github\ISSUE_TEMPLATE\feature_request.md = ..\.github\ISSUE_TEMPLATE\feature_request.md + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{14AB42BE-7411-4195-B734-EAB658BE1ED1}" + ProjectSection(SolutionItems) = preProject + ..\.github\workflows\benchmarks.yml = ..\.github\workflows\benchmarks.yml + ..\.github\workflows\codeql-analysis.yml = ..\.github\workflows\codeql-analysis.yml + ..\.github\workflows\label.yml = ..\.github\workflows\label.yml + ..\.github\workflows\publish-preview.yml = ..\.github\workflows\publish-preview.yml + ..\.github\workflows\publish-release.yml = ..\.github\workflows\publish-release.yml + ..\.github\workflows\stale.yml = ..\.github\workflows\stale.yml + ..\.github\workflows\test.yml = ..\.github\workflows\test.yml + EndProjectSection +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Destructurama.Attributed", "Destructurama.Attributed\Destructurama.Attributed.csproj", "{1F52A6F8-BE51-4648-9EDB-ADEC23E1C1C8}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Destructurama.Attributed.Tests", "Destructurama.Attributed.Tests\Destructurama.Attributed.Tests.csproj", "{293201F5-761A-47AC-B6B0-98734CA6B4A2}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Benchmarks", "Benchmarks\Benchmarks.csproj", "{27515D99-8216-423E-B12A-0150101A2C19}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1F52A6F8-BE51-4648-9EDB-ADEC23E1C1C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F52A6F8-BE51-4648-9EDB-ADEC23E1C1C8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F52A6F8-BE51-4648-9EDB-ADEC23E1C1C8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F52A6F8-BE51-4648-9EDB-ADEC23E1C1C8}.Release|Any CPU.Build.0 = Release|Any CPU + {293201F5-761A-47AC-B6B0-98734CA6B4A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {293201F5-761A-47AC-B6B0-98734CA6B4A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {293201F5-761A-47AC-B6B0-98734CA6B4A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {293201F5-761A-47AC-B6B0-98734CA6B4A2}.Release|Any CPU.Build.0 = Release|Any CPU + {27515D99-8216-423E-B12A-0150101A2C19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {27515D99-8216-423E-B12A-0150101A2C19}.Debug|Any CPU.Build.0 = Debug|Any CPU + {27515D99-8216-423E-B12A-0150101A2C19}.Release|Any CPU.ActiveCfg = Release|Any CPU + {27515D99-8216-423E-B12A-0150101A2C19}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {5E865875-D5D8-4308-86B2-8035BDDB7833} = {36896219-827B-40F7-B74E-FA02C5454361} + {14AB42BE-7411-4195-B734-EAB658BE1ED1} = {36896219-827B-40F7-B74E-FA02C5454361} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F09D8B7B-37C6-417E-B8DA-296735211A4E} + EndGlobalSection +EndGlobal