Skip to content

Commit 2d242d3

Browse files
committed
Refactors logger injection in command classes
Changes ILogger injection to ILogger<T> in command classes. This aligns with best practices for dependency injection and improves logging context.
1 parent 4f61da0 commit 2d242d3

File tree

10 files changed

+9
-11
lines changed

10 files changed

+9
-11
lines changed

new-cli/GitVersion.Calculation/CalculateCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace GitVersion.Commands;
77
public record CalculateSettings : GitVersionSettings;
88

99
[Command("calculate", "Calculates the version object from the git history.")]
10-
public class CalculateCommand(ILogger logger, IService service, IGitRepository repository) : ICommand<CalculateSettings>
10+
public class CalculateCommand(ILogger<CalculateCommand> logger, IService service, IGitRepository repository) : ICommand<CalculateSettings>
1111
{
1212
private readonly ILogger _logger = logger.NotNull();
1313
private readonly IService _service = service.NotNull();

new-cli/GitVersion.Configuration/ConfigCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace GitVersion.Commands;
66
public record ConfigSettings : GitVersionSettings;
77

88
[Command("config", "Manages the GitVersion configuration file.")]
9-
public class ConfigCommand(ILogger logger, IService service) : ICommand<ConfigSettings>
9+
public class ConfigCommand(ILogger<ConfigCommand> logger, IService service) : ICommand<ConfigSettings>
1010
{
1111
private readonly ILogger _logger = logger.NotNull();
1212
private readonly IService _service = service.NotNull();

new-cli/GitVersion.Configuration/Init/ConfigInitCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace GitVersion.Commands;
66
public record ConfigInitSettings : ConfigSettings;
77

88
[Command<ConfigCommand>("init", "Inits the configuration for current repository.")]
9-
public class ConfigInitCommand(ILogger logger, IService service) : ICommand<ConfigInitSettings>
9+
public class ConfigInitCommand(ILogger<ConfigInitCommand> logger, IService service) : ICommand<ConfigInitSettings>
1010
{
1111
private readonly ILogger _logger = logger.NotNull();
1212
private readonly IService _service = service.NotNull();

new-cli/GitVersion.Configuration/Show/ConfigShowCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace GitVersion.Commands;
66
public record ConfigShowSettings : ConfigSettings;
77

88
[Command<ConfigCommand>("show", "Shows the effective configuration.")]
9-
public class ConfigShowCommand(ILogger logger, IService service) : ICommand<ConfigShowSettings>
9+
public class ConfigShowCommand(ILogger<ConfigShowCommand> logger, IService service) : ICommand<ConfigShowSettings>
1010
{
1111
private readonly ILogger _logger = logger.NotNull();
1212
private readonly IService _service = service.NotNull();

new-cli/GitVersion.Core/Extensions/ServiceCollectionExtensions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using GitVersion.Infrastructure;
22
using Microsoft.Extensions.DependencyInjection;
3-
using Microsoft.Extensions.Logging;
43
using Serilog;
5-
using ILogger = Serilog.ILogger;
64

75
namespace GitVersion.Extensions;
86

new-cli/GitVersion.Normalization/NormalizeCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace GitVersion.Commands;
66
public record NormalizeSettings : GitVersionSettings;
77

88
[Command("normalize", "Normalizes the git repository for GitVersion calculations.")]
9-
public class NormalizeCommand(ILogger logger, IService service) : ICommand<NormalizeSettings>
9+
public class NormalizeCommand(ILogger<NormalizeCommand> logger, IService service) : ICommand<NormalizeSettings>
1010
{
1111
private readonly ILogger _logger = logger.NotNull();
1212
private readonly IService _service = service.NotNull();

new-cli/GitVersion.Output/AssemblyInfo/OutputAssemblyInfoCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace GitVersion.Commands;
55

66
[Command<OutputCommand>("assemblyinfo", "Outputs version to assembly")]
7-
public class OutputAssemblyInfoCommand(ILogger logger, IService service) : ICommand<OutputAssemblyInfoSettings>
7+
public class OutputAssemblyInfoCommand(ILogger<OutputAssemblyInfoCommand> logger, IService service) : ICommand<OutputAssemblyInfoSettings>
88
{
99
private readonly ILogger _logger = logger.NotNull();
1010
private readonly IService _service = service.NotNull();

new-cli/GitVersion.Output/OutputCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace GitVersion.Commands;
55

66
[Command("output", "Outputs the version object.")]
7-
public class OutputCommand(ILogger logger, IService service) : ICommand<OutputSettings>
7+
public class OutputCommand(ILogger<OutputCommand> logger, IService service) : ICommand<OutputSettings>
88
{
99
private readonly ILogger _logger = logger.NotNull();
1010
private readonly IService _service = service.NotNull();

new-cli/GitVersion.Output/Project/OutputProjectCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace GitVersion.Commands;
55

66
[Command<OutputCommand>("project", "Outputs version to project")]
7-
public class OutputProjectCommand(ILogger logger, IService service) : ICommand<OutputProjectSettings>
7+
public class OutputProjectCommand(ILogger<OutputProjectCommand> logger, IService service) : ICommand<OutputProjectSettings>
88
{
99
private readonly ILogger _logger = logger.NotNull();
1010
private readonly IService _service = service.NotNull();

new-cli/GitVersion.Output/Wix/OutputWixCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace GitVersion.Commands;
55

66
[Command<OutputCommand>("wix", "Outputs version to wix file")]
7-
public class OutputWixCommand(ILogger logger, IService service) : ICommand<OutputWixSettings>
7+
public class OutputWixCommand(ILogger<OutputWixCommand> logger, IService service) : ICommand<OutputWixSettings>
88
{
99
private readonly ILogger _logger = logger.NotNull();
1010
private readonly IService _service = service.NotNull();

0 commit comments

Comments
 (0)