Skip to content

Fix CS9124: avoid double-storing primary-constructor log parameter#2018

Merged
matt-richardson merged 1 commit into
mainfrom
fix/cs9124-primary-ctor-capture
Jun 16, 2026
Merged

Fix CS9124: avoid double-storing primary-constructor log parameter#2018
matt-richardson merged 1 commit into
mainfrom
fix/cs9124-primary-ctor-capture

Conversation

@matt-richardson

Copy link
Copy Markdown
Contributor

What

Resolves CS9124 in KubernetesDiscovererBase.

Why

KubernetesDiscovererBase(ILog log) captured the log primary-constructor parameter (it's used in LogDeserialisationError) and also stored it in an explicit protected readonly ILog Log field. That holds the same value twice — the compiler's synthesised capture field plus the explicit field — which is what CS9124 flags.

Change

  • KubernetesDiscovererBase: removed the redundant protected readonly ILog Log = log; field. The base now relies solely on the captured log parameter.
  • AwsKubernetesDiscoverer: it previously used the inherited Log field, so it now keeps its own readonly ILog log = log; and uses it for TryGetCredentials(log, …). The remaining Log.Verbose(…) calls bind to the static Calamari.Common.Plumbing.Logging.Log logger.

Impact

  • Clears the CS9124 warning.
  • No behavioural change to logging output.
  • Calamari.Aws (and Calamari.Common) build clean.

🤖 Generated with Claude Code

KubernetesDiscovererBase captured the 'log' primary-constructor parameter
(via LogDeserialisationError) while also storing it in an explicit
'protected readonly ILog Log' field, so the value was held twice (CS9124).

Remove the redundant base field; the base now relies on the captured
parameter. AwsKubernetesDiscoverer keeps its own 'readonly ILog log = log'
field and uses it for TryGetCredentials, with the remaining Log.Verbose
calls binding to the static logger.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@matt-richardson matt-richardson requested a review from Jtango18 June 15, 2026 07:03
@matt-richardson matt-richardson marked this pull request as ready for review June 15, 2026 07:03
@matt-richardson matt-richardson merged commit 19b322b into main Jun 16, 2026
35 checks passed
@matt-richardson matt-richardson deleted the fix/cs9124-primary-ctor-capture branch June 16, 2026 01:34
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