Skip to content

chore: Migrate to LoggerMessageAttribute#1697

Merged
HofmeisterAn merged 1 commit into
developfrom
feature/migrate-to-loggermessageattribute
May 29, 2026
Merged

chore: Migrate to LoggerMessageAttribute#1697
HofmeisterAn merged 1 commit into
developfrom
feature/migrate-to-loggermessageattribute

Conversation

@HofmeisterAn

@HofmeisterAn HofmeisterAn commented May 29, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

For high-performance logging scenarios in .NET, LoggerMessageAttribute replaces the legacy approach, LoggerMessage.Define. This PR removes the legacy implementation, adopts the modern approach, and also adds high-performance logging in three places where it was previously missing.

Why is it important?

-

Related issues

-

Summary by CodeRabbit

  • Version

    • Released version 4.13.0
  • Chores

    • Refactored internal logging implementation for improved efficiency

Review Change Stack

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

netlify Bot commented May 29, 2026

Copy link
Copy Markdown

Deploy Preview for testcontainers-dotnet ready!

Name Link
🔨 Latest commit 5619009
🔍 Latest deploy log https://app.netlify.com/projects/testcontainers-dotnet/deploys/6a19bad5a5872200088acd5a
😎 Deploy Preview https://deploy-preview-1697--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

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ac2a4081-f1d5-489d-80ef-8a6ebfe266df

📥 Commits

Reviewing files that changed from the base of the PR and between 571c175 and 5619009.

📒 Files selected for processing (4)
  • Directory.Build.props
  • src/Testcontainers/Clients/DockerApiClient.cs
  • src/Testcontainers/Containers/TarOutputMemoryStream.cs
  • src/Testcontainers/Logging.cs

Walkthrough

This PR modernizes the logging infrastructure by migrating from LoggerMessage.Define<> delegates to source-generated [LoggerMessage] partial methods, introduces new typed logging extension methods for Docker runtime and tar archive operations, updates consumer code to use these helpers, and bumps the package version to 4.13.0.

Changes

Logging Modernization

Layer / File(s) Summary
Logging infrastructure refactoring
src/Testcontainers/Logging.cs
Logging.cs replaces delegate-based LoggerMessage.Define<> pattern with source-generated internal static partial class and [LoggerMessage]-annotated methods. New public extension methods DockerRuntimeInfo(...) and two AddFileToTarArchive(...) overloads are added to support Docker runtime info logging and tar archive file logging with source/target paths, sizes, and permissions.
Consumer integration and version bump
src/Testcontainers/Clients/DockerApiClient.cs, src/Testcontainers/Containers/TarOutputMemoryStream.cs, Directory.Build.props
DockerApiClient and TarOutputMemoryStream replace direct LogInformation(...) calls with the new DockerRuntimeInfo(...) and AddFileToTarArchive(...) extension methods respectively. Both files add using DotNet.Testcontainers; to access the helpers. Package version is incremented from 4.12.0 to 4.13.0.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Logs refactored, patterns shine bright,
Source-generation makes logging light,
Docker runtimes and tar entries flow,
Version bumps to 4.13, steal the show! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description addresses the mandatory 'What does this PR do?' section but leaves the mandatory 'Why is it important?' section incomplete with only a dash, missing rationale and motivation details. Complete the 'Why is it important?' section by explaining the rationale, performance benefits, and motivation for migrating to LoggerMessageAttribute.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'chore: Migrate to LoggerMessageAttribute' accurately and concisely describes the main change: migrating from LoggerMessage.Define to the modern LoggerMessageAttribute approach for logging.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/migrate-to-loggermessageattribute

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.

@HofmeisterAn
HofmeisterAn merged commit 32acbf4 into develop May 29, 2026
204 of 227 checks passed
@HofmeisterAn
HofmeisterAn deleted the feature/migrate-to-loggermessageattribute branch May 29, 2026 18:27
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.

1 participant