Skip to content

Implement .NET Aspire orchestration in Chapter 4#234

Merged
kamilbaczek merged 10 commits intomainfrom
copilot/update-chapter-4-aspire
Jan 25, 2026
Merged

Implement .NET Aspire orchestration in Chapter 4#234
kamilbaczek merged 10 commits intomainfrom
copilot/update-chapter-4-aspire

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 19, 2025

📋 Description

Adds .NET Aspire orchestration for Chapter 4, mirroring the implementation from Chapter 3 (PR #227). Provides local development orchestration for PostgreSQL and RabbitMQ with .NET 10 and central package management.

AppHost Project

Created Fitnet.AppHost with orchestration for:

  • PostgreSQL 14.3 with pgAdmin
  • RabbitMQ with management plugin
  • Fitnet modular monolith
  • Contracts microservice
var postgres = builder.AddPostgres("postgres")
    .WithImage("postgres", "14.3")
    .WithPgAdmin();

var fitnetDatabase = postgres.AddDatabase("fitnetsdb", "fitnet");
var rabbitmq = builder.AddRabbitMQ("rabbitmq").WithManagementPlugin();

builder.AddProject<Fitnet>("fitnet-modular-monolith")
    .WithReference(fitnetDatabase, "Database__ConnectionString")
    .WithReference(rabbitmq, "EventBus__ConnectionString")
    .WaitFor(postgres)
    .WaitFor(rabbitmq);

EventBus Connection String Support

Updated EventBusModule.cs in both Fitnet.Passes.Api and Fitnet.Contracts to parse Aspire-provided connection strings with null-safe property access:

var uri = options.Value?.Uri;
var username = options.Value?.Username;
var password = options.Value?.Password;
if (!string.IsNullOrEmpty(uri))
{
    factoryConfigurator.Host(uri, h =>
    {
        if (!string.IsNullOrEmpty(username)) h.Username(username);
        if (!string.IsNullOrEmpty(password)) h.Password(password);
    });
}

📦 PR Includes

  • Feature added 🆕
  • Bug fix 🐛
  • Code refactor 🔄
  • Documentation update 📚
  • Tests added/updated 🧪
  • Other: (describe)

🚫 PR Does Not Include

  • Breaking changes ❌
  • Major architectural changes 🏗️
  • Unrelated features/tasks 🚫

💡 Additional Notes

Fully backward compatible with docker-compose workflow. No changes to business logic, Program.cs, or existing tests.

Copilot AI and others added 3 commits December 19, 2025 14:04
Co-authored-by: kamilbaczek <74410956+kamilbaczek@users.noreply.github.com>
Co-authored-by: kamilbaczek <74410956+kamilbaczek@users.noreply.github.com>
Co-authored-by: kamilbaczek <74410956+kamilbaczek@users.noreply.github.com>
Copilot AI changed the title [WIP] Update chapter 4 with similar changes as in pull request 227 Implement .NET Aspire orchestration in Chapter 4 Dec 19, 2025
Copilot AI requested a review from kamilbaczek December 19, 2025 14:13

var uri = options.Value.Uri;
var username = options.Value.Username;
var password = options.Value.Password;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot fix Dereference of a possibly null reference.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 6ad0888. Added null-conditional operator (?.) when accessing options.Value properties to prevent potential null reference dereference.

var username = options.Value.Username;
var password = options.Value.Password;

if (!string.IsNullOrEmpty(uri))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 3863ac9. Removed extra blank line to comply with IDE0055 formatting rules.


<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot remove target framework

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 3863ac9. Removed TargetFramework property - now inherits net10.0 from Directory.Build.props.

</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.0.0" />
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot remove from this we are using central management packages and .net 10

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 3863ac9. Removed package versions from csproj file. Now using central package management with Aspire 13.0.0 packages defined in Directory.Packages.props.

Co-authored-by: kamilbaczek <74410956+kamilbaczek@users.noreply.github.com>
Co-authored-by: kamilbaczek <74410956+kamilbaczek@users.noreply.github.com>
Copilot AI changed the title Implement .NET Aspire orchestration in Chapter 4 Implement .NET Aspire orchestration in Chapter 4 with .NET 10 and Central Package Management Jan 25, 2026
{
return;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error: /home/runner/work/evolutionary-architecture-by-example/evolutionary-architecture-by-example/Chapter-4-applying-tactical-domain-driven-design/Fitnet/Src/Passes/Fitnet.Passes.Api/Common/EventBus/EventBusModule.cs(47,1): error IDE0055: Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055) [/home/runner/work/evolutionary-architecture-by-example/evolutionary-architecture-by-example/Chapter-4-applying-tactical-domain-driven-design/Fitnet/Src/Passes/Fitnet.Passes.Api/Fitnet.Passes.Api.csproj]

@copilot fix formatting

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d08e267. Removed blank line between the closing brace and factoryConfigurator.ConfigureEndpoints(context); to comply with IDE0055 formatting rules.

}
});
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot fix formatting

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already fixed in d08e267. The blank line before factoryConfigurator.ConfigureEndpoints(context); was removed.

<Project>

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot remove target framework

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 02795b6. Removed TargetFramework property from root Directory.Build.props - AppHost inherits from subdirectory Directory.Build.props files.

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot remove

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 02795b6. Removed ImplicitUsings and Nullable properties from root Directory.Build.props.

Co-authored-by: kamilbaczek <74410956+kamilbaczek@users.noreply.github.com>
Co-authored-by: kamilbaczek <74410956+kamilbaczek@users.noreply.github.com>
@kamilbaczek
Copy link
Copy Markdown
Collaborator

@copilot Error: /home/runner/work/evolutionary-architecture-by-example/evolutionary-architecture-by-example/Chapter-4-applying-tactical-domain-driven-design/Fitnet/Src/Passes/Fitnet.Passes.Api/Common/EventBus/EventBusModule.cs(29,1): error IDE0055: Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055) [/home/runner/work/evolutionary-architecture-by-example/evolutionary-architecture-by-example/Chapter-4-applying-tactical-domain-driven-design/Fitnet/Src/Passes/Fitnet.Passes.Api/Fitnet.Passes.Api.csproj]

Co-authored-by: kamilbaczek <74410956+kamilbaczek@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 25, 2026

@copilot Error: /home/runner/work/evolutionary-architecture-by-example/evolutionary-architecture-by-example/Chapter-4-applying-tactical-domain-driven-design/Fitnet/Src/Passes/Fitnet.Passes.Api/Common/...

Fixed in ba7e3f3. Removed blank line on line 29 between the closing brace of the if statement and the variable declarations to comply with IDE0055 formatting rules.

@kamilbaczek kamilbaczek marked this pull request as ready for review January 25, 2026 21:09
@kamilbaczek kamilbaczek changed the title Implement .NET Aspire orchestration in Chapter 4 with .NET 10 and Central Package Management Implement .NET Aspire orchestration in Chapter 4 Jan 25, 2026
@kamilbaczek kamilbaczek merged commit 5a4f555 into main Jan 25, 2026
4 checks passed
@kamilbaczek kamilbaczek deleted the copilot/update-chapter-4-aspire branch January 25, 2026 21:14
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.

2 participants