Skip to content

Reduce TransactionAggregate.StartTransaction parameter count with start context object#1694

Merged
StuartFerguson merged 3 commits intomasterfrom
copilot/complexity-fix-start-transaction
Mar 18, 2026
Merged

Reduce TransactionAggregate.StartTransaction parameter count with start context object#1694
StuartFerguson merged 3 commits intomasterfrom
copilot/complexity-fix-start-transaction

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 18, 2026

TransactionAggregateExtensions.StartTransaction exceeded the repository’s parameter-count limit by taking 8 inputs plus the aggregate receiver. This change reduces the method’s surface area without changing transaction-start behavior by grouping the merchant/device identity inputs into a dedicated context object.

  • API shape

    • Introduce TransactionStartContext to carry:
      • EstateId
      • MerchantId
      • DeviceIdentifier
    • Update StartTransaction to accept the context object instead of three separate parameters.
  • Aggregate validation

    • Move estate/merchant/device validation onto TransactionStartContext.
    • Add an explicit invalid-result path when the context itself is null.
  • Call site updates

    • Update business logic, shared test data builders, and aggregate tests to construct and pass TransactionStartContext.
    • Reduce repeated test setup in TestData with a shared CreateTransactionStartContext() helper.
  • Safety / consistency

    • Make TransactionStartContext immutable with init setters to avoid post-construction mutation.
    • Add focused aggregate coverage for the null-context case.
Result result = transactionAggregate.StartTransaction(
    command.TransactionDateTime,
    command.TransactionNumber,
    transactionType,
    transactionReference,
    new TransactionStartContext
    {
        EstateId = command.EstateId,
        MerchantId = command.MerchantId,
        DeviceIdentifier = command.DeviceIdentifier
    },
    amount);

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • f.feedz.io
    • Triggering command: /usr/bin/dotnet dotnet test TransactionProcessor.Tests.csproj --filter VerifyBootstrapperIsValid --no-restore -nologo (dns block)
    • Triggering command: /usr/bin/dotnet dotnet test TransactionProcessor.Aggregates.Tests.csproj --filter TransactionAggregate_StartTransaction -p:RestoreIgnoreFailedSources=true -nologo (dns block)
    • Triggering command: /opt/hostedtoolcache/CodeQL/2.24.3/x64/codeql/csharp/tools/linux64/Semmle.Autobuild.CSharp /opt/hostedtoolcache/CodeQL/2.24.3/x64/codeql/csharp/tools/linux64/Semmle.Autobuild.CSharp (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>[Complexity] Method TransactionAggregateExtensions::StartTransaction has 9 parameters (limit is 8)</issue_title>
<issue_description>Codacy ID: c680e46466cc8832f3ade1dddbcbb6e9

File: TransactionProcessor.Aggregates/TransactionAggregate.cs
Line: 495
Rule: Complexity (Warning)
Commit: d86ddd7f1bcabe1f21d4be000e4eda81d82ca1d5

Message: Method TransactionAggregateExtensions::StartTransaction has 9 parameters (limit is 8)

**Code Snippet:**
```csharp
        public static Result StartTransaction(this TransactionAggregate aggregate, 
```

</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI changed the title [WIP] [Complexity] Fix method with too many parameters Reduce TransactionAggregate.StartTransaction parameter count with start context object Mar 18, 2026
Copilot AI requested a review from StuartFerguson March 18, 2026 19:47
@StuartFerguson StuartFerguson marked this pull request as ready for review March 18, 2026 19:47
@StuartFerguson StuartFerguson merged commit 3efb2c8 into master Mar 18, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Complexity] Method TransactionAggregateExtensions::StartTransaction has 9 parameters (limit is 8)

2 participants