From c1ec8c5a41268571df04e01221e03e057942e39c Mon Sep 17 00:00:00 2001 From: Christo du Toit Date: Tue, 15 Apr 2025 22:44:42 +0100 Subject: [PATCH 01/15] CONFIG: Updated packages and build script --- .github/workflows/{dotnet.yml => build.yml} | 81 +-------- .github/workflows/prLinter.yml | 135 ++++++++++++++ Xeption.Infrastructure.Build/Program.cs | 107 +----------- .../Services/ScriptGenerationService.cs | 164 ++++++++++++++++++ .../Xeption.Infrastructure.Build.csproj | 2 +- Xeption.Tests/Xeption.Tests.csproj | 8 +- Xeption/Xeption.csproj | 10 +- 7 files changed, 323 insertions(+), 184 deletions(-) rename .github/workflows/{dotnet.yml => build.yml} (64%) create mode 100644 .github/workflows/prLinter.yml create mode 100644 Xeption.Infrastructure.Build/Services/ScriptGenerationService.cs diff --git a/.github/workflows/dotnet.yml b/.github/workflows/build.yml similarity index 64% rename from .github/workflows/dotnet.yml rename to .github/workflows/build.yml index 5b1cb93..1f55e31 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/build.yml @@ -4,84 +4,16 @@ on: branches: - main pull_request: + types: + - opened + - synchronize + - reopened + - closed branches: - main jobs: - label: - runs-on: ubuntu-latest - steps: - - name: Apply Label - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: >- - const prefixes = [ - 'INFRA:', - 'PROVISIONS:', - 'RELEASES:', - 'DATA:', - 'BROKERS:', - 'FOUNDATIONS:', - 'PROCESSINGS:', - 'ORCHESTRATIONS:', - 'COORDINATIONS:', - 'MANAGEMENTS:', - 'AGGREGATIONS:', - 'CONTROLLERS:', - 'CLIENTS:', - 'EXPOSERS:', - 'PROVIDERS:', - 'BASE:', - 'COMPONENTS:', - 'VIEWS:', - 'PAGES:', - 'ACCEPTANCE:', - 'INTEGRATIONS:', - 'CODE RUB:', - 'MINOR FIX:', - 'MEDIUM FIX:', - 'MAJOR FIX:', - 'DOCUMENTATION:', - 'CONFIG:', - 'STANDARD:', - 'DESIGN:', - 'BUSINESS:' - ]; - - - const pullRequest = context.payload.pull_request; - - - if (!pullRequest) { - console.log('No pull request context available.'); - return; - } - - - const title = context.payload.pull_request.title; - - const existingLabels = context.payload.pull_request.labels.map(label => label.name); - - - for (const prefix of prefixes) { - if (title.startsWith(prefix)) { - const label = prefix.slice(0, -1); - if (!existingLabels.includes(label)) { - console.log(`Applying label: ${label}`); - await github.rest.issues.addLabels({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.payload.pull_request.number, - labels: [label] - }); - } - break; - } - } - permissions: - contents: read - pull-requests: write build: + name: Build runs-on: ubuntu-latest steps: - name: Check out @@ -97,6 +29,7 @@ jobs: - name: Test run: dotnet test --no-build --verbosity normal add_tag: + name: Tag and Release runs-on: ubuntu-latest needs: - build diff --git a/.github/workflows/prLinter.yml b/.github/workflows/prLinter.yml new file mode 100644 index 0000000..a67f18d --- /dev/null +++ b/.github/workflows/prLinter.yml @@ -0,0 +1,135 @@ +name: PR Linter +on: + pull_request: + types: + - opened + - edited + - synchronize + - reopened + - closed + branches: + - main +jobs: + label: + name: Label + runs-on: ubuntu-latest + steps: + - name: Apply Label + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: >- + const prefixes = [ + 'INFRA:', + 'PROVISIONS:', + 'RELEASES:', + 'DATA:', + 'BROKERS:', + 'FOUNDATIONS:', + 'PROCESSINGS:', + 'ORCHESTRATIONS:', + 'COORDINATIONS:', + 'MANAGEMENTS:', + 'AGGREGATIONS:', + 'CONTROLLERS:', + 'CLIENTS:', + 'EXPOSERS:', + 'PROVIDERS:', + 'BASE:', + 'COMPONENTS:', + 'VIEWS:', + 'PAGES:', + 'ACCEPTANCE:', + 'INTEGRATIONS:', + 'CODE RUB:', + 'MINOR FIX:', + 'MEDIUM FIX:', + 'MAJOR FIX:', + 'DOCUMENTATION:', + 'CONFIG:', + 'STANDARD:', + 'DESIGN:', + 'BUSINESS:' + ]; + + + const pullRequest = context.payload.pull_request; + + + if (!pullRequest) { + console.log('No pull request context available.'); + return; + } + + + const title = context.payload.pull_request.title; + + const existingLabels = context.payload.pull_request.labels.map(label => label.name); + + + for (const prefix of prefixes) { + if (title.startsWith(prefix)) { + const label = prefix.slice(0, -1); + if (!existingLabels.includes(label)) { + console.log(`Applying label: ${label}`); + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.pull_request.number, + labels: [label] + }); + } + break; + } + } + permissions: + contents: read + pull-requests: write + requireIssueOrTask: + name: Require Issue Or Task Association + runs-on: ubuntu-latest + steps: + - name: Check out + uses: actions/checkout@v3 + - name: Get PR Information + id: get_pr_info + uses: actions/github-script@v6 + with: + script: >2- + const pr = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number + }); + + const prOwner = pr.data.user.login || ""; + const prBody = pr.data.body || ""; + core.setOutput("prOwner", prOwner); + core.setOutput("description", prBody); + console.log(`PR Owner: ${prOwner}`); + console.log(`PR Body: ${prBody}`); + - name: Check For Associated Issues Or Tasks + id: check_for_issues_or_tasks + if: ${{ steps.get_pr_info.outputs.prOwner != 'dependabot[bot]' }} + run: >2- + PR_BODY="${{ steps.get_pr_info.outputs.description }}" + echo "::notice::Raw PR Body: $PR_BODY" + + if [[ -z "$PR_BODY" ]]; then + echo "Error: PR description does not contain any links to issue(s)/task(s) (e.g., 'closes #123' / 'closes AB#123' / 'fixes #123' / 'fixes AB#123')." + exit 1 + fi + + PR_BODY=$(echo "$PR_BODY" | tr -s '\r\n' ' ' | tr '\n' ' ' | xargs) + echo "::notice::Normalized PR Body: $PR_BODY" + + if echo "$PR_BODY" | grep -Piq "((close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved)\s*(\[#\d+\]|\#\d+)|(?:close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved)\s*(\[AB#\d+\]|AB#\d+))"; then + echo "Valid PR description." + else + echo "Error: PR description does not contain any links to issue(s)/task(s) (e.g., 'closes #123' / 'closes AB#123' / 'fixes #123' / 'fixes AB#123')." + exit 1 + fi + shell: bash + permissions: + contents: read + pull-requests: read diff --git a/Xeption.Infrastructure.Build/Program.cs b/Xeption.Infrastructure.Build/Program.cs index 47b452b..029ba68 100644 --- a/Xeption.Infrastructure.Build/Program.cs +++ b/Xeption.Infrastructure.Build/Program.cs @@ -2,12 +2,7 @@ // Copyright (c) The Standard Organization, a coalition of the Good-Hearted Engineers // ---------------------------------------------------------------------------------- -using System.Collections.Generic; -using System.IO; -using ADotNet.Clients; -using ADotNet.Models.Pipelines.GithubPipelines.DotNets; -using ADotNet.Models.Pipelines.GithubPipelines.DotNets.Tasks; -using ADotNet.Models.Pipelines.GithubPipelines.DotNets.Tasks.SetupDotNetTaskV3s; +using Xeption.Infrastructure.Build.Services; namespace Xeptions.Infrastructure.Build { @@ -15,102 +10,14 @@ internal class Program { static void Main(string[] args) { - string branchName = "main"; - string dotNetVersion = "9.0.100"; - var adotNetClient = new ADotNetClient(); + var scriptGenerationService = new ScriptGenerationService(); - var githubPipeline = new GithubPipeline - { - Name = "Build", + scriptGenerationService.GenerateBuildScript( + branchName: "main", + projectName: "Xeption", + dotNetVersion: "9.0.100"); - OnEvents = new Events - { - Push = new PushEvent - { - Branches = new string[] { branchName } - }, - - PullRequest = new PullRequestEvent - { - Branches = new string[] { branchName } - } - }, - - Jobs = new Dictionary - { - { - "label", - new LabelJobV2(runsOn: BuildMachines.UbuntuLatest) - }, - { - "build", - new Job - { - RunsOn = BuildMachines.UbuntuLatest, - - Steps = new List - { - new CheckoutTaskV3 - { - Name = "Check out" - }, - - new SetupDotNetTaskV3 - { - Name = "Setup .Net", - - With = new TargetDotNetVersionV3 - { - DotNetVersion = dotNetVersion - } - }, - - new RestoreTask - { - Name = "Restore" - }, - - new DotNetBuildTask - { - Name = "Build" - }, - - new TestTask - { - Name = "Test" - } - } - } - }, - { - "add_tag", - new TagJob( - runsOn: BuildMachines.UbuntuLatest, - dependsOn: "build", - projectRelativePath: "Xeption/Xeption.csproj", - githubToken: "${{ secrets.PAT_FOR_TAGGING }}", - branchName: branchName) - }, - { - "publish", - new PublishJobV2( - runsOn: BuildMachines.UbuntuLatest, - dependsOn: "add_tag", - dotNetVersion: dotNetVersion, - nugetApiKey: "${{ secrets.NUGET_ACCESS }}") - } - } - }; - - string buildScriptPath = "../../../../.github/workflows/dotnet.yml"; - string directoryPath = Path.GetDirectoryName(buildScriptPath); - - if (Directory.Exists(directoryPath) is false) - { - Directory.CreateDirectory(directoryPath); - } - - adotNetClient.SerializeAndWriteToFile(adoPipeline: githubPipeline, path: buildScriptPath); + scriptGenerationService.GeneratePrLintScript(branchName: "main"); } } } diff --git a/Xeption.Infrastructure.Build/Services/ScriptGenerationService.cs b/Xeption.Infrastructure.Build/Services/ScriptGenerationService.cs new file mode 100644 index 0000000..9370687 --- /dev/null +++ b/Xeption.Infrastructure.Build/Services/ScriptGenerationService.cs @@ -0,0 +1,164 @@ +// ---------------------------------------------------------------------------------- +// Copyright (c) The Standard Organization, a coalition of the Good-Hearted Engineers +// ---------------------------------------------------------------------------------- + +using System.Collections.Generic; +using System.IO; +using ADotNet.Clients; +using ADotNet.Models.Pipelines.GithubPipelines.DotNets; +using ADotNet.Models.Pipelines.GithubPipelines.DotNets.Tasks; +using ADotNet.Models.Pipelines.GithubPipelines.DotNets.Tasks.SetupDotNetTaskV3s; + +namespace Xeption.Infrastructure.Build.Services +{ + internal class ScriptGenerationService + { + private readonly ADotNetClient adotNetClient; + + public ScriptGenerationService() => + adotNetClient = new ADotNetClient(); + + public void GenerateBuildScript(string branchName, string projectName, string dotNetVersion) + { + var githubPipeline = new GithubPipeline + { + Name = "Build", + + OnEvents = new Events + { + Push = new PushEvent { Branches = [branchName] }, + + PullRequest = new PullRequestEvent + { + Types = ["opened", "synchronize", "reopened", "closed"], + Branches = [branchName] + } + }, + + Jobs = new Dictionary + { + { + "build", + new Job + { + Name = "Build", + RunsOn = BuildMachines.UbuntuLatest, + + Steps = new List + { + new CheckoutTaskV3 + { + Name = "Check out" + }, + + new SetupDotNetTaskV3 + { + Name = "Setup .Net", + + With = new TargetDotNetVersionV3 + { + DotNetVersion = dotNetVersion + } + }, + + new RestoreTask + { + Name = "Restore" + }, + + new DotNetBuildTask + { + Name = "Build" + }, + + new TestTask + { + Name = "Test" + } + } + } + }, + { + "add_tag", + new TagJob( + runsOn: BuildMachines.UbuntuLatest, + dependsOn: "build", + projectRelativePath: $"{projectName}/{projectName}.csproj", + githubToken: "${{ secrets.PAT_FOR_TAGGING }}", + branchName: branchName) + { + Name = "Tag and Release" + } + }, + { + "publish", + new PublishJobV2( + runsOn: BuildMachines.UbuntuLatest, + dependsOn: "add_tag", + dotNetVersion: dotNetVersion, + nugetApiKey: "${{ secrets.NUGET_ACCESS }}") + } + } + }; + + string buildScriptPath = "../../../../.github/workflows/build.yml"; + string directoryPath = Path.GetDirectoryName(buildScriptPath); + + if (!Directory.Exists(directoryPath)) + { + Directory.CreateDirectory(directoryPath); + } + + adotNetClient.SerializeAndWriteToFile( + adoPipeline: githubPipeline, + path: buildScriptPath); + } + + public void GeneratePrLintScript(string branchName) + { + var githubPipeline = new GithubPipeline + { + Name = "PR Linter", + + OnEvents = new Events + { + PullRequest = new PullRequestEvent + { + Types = ["opened", "edited", "synchronize", "reopened", "closed"], + Branches = [branchName] + } + }, + + Jobs = new Dictionary + { + { + "label", + new LabelJobV2(runsOn: BuildMachines.UbuntuLatest) + { + Name = "Label", + } + }, + { + "requireIssueOrTask", + new RequireIssueOrTaskJob() + { + Name = "Require Issue Or Task Association", + } + }, + } + }; + + string buildScriptPath = "../../../../.github/workflows/prLinter.yml"; + string directoryPath = Path.GetDirectoryName(buildScriptPath); + + if (!Directory.Exists(directoryPath)) + { + Directory.CreateDirectory(directoryPath); + } + + adotNetClient.SerializeAndWriteToFile( + adoPipeline: githubPipeline, + path: buildScriptPath); + } + } +} diff --git a/Xeption.Infrastructure.Build/Xeption.Infrastructure.Build.csproj b/Xeption.Infrastructure.Build/Xeption.Infrastructure.Build.csproj index 5deccf8..07715e6 100644 --- a/Xeption.Infrastructure.Build/Xeption.Infrastructure.Build.csproj +++ b/Xeption.Infrastructure.Build/Xeption.Infrastructure.Build.csproj @@ -7,7 +7,7 @@ - + diff --git a/Xeption.Tests/Xeption.Tests.csproj b/Xeption.Tests/Xeption.Tests.csproj index 62dd0f7..0a98d78 100644 --- a/Xeption.Tests/Xeption.Tests.csproj +++ b/Xeption.Tests/Xeption.Tests.csproj @@ -10,15 +10,15 @@ - + - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/Xeption/Xeption.csproj b/Xeption/Xeption.csproj index b74b4f9..5e45067 100644 --- a/Xeption/Xeption.csproj +++ b/Xeption/Xeption.csproj @@ -1,11 +1,11 @@  - netstandard2.0;netstandard2.1 + netstandard2.0;net9.0 Hassan Habib, Christo du Toit - Hassan Habib + Standard Organization Exceptional Exceptions - Copyright (c) Hassan Habib + Copyright (c) Standard Organization true true Xeption.png @@ -15,9 +15,9 @@ 2.8.0.0 en-US - https://www.xeption.net + https://github.com/The-Standard-Organization/Xeption License.txt - https://github.com/hassanhabib/Xeption + https://github.com/The-Standard-Organization/Xeption GitHub Exceptions .NET From 30dd4c310fa9b4b1e44b60b537baff6f621df781 Mon Sep 17 00:00:00 2001 From: Christo du Toit Date: Fri, 8 May 2026 12:40:38 +0100 Subject: [PATCH 02/15] CODE RUB: Included .Net 10 as target version for LST and updated packages --- Xeption.Infrastructure.Build/Program.cs | 2 +- .../Xeption.Infrastructure.Build.csproj | 2 +- Xeption.Tests/Xeption.Tests.csproj | 8 ++++---- Xeption.slnx | 9 +++++++++ Xeption/Xeption.csproj | 4 ++-- 5 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 Xeption.slnx diff --git a/Xeption.Infrastructure.Build/Program.cs b/Xeption.Infrastructure.Build/Program.cs index 029ba68..6cf6e8a 100644 --- a/Xeption.Infrastructure.Build/Program.cs +++ b/Xeption.Infrastructure.Build/Program.cs @@ -15,7 +15,7 @@ static void Main(string[] args) scriptGenerationService.GenerateBuildScript( branchName: "main", projectName: "Xeption", - dotNetVersion: "9.0.100"); + dotNetVersion: "10.x"); scriptGenerationService.GeneratePrLintScript(branchName: "main"); } diff --git a/Xeption.Infrastructure.Build/Xeption.Infrastructure.Build.csproj b/Xeption.Infrastructure.Build/Xeption.Infrastructure.Build.csproj index 07715e6..6fc7270 100644 --- a/Xeption.Infrastructure.Build/Xeption.Infrastructure.Build.csproj +++ b/Xeption.Infrastructure.Build/Xeption.Infrastructure.Build.csproj @@ -2,7 +2,7 @@ Exe - net9.0 + net10.0 disable diff --git a/Xeption.Tests/Xeption.Tests.csproj b/Xeption.Tests/Xeption.Tests.csproj index 0a98d78..92c2ee7 100644 --- a/Xeption.Tests/Xeption.Tests.csproj +++ b/Xeption.Tests/Xeption.Tests.csproj @@ -9,16 +9,16 @@ - - + + - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/Xeption.slnx b/Xeption.slnx new file mode 100644 index 0000000..549b497 --- /dev/null +++ b/Xeption.slnx @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/Xeption/Xeption.csproj b/Xeption/Xeption.csproj index 5e45067..6211e88 100644 --- a/Xeption/Xeption.csproj +++ b/Xeption/Xeption.csproj @@ -1,7 +1,7 @@  - netstandard2.0;net9.0 + netstandard2.0;net9.0;net10.0 Hassan Habib, Christo du Toit Standard Organization Exceptional Exceptions @@ -39,7 +39,7 @@ - + From 127c2bbbe2b1f8db75f6119d21afe50511b37827 Mon Sep 17 00:00:00 2001 From: Christo du Toit Date: Fri, 8 May 2026 12:44:42 +0100 Subject: [PATCH 03/15] CODE RUB: Removed old solution file --- Xeption.sln | 43 ------------------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 Xeption.sln diff --git a/Xeption.sln b/Xeption.sln deleted file mode 100644 index e857ce4..0000000 --- a/Xeption.sln +++ /dev/null @@ -1,43 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.0.31612.314 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xeption", "Xeption\Xeption.csproj", "{903BFBDD-0C7E-4E76-8680-5461F659EACF}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xeption.Tests", "Xeption.Tests\Xeption.Tests.csproj", "{C72AD7F5-15EA-485B-A997-9F5C3772CC5E}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xeption.Infrastructure.Build", "Xeption.Infrastructure.Build\Xeption.Infrastructure.Build.csproj", "{AF2B0C4C-A457-4B9A-A02C-6DECEE665348}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{95739A3B-5FC3-41EB-B265-347E109A692D}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - README.md = README.md - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {903BFBDD-0C7E-4E76-8680-5461F659EACF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {903BFBDD-0C7E-4E76-8680-5461F659EACF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {903BFBDD-0C7E-4E76-8680-5461F659EACF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {903BFBDD-0C7E-4E76-8680-5461F659EACF}.Release|Any CPU.Build.0 = Release|Any CPU - {C72AD7F5-15EA-485B-A997-9F5C3772CC5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C72AD7F5-15EA-485B-A997-9F5C3772CC5E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C72AD7F5-15EA-485B-A997-9F5C3772CC5E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C72AD7F5-15EA-485B-A997-9F5C3772CC5E}.Release|Any CPU.Build.0 = Release|Any CPU - {AF2B0C4C-A457-4B9A-A02C-6DECEE665348}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AF2B0C4C-A457-4B9A-A02C-6DECEE665348}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AF2B0C4C-A457-4B9A-A02C-6DECEE665348}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AF2B0C4C-A457-4B9A-A02C-6DECEE665348}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {5B0D28EC-C885-4BC2-942E-835DA222E9DE} - EndGlobalSection -EndGlobal From b70d7e80701ed75c5c428ae8c8e26668ea7bea8a Mon Sep 17 00:00:00 2001 From: Christo du Toit Date: Fri, 8 May 2026 13:18:37 +0100 Subject: [PATCH 04/15] CODE RUB: Code cleanup --- Xeption/Xeption.cs | 1 - Xeption/Xeption.csproj | 1 - 2 files changed, 2 deletions(-) diff --git a/Xeption/Xeption.cs b/Xeption/Xeption.cs index b68b634..ad9fa98 100644 --- a/Xeption/Xeption.cs +++ b/Xeption/Xeption.cs @@ -97,7 +97,6 @@ internal static (bool IsMatch, string Message) CompareDataKeys( ? "exception" : $"inner exception (level {exceptionLevel})"; - bool isMatch = true; var errors = new StringBuilder(); errors.AppendLine($"Expected {exceptionLevelName} to:"); bool unmatched = dictionary.Count != otherDictionary.Count; diff --git a/Xeption/Xeption.csproj b/Xeption/Xeption.csproj index 6211e88..19a1068 100644 --- a/Xeption/Xeption.csproj +++ b/Xeption/Xeption.csproj @@ -40,7 +40,6 @@ - From 6e76b9ff90b5f72a653a0d0a8aa71ddb77402336 Mon Sep 17 00:00:00 2001 From: Christo du Toit Date: Fri, 8 May 2026 14:16:35 +0100 Subject: [PATCH 05/15] ShouldNotThrowWhenComparingDataWithEmptyValuesList -> FAIL --- Xeption.Tests/XeptionTests.Logic.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Xeption.Tests/XeptionTests.Logic.cs b/Xeption.Tests/XeptionTests.Logic.cs index beee68b..1d826b8 100644 --- a/Xeption.Tests/XeptionTests.Logic.cs +++ b/Xeption.Tests/XeptionTests.Logic.cs @@ -14,6 +14,23 @@ namespace Xeptions.Tests { public partial class XeptionTests { + [Fact] + public void ShouldNotThrowWhenComparingDataWithEmptyValuesList() + { + // given + var xeption = new Xeption(); + xeption.AddData(key: "someKey"); + + var otherXeption = new Xeption(); + otherXeption.AddData(key: "someKey"); + + // when + Action compareAction = () => xeption.DataEquals(otherXeption.Data); + + // then + compareAction.Should().NotThrow(); + } + [Fact] public void ShouldInheritFromSystemException() { From 3e662165e2250c75f16f679b1732455364e184f2 Mon Sep 17 00:00:00 2001 From: Christo du Toit Date: Fri, 8 May 2026 14:16:58 +0100 Subject: [PATCH 06/15] ShouldNotThrowWhenComparingDataWithEmptyValuesList -> PASS --- Xeption/Xeption.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Xeption/Xeption.cs b/Xeption/Xeption.cs index ad9fa98..9715670 100644 --- a/Xeption/Xeption.cs +++ b/Xeption/Xeption.cs @@ -220,6 +220,11 @@ private static string GetDictionaryValues(object values) throw new InvalidCastException("Unsupported type in sharedItems dictionary."); } + if (valuesList.Count == 0) + { + return string.Empty; + } + string stringValues = valuesList.Aggregate((t1, t2) => t1 + "','" + t2); return stringValues; From 45157abf1ddb3bc2f554927d2d817dd53a6649e1 Mon Sep 17 00:00:00 2001 From: Christo du Toit Date: Fri, 8 May 2026 14:18:08 +0100 Subject: [PATCH 07/15] ShouldNotThrowWhenComparingDataWithNonStringListValues -> FAIL --- Xeption.Tests/XeptionTests.Logic.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Xeption.Tests/XeptionTests.Logic.cs b/Xeption.Tests/XeptionTests.Logic.cs index 1d826b8..535d7ca 100644 --- a/Xeption.Tests/XeptionTests.Logic.cs +++ b/Xeption.Tests/XeptionTests.Logic.cs @@ -14,6 +14,23 @@ namespace Xeptions.Tests { public partial class XeptionTests { + [Fact] + public void ShouldNotThrowWhenComparingDataWithNonStringListValues() + { + // given + var xeption = new Xeption(); + xeption.Data.Add("someKey", 42); + + var otherXeption = new Xeption(); + otherXeption.Data.Add("someKey", 42); + + // when + Action compareAction = () => xeption.DataEquals(otherXeption.Data); + + // then + compareAction.Should().NotThrow(); + } + [Fact] public void ShouldNotThrowWhenComparingDataWithEmptyValuesList() { From 05bd13bfe35852a5971284f53f14d18a8bf97b64 Mon Sep 17 00:00:00 2001 From: Christo du Toit Date: Fri, 8 May 2026 14:18:31 +0100 Subject: [PATCH 08/15] ShouldNotThrowWhenComparingDataWithNonStringListValues -> PASS --- Xeption/Xeption.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xeption/Xeption.cs b/Xeption/Xeption.cs index 9715670..17bccd6 100644 --- a/Xeption/Xeption.cs +++ b/Xeption/Xeption.cs @@ -217,7 +217,7 @@ private static string GetDictionaryValues(object values) } else { - throw new InvalidCastException("Unsupported type in sharedItems dictionary."); + return values?.ToString() ?? string.Empty; } if (valuesList.Count == 0) From 6f7e76a4e297ac5da3a137e7c553f2867f6656f7 Mon Sep 17 00:00:00 2001 From: Christo du Toit Date: Fri, 8 May 2026 14:30:45 +0100 Subject: [PATCH 09/15] ShouldNotSilentlyDropValueWhenUpsertingOnNonStringListKey -> FAIL --- Xeption.Tests/XeptionTests.Logic.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Xeption.Tests/XeptionTests.Logic.cs b/Xeption.Tests/XeptionTests.Logic.cs index 535d7ca..b1ac7d5 100644 --- a/Xeption.Tests/XeptionTests.Logic.cs +++ b/Xeption.Tests/XeptionTests.Logic.cs @@ -14,6 +14,24 @@ namespace Xeptions.Tests { public partial class XeptionTests { + [Fact] + public void ShouldNotSilentlyDropValueWhenUpsertingOnNonStringListKey() + { + // given + string key = GetRandomMessage(); + string upsertedValue = GetRandomMessage(); + var xeption = new Xeption(); + xeption.Data.Add(key, 42); + + // when + xeption.UpsertDataList(key, upsertedValue); + + // then + var storedList = xeption.Data[key] as List; + storedList.Should().NotBeNull(); + storedList.Should().Contain(upsertedValue); + } + [Fact] public void ShouldNotThrowWhenComparingDataWithNonStringListValues() { From cf2cc17c25b954864006e3aa528973a851e105ab Mon Sep 17 00:00:00 2001 From: Christo du Toit Date: Fri, 8 May 2026 14:31:09 +0100 Subject: [PATCH 10/15] ShouldNotSilentlyDropValueWhenUpsertingOnNonStringListKey -> PASS --- Xeption/Xeption.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Xeption/Xeption.cs b/Xeption/Xeption.cs index 17bccd6..107d707 100644 --- a/Xeption/Xeption.cs +++ b/Xeption/Xeption.cs @@ -39,7 +39,14 @@ public void UpsertDataList(string key, string value) { if (this.Data.Contains(key)) { - (this.Data[key] as List)?.Add(value); + if (this.Data[key] is List existingList) + { + existingList.Add(value); + } + else + { + this.Data[key] = new List { value }; + } } else { From ab943844a9c37cd1dc33d275e30ba8f6185bc821 Mon Sep 17 00:00:00 2001 From: Christo du Toit Date: Fri, 8 May 2026 14:37:01 +0100 Subject: [PATCH 11/15] CODE RUB: Boolean comparisons, PackageLicenseExpression, SemVer version --- Xeption/Xeption.cs | 40 +++++++++++++++++------------------- Xeption/Xeption.csproj | 3 +-- Xeption/XeptionExtensions.cs | 6 +++--- 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/Xeption/Xeption.cs b/Xeption/Xeption.cs index 107d707..9aa1d25 100644 --- a/Xeption/Xeption.cs +++ b/Xeption/Xeption.cs @@ -122,25 +122,25 @@ internal static (bool IsMatch, string Message) CompareDataKeys( if (unmatched || hasAdditionalItems || hasMissingItems || unMatchedItems) { - if (String.IsNullOrWhiteSpace(additionalErrors) is false) - { - errors.AppendLine(additionalErrors); - } + if (!String.IsNullOrWhiteSpace(additionalErrors)) + { + errors.AppendLine(additionalErrors); + } - if (String.IsNullOrWhiteSpace(missingErrors) is false) - { - errors.AppendLine(missingErrors); - } + if (!String.IsNullOrWhiteSpace(missingErrors)) + { + errors.AppendLine(missingErrors); + } - if (String.IsNullOrWhiteSpace(unMatchedItemsErrors) is false) - { - errors.AppendLine(unMatchedItemsErrors); - } + if (!String.IsNullOrWhiteSpace(unMatchedItemsErrors)) + { + errors.AppendLine(unMatchedItemsErrors); + } return (false, errors.ToString().Trim()); } - return (true, string.Empty); + return (true, String.Empty); } private static (bool hasAdditionalItems, string additionalErrors) EvaluateAdditionalKeys( @@ -183,11 +183,11 @@ private static (bool unMatchedItems, string unMatchedItemsErrors) EvaluateShared IDictionary dictionary, IDictionary sharedItems) { + bool unMatchedItems = false; + var unMatchedItemsErrors = new StringBuilder(); + if (sharedItems?.Count > 0) { - bool unMatchedItems = false; - var unMatchedItemsErrors = new StringBuilder(); - foreach (DictionaryEntry dictionaryEntry in sharedItems) { string expectedValues = GetDictionaryValues(dictionaryEntry.Value); @@ -203,11 +203,9 @@ private static (bool unMatchedItems, string unMatchedItemsErrors) EvaluateShared $"but found value(s) ['{actualValues}']"); } } - - return (unMatchedItems, unMatchedItemsErrors.ToString().Trim()); } - return (false, string.Empty); + return (unMatchedItems, unMatchedItemsErrors.ToString().Trim()); } private static string GetDictionaryValues(object values) @@ -224,12 +222,12 @@ private static string GetDictionaryValues(object values) } else { - return values?.ToString() ?? string.Empty; + return values?.ToString() ?? String.Empty; } if (valuesList.Count == 0) { - return string.Empty; + return String.Empty; } string stringValues = valuesList.Aggregate((t1, t2) => t1 + "','" + t2); diff --git a/Xeption/Xeption.csproj b/Xeption/Xeption.csproj index 19a1068..30ef57c 100644 --- a/Xeption/Xeption.csproj +++ b/Xeption/Xeption.csproj @@ -10,11 +10,10 @@ true Xeption.png - 2.8 + 2.8.0 2.8.0.0 2.8.0.0 en-US - https://github.com/The-Standard-Organization/Xeption License.txt https://github.com/The-Standard-Organization/Xeption diff --git a/Xeption/XeptionExtensions.cs b/Xeption/XeptionExtensions.cs index 4d48196..cf0d4dd 100644 --- a/Xeption/XeptionExtensions.cs +++ b/Xeption/XeptionExtensions.cs @@ -79,13 +79,13 @@ internal static bool IsSameExceptionsAs( (bool isDataEqual, string dataMessage) = Xeption.CompareDataKeys(exception.Data, otherException.Data, exceptionLevel); - if (isDataEqual == false) + if (!isDataEqual) { invalidException = true; errors.AppendLine(dataMessage); } - if (invalidException == true) + if (invalidException) { message = errors.ToString().Trim(); return false; @@ -120,7 +120,7 @@ internal static bool IsSameExceptionsAs( } } - if (invalidException == true) + if (invalidException) { message = aggregateErrors.ToString().Trim(); return false; From 1991f7e083b7b541556893c381b761731d126e89 Mon Sep 17 00:00:00 2001 From: Christo du Toit Date: Fri, 8 May 2026 15:20:33 +0100 Subject: [PATCH 12/15] ShouldAppendToExistingListWhenUpsertingAfterAddDataFromDictionary -> FAIL --- Xeption.Tests/XeptionTests.Logic.cs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Xeption.Tests/XeptionTests.Logic.cs b/Xeption.Tests/XeptionTests.Logic.cs index b1ac7d5..bb2ed32 100644 --- a/Xeption.Tests/XeptionTests.Logic.cs +++ b/Xeption.Tests/XeptionTests.Logic.cs @@ -14,6 +14,32 @@ namespace Xeptions.Tests { public partial class XeptionTests { + [Fact] + public void ShouldAppendToExistingListWhenUpsertingAfterAddDataFromDictionary() + { + // given + string key = GetRandomMessage(); + string existingValue = GetRandomMessage(); + string upsertedValue = GetRandomMessage(); + var xeption = new Xeption(); + + var sourceDictionary = new System.Collections.Generic.Dictionary + { + { key, new[] { existingValue } } + }; + + xeption.AddData(sourceDictionary); + + // when + xeption.UpsertDataList(key, upsertedValue); + + // then + var storedList = xeption.Data[key] as List; + storedList.Should().NotBeNull(); + storedList.Should().Contain(existingValue); + storedList.Should().Contain(upsertedValue); + } + [Fact] public void ShouldNotSilentlyDropValueWhenUpsertingOnNonStringListKey() { From 0ad3aa77ff364b6580907ab30a72d0c3166fa50c Mon Sep 17 00:00:00 2001 From: Christo du Toit Date: Fri, 8 May 2026 15:20:59 +0100 Subject: [PATCH 13/15] ShouldAppendToExistingListWhenUpsertingAfterAddDataFromDictionary -> PASS --- Xeption/Xeption.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Xeption/Xeption.cs b/Xeption/Xeption.cs index 9aa1d25..362e91c 100644 --- a/Xeption/Xeption.cs +++ b/Xeption/Xeption.cs @@ -68,7 +68,18 @@ public void AddData(IDictionary dictionary) { foreach (DictionaryEntry item in dictionary) { - this.Data.Add(item.Key, item.Value); + if (item.Value is List listValue) + { + this.Data.Add(item.Key, listValue); + } + else if (item.Value is string[] arrayValue) + { + this.Data.Add(item.Key, arrayValue.ToList()); + } + else + { + this.Data.Add(item.Key, item.Value); + } } } } From 1dac233718c27f9d07573bc581de96a7aaf362d7 Mon Sep 17 00:00:00 2001 From: Christo du Toit Date: Fri, 8 May 2026 15:41:03 +0100 Subject: [PATCH 14/15] CODE RUB: Indentation, dead code, PackageIconUrl, PackageReleaseNotes --- Xeption/Xeption.cs | 24 +++++++++++------------- Xeption/Xeption.csproj | 12 +++++++++--- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Xeption/Xeption.cs b/Xeption/Xeption.cs index 362e91c..f397dd6 100644 --- a/Xeption/Xeption.cs +++ b/Xeption/Xeption.cs @@ -134,19 +134,19 @@ internal static (bool IsMatch, string Message) CompareDataKeys( if (unmatched || hasAdditionalItems || hasMissingItems || unMatchedItems) { if (!String.IsNullOrWhiteSpace(additionalErrors)) - { - errors.AppendLine(additionalErrors); - } + { + errors.AppendLine(additionalErrors); + } - if (!String.IsNullOrWhiteSpace(missingErrors)) - { - errors.AppendLine(missingErrors); - } + if (!String.IsNullOrWhiteSpace(missingErrors)) + { + errors.AppendLine(missingErrors); + } - if (!String.IsNullOrWhiteSpace(unMatchedItemsErrors)) - { - errors.AppendLine(unMatchedItemsErrors); - } + if (!String.IsNullOrWhiteSpace(unMatchedItemsErrors)) + { + errors.AppendLine(unMatchedItemsErrors); + } return (false, errors.ToString().Trim()); } @@ -162,8 +162,6 @@ private static (bool hasAdditionalItems, string additionalErrors) EvaluateAdditi if (additionalItems?.Count > 0) { - hasAdditionalItems = true; - foreach (DictionaryEntry dictionaryEntry in additionalItems) { additionalErrors.AppendLine($"- NOT contain key \"{dictionaryEntry.Key}\""); diff --git a/Xeption/Xeption.csproj b/Xeption/Xeption.csproj index 30ef57c..3390b7e 100644 --- a/Xeption/Xeption.csproj +++ b/Xeption/Xeption.csproj @@ -9,7 +9,6 @@ true true Xeption.png - 2.8.0 2.8.0.0 2.8.0.0 @@ -20,8 +19,15 @@ GitHub Exceptions .NET - Addition of a SameExceptionAs overload that can provide detail on differences. - Aggregate exception support. + Bug fixes and code quality improvements: + - Fixed crash in GetDictionaryValues when comparing empty List<string> values. + - Fixed crash in GetDictionaryValues when Data contains non-string-list values. + - Fixed UpsertDataList silently dropping data when key holds a non-List<string> value. + - Fixed AddData(IDictionary) not normalizing string[] values to List<string>. + - Refactored EvaluateSharedKeys for clarity (single return point). + - Removed boolean comparison anti-patterns. + - Fixed SemVer version format. + - Removed empty PackageLicenseExpression element. From a36012f44d46e9dd8273821e32dc658ff77ab5de Mon Sep 17 00:00:00 2001 From: Christo du Toit Date: Fri, 8 May 2026 16:00:44 +0100 Subject: [PATCH 15/15] CODE RUB: Updated Build Script --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1f55e31..bdfb3f7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,7 +21,7 @@ jobs: - name: Setup .Net uses: actions/setup-dotnet@v3 with: - dotnet-version: 9.0.100 + dotnet-version: 10.x - name: Restore run: dotnet restore - name: Build @@ -121,7 +121,7 @@ jobs: - name: Setup .Net uses: actions/setup-dotnet@v3 with: - dotnet-version: 9.0.100 + dotnet-version: 10.x - name: Restore run: dotnet restore - name: Build