Skip to content

Conversation

@HofmeisterAn
Copy link
Collaborator

@HofmeisterAn HofmeisterAn commented Jan 2, 2026

What does this PR do?

This PR updates the .NET examples to the latest TC version (4.10.0) and removes obsolete API usage to follow best practices and serve as a good reference for using TC for .NET.

Why is it important?

-

Related issues

Summary by CodeRabbit

  • Chores

    • Updated NuGet package dependencies across example projects, including Testcontainers.PostgreSql, Entity Framework Core, Npgsql, and Fluent UI to latest versions
    • Updated Docker base image from ASP.NET 8.0 to 10.0 runtime in WeatherForecast example
  • New Features

    • Added Platform property to image configuration in WeatherForecast example

✏️ Tip: You can customize this high-level summary in your review settings.

@HofmeisterAn HofmeisterAn added the chore A change that doesn't impact the existing functionality, e.g. internal refactorings or cleanups label Jan 2, 2026
@netlify
Copy link

netlify bot commented Jan 2, 2026

Deploy Preview for testcontainers-dotnet ready!

Name Link
🔨 Latest commit 20b031b
🔍 Latest deploy log https://app.netlify.com/projects/testcontainers-dotnet/deploys/6957ab3a9cfe3f00083af6f1
😎 Deploy Preview https://deploy-preview-1616--testcontainers-dotnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link

coderabbitai bot commented Jan 2, 2026

Walkthrough

The changes upgrade dependency versions across example projects (Testcontainers, EntityFrameworkCore, AspNetCore) to newer releases, update Docker base images, and refactor builder constructors to accept image parameters directly rather than using parameterless constructors with chained .WithImage() calls.

Changes

Cohort / File(s) Summary
Package Dependencies
examples/Flyway/Directory.Packages.props, examples/Respawn/Directory.Packages.props, examples/WeatherForecast/Directory.Packages.props
Testcontainers.PostgreSql updated from 4.7.0 to 4.10.0 across all three examples; Respawn 6.2.1→7.0.0; WeatherForecast also bumps EntityFrameworkCore 8.0.13→10.0.1, FluentUI 3.5.5→3.8.0, and Npgsql.EntityFrameworkCore 8.0.11→10.0.0
PostgreSQL Builder Constructor Refactoring
examples/Flyway/tests/Flyway.Tests/DbFixture.cs, examples/Respawn/tests/Respawn.Tests/DbFixture.cs, examples/WeatherForecast/src/WeatherForecast/DatabaseContainer.cs, examples/WeatherForecast/tests/WeatherForecast.InProcess.Tests/WeatherForecastTest.cs
PostgreSqlBuilder instantiation changed from parameterless constructor with separate .WithImage() call to parameterized constructor accepting image string directly (e.g., PostgreSqlBuilder("postgres:15-alpine") or PostgreSqlBuilder("postgres:15.1"))
Flyway Container Configuration
examples/Flyway/tests/Flyway.Tests/DbFixture.cs
ContainerBuilder migrated to parameterized constructor; AddCustomWaitStrategy expanded with configuration lambda to set mode: OneShot; WithCommand chain extended to include -password= parameter
WeatherForecast Container & Image Updates
examples/WeatherForecast/tests/WeatherForecast.Tests/WeatherForecastContainer.cs
Certificate initialization replaced with X509CertificateLoader.LoadPkcs12FromFile(); ContainerBuilder refactored to accept Image parameter directly instead of parameterless with .WithImage() chain
Docker Base Image
examples/WeatherForecast/Dockerfile
Base image updated from mcr.microsoft.com/dotnet/aspnet:8.0 to mcr.microsoft.com/dotnet/aspnet:10.0
Image Property Addition
examples/WeatherForecast/tests/WeatherForecast/WeatherForecastImage.cs
New public Platform property added, delegating to underlying _image.Platform

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 Dependencies dance in version's light,
Builders now speak up—image strings in sight,
From parameterless to targeted calls,
Examples refresh through these upgrade halls,
Platform exposed, fresh Docker base unfurled! 🚀

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description check ❓ Inconclusive The description covers the WHAT and includes a related issue, but lacks the mandatory WHY explanation and testing instructions that the template requests. Expand the WHY section with concrete reasons for the update (e.g., bug fixes, performance improvements, deprecation removal) and add testing instructions for reviewers.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main objective: updating examples to use Testcontainers for .NET version 4.10.0.
✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d66a9f1 and 20b031b.

