Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 12 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,20 @@ resharper_csharp_use_roslyn_logic_for_evident_types = true
# Alignment
resharper_csharp_align_multiline_parameter = true

# Qualify fields with "this."
# Qualify fields with `this.` in ReSharper
resharper_csharp_instance_members_qualify_members = field

# Qualify fields with `this.` in Roslyn
dotnet_style_qualification_for_field = true:error

# Do not qualify properties, methods, and events with `this.` in Roslyn
dotnet_style_qualification_for_property = false:error
dotnet_style_qualification_for_method = false:error
dotnet_style_qualification_for_event = false:error

# Make missing `this.` qualification an error
dotnet_diagnostic.IDE0009.severity = error

# IDE0005: Using directive is unnecessary.
dotnet_diagnostic.ide0005.severity = warning

Expand Down
2 changes: 1 addition & 1 deletion .github/skills/dotnet-dev/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public string RequiredProperty { get; set; } = string.Empty;
Use file-scoped namespaces:

```csharp
namespace GitVersion.Core;
namespace GitVersion;

public class MyClass
{
Expand Down
16 changes: 8 additions & 8 deletions new-cli/GitVersion.Calculation/CalculateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ public record CalculateSettings : GitVersionSettings;
[Command("calculate", "Calculates the version object from the git history.")]
public class CalculateCommand(ILogger<CalculateCommand> logger, IService service, IGitRepository repository) : ICommand<CalculateSettings>
{
private readonly ILogger _logger = logger.NotNull();
private readonly IService _service = service.NotNull();
private readonly IGitRepository _repository = repository.NotNull();
private readonly ILogger logger = logger.NotNull();
private readonly IService service = service.NotNull();
private readonly IGitRepository repository = repository.NotNull();

public Task<int> InvokeAsync(CalculateSettings settings, CancellationToken cancellationToken = default)
{
var value = _service.Call();
var value = this.service.Call();
if (settings.WorkDir != null)
{
_repository.DiscoverRepository(settings.WorkDir.FullName);
var branches = _repository.Branches.ToList();
_logger.LogInformation("Command : 'calculate', LogFile : '{logFile}', WorkDir : '{workDir}' ",
this.repository.DiscoverRepository(settings.WorkDir.FullName);
var branches = this.repository.Branches.ToList();
this.logger.LogInformation("Command : 'calculate', LogFile : '{logFile}', WorkDir : '{workDir}' ",
settings.LogFile, settings.WorkDir);
_logger.LogInformation("Found {count} branches", branches.Count);
this.logger.LogInformation("Found {count} branches", branches.Count);
}

return Task.FromResult(value);
Expand Down
6 changes: 3 additions & 3 deletions new-cli/GitVersion.Cli.Generator/TypeVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ namespace GitVersion;
internal class TypeVisitor(Func<INamedTypeSymbol, bool> searchQuery, CancellationToken cancellation)
: SymbolVisitor
{
private readonly HashSet<INamedTypeSymbol> _exportedTypes = new(SymbolEqualityComparer.Default);
private readonly HashSet<INamedTypeSymbol> exportedTypes = new(SymbolEqualityComparer.Default);

public ImmutableArray<INamedTypeSymbol> GetResults() => [.. _exportedTypes];
public ImmutableArray<INamedTypeSymbol> GetResults() => [.. this.exportedTypes];

public override void VisitAssembly(IAssemblySymbol symbol)
{
Expand All @@ -28,7 +28,7 @@ public override void VisitNamedType(INamedTypeSymbol type)

if (searchQuery(type))
{
_exportedTypes.Add(type);
this.exportedTypes.Add(type);
}
}
}
8 changes: 4 additions & 4 deletions new-cli/GitVersion.Configuration/ConfigCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ public record ConfigSettings : GitVersionSettings;
[Command("config", "Manages the GitVersion configuration file.")]
public class ConfigCommand(ILogger<ConfigCommand> logger, IService service) : ICommand<ConfigSettings>
{
private readonly ILogger _logger = logger.NotNull();
private readonly IService _service = service.NotNull();
private readonly ILogger logger = logger.NotNull();
private readonly IService service = service.NotNull();

public Task<int> InvokeAsync(ConfigSettings settings, CancellationToken cancellationToken = default)
{
var value = _service.Call();
_logger.LogInformation($"Command : 'config', LogFile : '{settings.LogFile}', WorkDir : '{settings.WorkDir}' ");
var value = this.service.Call();
this.logger.LogInformation($"Command : 'config', LogFile : '{settings.LogFile}', WorkDir : '{settings.WorkDir}' ");
return Task.FromResult(value);
}
}
8 changes: 4 additions & 4 deletions new-cli/GitVersion.Configuration/Init/ConfigInitCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ public record ConfigInitSettings : ConfigSettings;
[Command<ConfigCommand>("init", "Inits the configuration for current repository.")]
public class ConfigInitCommand(ILogger<ConfigInitCommand> logger, IService service) : ICommand<ConfigInitSettings>
{
private readonly ILogger _logger = logger.NotNull();
private readonly IService _service = service.NotNull();
private readonly ILogger logger = logger.NotNull();
private readonly IService service = service.NotNull();

public Task<int> InvokeAsync(ConfigInitSettings settings, CancellationToken cancellationToken = default)
{
var value = _service.Call();
_logger.LogInformation($"Command : 'config init', LogFile : '{settings.LogFile}', WorkDir : '{settings.WorkDir}' ");
var value = this.service.Call();
this.logger.LogInformation($"Command : 'config init', LogFile : '{settings.LogFile}', WorkDir : '{settings.WorkDir}' ");
return Task.FromResult(value);
}
}
8 changes: 4 additions & 4 deletions new-cli/GitVersion.Configuration/Show/ConfigShowCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ public record ConfigShowSettings : ConfigSettings;
[Command<ConfigCommand>("show", "Shows the effective configuration.")]
public class ConfigShowCommand(ILogger<ConfigShowCommand> logger, IService service) : ICommand<ConfigShowSettings>
{
private readonly ILogger _logger = logger.NotNull();
private readonly IService _service = service.NotNull();
private readonly ILogger logger = logger.NotNull();
private readonly IService service = service.NotNull();

public Task<int> InvokeAsync(ConfigShowSettings settings, CancellationToken cancellationToken = default)
{
var value = _service.Call();
_logger.LogInformation($"Command : 'config show', LogFile : '{settings.LogFile}', WorkDir : '{settings.WorkDir}' ");
var value = this.service.Call();
this.logger.LogInformation($"Command : 'config show', LogFile : '{settings.LogFile}', WorkDir : '{settings.WorkDir}' ");
return Task.FromResult(value);
}
}
16 changes: 8 additions & 8 deletions new-cli/GitVersion.Core/Infrastructure/LoggingEnricher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ namespace GitVersion.Infrastructure;
public class LoggingEnricher : ILogEventEnricher
{
public static readonly LoggingLevelSwitch LogLevel = new();
private string? _cachedLogFilePath;
private LogEventProperty? _cachedLogFilePathProp;
private string? cachedLogFilePath;
private LogEventProperty? cachedLogFilePathProp;

// this path and level will be set by the LogInterceptor.cs after parsing the settings
private static string _path = string.Empty;
private static string path = string.Empty;

public const string LogFilePathPropertyName = "LogFilePath";

Expand All @@ -20,25 +20,25 @@ public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propFactory)
// we won't have the setting, so a default value for the log file will be required
LogEventProperty logFilePathProp;

if (_cachedLogFilePathProp != null && _path.Equals(_cachedLogFilePath))
if (this.cachedLogFilePathProp != null && path.Equals(this.cachedLogFilePath))
{
// The Path hasn't changed, so let's use the cached property
logFilePathProp = _cachedLogFilePathProp;
logFilePathProp = this.cachedLogFilePathProp;
}
else
{
// We've got a new path for the log. Let's create a new property
// and cache it for future log events to use
_cachedLogFilePath = _path;
_cachedLogFilePathProp = logFilePathProp = propFactory.CreateProperty(LogFilePathPropertyName, _path);
this.cachedLogFilePath = path;
this.cachedLogFilePathProp = logFilePathProp = propFactory.CreateProperty(LogFilePathPropertyName, path);
}

logEvent.AddPropertyIfAbsent(logFilePathProp);
}

public static void Configure(string? logFile, Verbosity verbosity)
{
if (!string.IsNullOrWhiteSpace(logFile)) _path = logFile;
if (!string.IsNullOrWhiteSpace(logFile)) path = logFile;
LogLevel.MinimumLevel = GetLevelForVerbosity(verbosity);
}

Expand Down
8 changes: 4 additions & 4 deletions new-cli/GitVersion.Normalization/NormalizeCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ public record NormalizeSettings : GitVersionSettings;
[Command("normalize", "Normalizes the git repository for GitVersion calculations.")]
public class NormalizeCommand(ILogger<NormalizeCommand> logger, IService service) : ICommand<NormalizeSettings>
{
private readonly ILogger _logger = logger.NotNull();
private readonly IService _service = service.NotNull();
private readonly ILogger logger = logger.NotNull();
private readonly IService service = service.NotNull();

public Task<int> InvokeAsync(NormalizeSettings settings, CancellationToken cancellationToken = default)
{
var value = _service.Call();
_logger.LogInformation($"Command : 'normalize', LogFile : '{settings.LogFile}', WorkDir : '{settings.WorkDir}' ");
var value = this.service.Call();
this.logger.LogInformation($"Command : 'normalize', LogFile : '{settings.LogFile}', WorkDir : '{settings.WorkDir}' ");
return Task.FromResult(value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ namespace GitVersion.Commands;
[Command<OutputCommand>("assemblyinfo", "Outputs version to assembly")]
public class OutputAssemblyInfoCommand(ILogger<OutputAssemblyInfoCommand> logger, IService service) : ICommand<OutputAssemblyInfoSettings>
{
private readonly ILogger _logger = logger.NotNull();
private readonly IService _service = service.NotNull();
private readonly ILogger logger = logger.NotNull();
private readonly IService service = service.NotNull();

public Task<int> InvokeAsync(OutputAssemblyInfoSettings settings, CancellationToken cancellationToken = default)
{
var value = _service.Call();
var value = this.service.Call();
var versionInfo = settings.VersionInfo.Value;
_logger.LogInformation($"Command : 'output assemblyinfo', LogFile : '{settings.LogFile}', WorkDir : '{settings.OutputDir}', InputFile: '{settings.InputFile}', AssemblyInfo: '{settings.AssemblyinfoFile}' ");
_logger.LogInformation($"Version info: {versionInfo}");
this.logger.LogInformation($"Command : 'output assemblyinfo', LogFile : '{settings.LogFile}', WorkDir : '{settings.OutputDir}', InputFile: '{settings.InputFile}', AssemblyInfo: '{settings.AssemblyinfoFile}' ");
this.logger.LogInformation($"Version info: {versionInfo}");
return Task.FromResult(value);
}
}
8 changes: 4 additions & 4 deletions new-cli/GitVersion.Output/OutputCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ namespace GitVersion.Commands;
[Command("output", "Outputs the version object.")]
public class OutputCommand(ILogger<OutputCommand> logger, IService service) : ICommand<OutputSettings>
{
private readonly ILogger _logger = logger.NotNull();
private readonly IService _service = service.NotNull();
private readonly ILogger logger = logger.NotNull();
private readonly IService service = service.NotNull();

public Task<int> InvokeAsync(OutputSettings settings, CancellationToken cancellationToken = default)
{
var value = _service.Call();
_logger.LogInformation($"Command : 'output', LogFile : '{settings.LogFile}', WorkDir : '{settings.WorkDir}' ");
var value = this.service.Call();
this.logger.LogInformation($"Command : 'output', LogFile : '{settings.LogFile}', WorkDir : '{settings.WorkDir}' ");
return Task.FromResult(value);
}
}
8 changes: 4 additions & 4 deletions new-cli/GitVersion.Output/Project/OutputProjectCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ namespace GitVersion.Commands;
[Command<OutputCommand>("project", "Outputs version to project")]
public class OutputProjectCommand(ILogger<OutputProjectCommand> logger, IService service) : ICommand<OutputProjectSettings>
{
private readonly ILogger _logger = logger.NotNull();
private readonly IService _service = service.NotNull();
private readonly ILogger logger = logger.NotNull();
private readonly IService service = service.NotNull();

public Task<int> InvokeAsync(OutputProjectSettings settings, CancellationToken cancellationToken = default)
{
var value = _service.Call();
_logger.LogInformation($"Command : 'output project', LogFile : '{settings.LogFile}', WorkDir : '{settings.OutputDir}', InputFile: '{settings.InputFile}', Project: '{settings.ProjectFile}' ");
var value = this.service.Call();
this.logger.LogInformation($"Command : 'output project', LogFile : '{settings.LogFile}', WorkDir : '{settings.OutputDir}', InputFile: '{settings.InputFile}', Project: '{settings.ProjectFile}' ");
return Task.FromResult(value);
}
}
8 changes: 4 additions & 4 deletions new-cli/GitVersion.Output/Wix/OutputWixCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ namespace GitVersion.Commands;
[Command<OutputCommand>("wix", "Outputs version to wix file")]
public class OutputWixCommand(ILogger<OutputWixCommand> logger, IService service) : ICommand<OutputWixSettings>
{
private readonly ILogger _logger = logger.NotNull();
private readonly IService _service = service.NotNull();
private readonly ILogger logger = logger.NotNull();
private readonly IService service = service.NotNull();

public Task<int> InvokeAsync(OutputWixSettings settings, CancellationToken cancellationToken = default)
{
var value = _service.Call();
_logger.LogInformation($"Command : 'output wix', LogFile : '{settings.LogFile}', WorkDir : '{settings.OutputDir}', InputFile: '{settings.InputFile}', WixFile: '{settings.WixFile}' ");
var value = this.service.Call();
this.logger.LogInformation($"Command : 'output wix', LogFile : '{settings.LogFile}', WorkDir : '{settings.OutputDir}', InputFile: '{settings.InputFile}', WixFile: '{settings.WixFile}' ");
return Task.FromResult(value);
}
}
Loading
Loading