Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make commandName non-nullable in ConsoleActivityLogger
The commandName parameter is always provided from PipelineCommandBase.Name
and should never be null. Changed constructor signature to make it a
required parameter and removed null checks.

Co-authored-by: davidfowl <[email protected]>
  • Loading branch information
Copilot and davidfowl committed Nov 1, 2025
commit d8a8b60af3cfef85640a153b1ba6d514b4594cfc
2 changes: 1 addition & 1 deletion src/Aspire.Cli/Commands/PipelineCommandBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ public async Task<bool> ProcessAndDisplayPublishingActivitiesAsync(IAsyncEnumera
{
var stepCounter = 1;
var steps = new Dictionary<string, StepInfo>();
var logger = new ConsoleActivityLogger(_hostEnvironment, commandName: this.Name);
var logger = new ConsoleActivityLogger(_hostEnvironment, this.Name);
logger.StartSpinner();
PublishingActivity? publishingActivity = null;

Expand Down
6 changes: 3 additions & 3 deletions src/Aspire.Cli/Utils/ConsoleActivityLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal sealed class ConsoleActivityLogger
{
private readonly bool _enableColor;
private readonly ICliHostEnvironment _hostEnvironment;
private readonly string? _commandName;
private readonly string _commandName;
private readonly object _lock = new();
Copy link

Copilot AI Nov 1, 2025

Choose a reason for hiding this comment

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

[nitpick] The new field _commandName is placed between _hostEnvironment and _lock, disrupting the logical grouping of fields. Consider placing _commandName immediately after _hostEnvironment (line 20) and before _lock to maintain better field organization, as both _hostEnvironment and _commandName are constructor parameters that store configuration, while _lock begins the section of runtime state fields.

Suggested change
private readonly string _commandName;
private readonly object _lock = new();
private readonly object _lock = new();
private readonly string _commandName;

Copilot uses AI. Check for mistakes.
private readonly Stopwatch _stopwatch = Stopwatch.StartNew();
private readonly Dictionary<string, string> _stepColors = new();
Expand All @@ -44,7 +44,7 @@ internal sealed class ConsoleActivityLogger
private const string InProgressSymbol = "→";
private const string InfoSymbol = "i";

public ConsoleActivityLogger(ICliHostEnvironment hostEnvironment, bool? forceColor = null, string? commandName = null)
public ConsoleActivityLogger(ICliHostEnvironment hostEnvironment, string commandName, bool? forceColor = null)
{
_hostEnvironment = hostEnvironment;
_enableColor = forceColor ?? _hostEnvironment.SupportsAnsi;
Expand Down Expand Up @@ -256,7 +256,7 @@ public void WriteSummary()
AnsiConsole.MarkupLine(_finalStatusHeader!);

// If pipeline failed, show help message about using --log-level debug
if (!_pipelineSucceeded && !string.IsNullOrEmpty(_commandName))
if (!_pipelineSucceeded)
{
var helpMessage = _enableColor
? $"[dim]For more details, re-run with: aspire {_commandName} --log-level debug[/]"
Expand Down
Loading