📒 Files selected for processing (10)
  • examples/Flyway/Directory.Packages.props
  • examples/Flyway/tests/Flyway.Tests/DbFixture.cs
  • examples/Respawn/Directory.Packages.props
  • examples/Respawn/tests/Respawn.Tests/DbFixture.cs
  • examples/WeatherForecast/Directory.Packages.props
  • examples/WeatherForecast/Dockerfile
  • examples/WeatherForecast/src/WeatherForecast/DatabaseContainer.cs
  • examples/WeatherForecast/tests/WeatherForecast.InProcess.Tests/WeatherForecastTest.cs
  • examples/WeatherForecast/tests/WeatherForecast.Tests/WeatherForecastContainer.cs
  • examples/WeatherForecast/tests/WeatherForecast.Tests/WeatherForecastImage.cs
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: diegosasw
Repo: testcontainers/testcontainers-dotnet PR: 1583
File: src/Testcontainers.KurrentDb/Testcontainers.KurrentDb.csproj:7-7
Timestamp: 2025-11-17T17:58:43.958Z
Learning: In the testcontainers-dotnet repository, JetBrains.Annotations should use version 2023.3.0 to maintain consistency with the main Testcontainers csproj, rather than always using the latest available version.
📚 Learning: 2025-11-17T17:58:43.958Z
Learnt from: diegosasw
Repo: testcontainers/testcontainers-dotnet PR: 1583
File: src/Testcontainers.KurrentDb/Testcontainers.KurrentDb.csproj:7-7
Timestamp: 2025-11-17T17:58:43.958Z
Learning: In the testcontainers-dotnet repository, JetBrains.Annotations should use version 2023.3.0 to maintain consistency with the main Testcontainers csproj, rather than always using the latest available version.

Applied to files:

  • examples/Respawn/Directory.Packages.props
  • examples/WeatherForecast/Directory.Packages.props
  • examples/WeatherForecast/tests/WeatherForecast.InProcess.Tests/WeatherForecastTest.cs
  • examples/Flyway/Directory.Packages.props
🔇 Additional comments (11)
examples/Respawn/Directory.Packages.props (2)

9-9: Testcontainers.PostgreSql update looks good.

The version update aligns with the PR objectives.


14-14: No action required—Respawn v7.0.0 release notes do not list breaking changes compared to 6.2.1. The major version bump includes features and dependency updates but no documented breaking API changes.

examples/WeatherForecast/Dockerfile (1)

13-13: .NET 10.0 is officially released and available from Microsoft.

.NET 10.0 was officially released on November 11, 2025, and is currently available from the Microsoft Container Registry. The Dockerfile's use of this version is appropriate and no longer a concern.

examples/Flyway/Directory.Packages.props (1)

9-9: Package version 4.10.0 is available and has no known security vulnerabilities.

The Testcontainers.PostgreSql version is confirmed in the NuGet registry with no reported CVEs or advisories for this specific release.

examples/WeatherForecast/tests/WeatherForecast.Tests/WeatherForecastImage.cs (1)

24-25: Remove Platform property addition as it is not part of the IImage interface.

The Platform property is not a required member of the IImage interface in Testcontainers for .NET 4.10.0. IImage exposes Registry, Repository, Name, Tag, Digest, and hostname resolver functionality—Platform is specific to the DockerImage implementation. Adding this property does not complete IImage implementation and suggests a misunderstanding of the interface contract.

Likely an incorrect or invalid review comment.

examples/Respawn/tests/Respawn.Tests/DbFixture.cs (1)

13-15: LGTM!

The migration from PostgreSqlBuilder().WithImage(...) to PostgreSqlBuilder("postgres:15-alpine") follows the updated Testcontainers API pattern and removes obsolete method chaining.

examples/Flyway/tests/Flyway.Tests/DbFixture.cs (1)

22-25: LGTM!

Good improvements:

  1. Both PostgreSqlBuilder and ContainerBuilder now use parameterized constructors with explicit image tags.
  2. The addition of -password command (line 36) ensures Flyway can authenticate with PostgreSQL using the default credentials.
  3. WaitStrategyMode.OneShot is appropriate for the Flyway container since it runs migrations once and exits.

Also applies to: 32-42

examples/WeatherForecast/tests/WeatherForecast.InProcess.Tests/WeatherForecastTest.cs (1)

6-6: LGTM!

The migration to the parameterized PostgreSqlBuilder("postgres:15.1") constructor follows the updated API pattern. The use of postgres:15.1 (specific version without Alpine) is consistent with other WeatherForecast examples in this PR.

examples/WeatherForecast/tests/WeatherForecast.Tests/WeatherForecastContainer.cs (2)

6-6: Good modernization to use X509CertificateLoader.

The switch from the deprecated X509Certificate2 constructor to X509CertificateLoader.LoadPkcs12FromFile aligns with .NET 9+ best practices where the file-loading constructors were marked obsolete.


30-43: LGTM!

Both builder instantiations follow the updated API patterns:

  • PostgreSqlBuilder("postgres:15.1") uses the parameterized constructor.
  • ContainerBuilder(Image) directly accepts the IImage instance instead of chaining .WithImage().
examples/WeatherForecast/Directory.Packages.props (1)

7-13: All package versions in Directory.Packages.props exist and are available on NuGet. The major version upgrades to 10.x for Entity Framework Core and related packages are consistent with the .NET 10 migration, and the pinned versions are stable and properly released.

@HofmeisterAn HofmeisterAn merged commit fd8a3b7 into develop Jan 2, 2026
11 checks passed
@HofmeisterAn HofmeisterAn deleted the feature/update-examples-to-4-10-0 branch January 2, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore A change that doesn't impact the existing functionality, e.g. internal refactorings or cleanups

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants