Skip to content

Commit b3c977d

Browse files
committed
Qualify this. prefix
Qualify `this.` prefix on private fields; unqualify it on all other class members.
1 parent 15c99ef commit b3c977d

163 files changed

Lines changed: 2018 additions & 1274 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,20 @@ resharper_csharp_use_roslyn_logic_for_evident_types = true
158158
# Alignment
159159
resharper_csharp_align_multiline_parameter = true
160160

161-
# Qualify fields with "this."
161+
# Qualify fields with `this.` in ReSharper
162162
resharper_csharp_instance_members_qualify_members = field
163163

164+
# Qualify fields with `this.` in Roslyn
165+
dotnet_style_qualification_for_field = true:error
166+
167+
# Do not qualify properties, methods, and events with `this.` in Roslyn
168+
dotnet_style_qualification_for_property = false:error
169+
dotnet_style_qualification_for_method = false:error
170+
dotnet_style_qualification_for_event = false:error
171+
172+
# Make missing `this.` qualification an error
173+
dotnet_diagnostic.IDE0009.severity = error
174+
164175
# IDE0005: Using directive is unnecessary.
165176
dotnet_diagnostic.ide0005.severity = warning
166177

new-cli/GitVersion.Calculation/CalculateCommand.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ public record CalculateSettings : GitVersionSettings;
99
[Command("calculate", "Calculates the version object from the git history.")]
1010
public class CalculateCommand(ILogger<CalculateCommand> logger, IService service, IGitRepository repository) : ICommand<CalculateSettings>
1111
{
12-
private readonly ILogger _logger = logger.NotNull();
13-
private readonly IService _service = service.NotNull();
14-
private readonly IGitRepository _repository = repository.NotNull();
12+
private readonly ILogger logger = logger.NotNull();
13+
private readonly IService service = service.NotNull();
14+
private readonly IGitRepository repository = repository.NotNull();
1515

1616
public Task<int> InvokeAsync(CalculateSettings settings, CancellationToken cancellationToken = default)
1717
{
18-
var value = _service.Call();
18+
var value = this.service.Call();
1919
if (settings.WorkDir != null)
2020
{
21-
_repository.DiscoverRepository(settings.WorkDir.FullName);
22-
var branches = _repository.Branches.ToList();
23-
_logger.LogInformation("Command : 'calculate', LogFile : '{logFile}', WorkDir : '{workDir}' ",
21+
this.repository.DiscoverRepository(settings.WorkDir.FullName);
22+
var branches = this.repository.Branches.ToList();
23+
this.logger.LogInformation("Command : 'calculate', LogFile : '{logFile}', WorkDir : '{workDir}' ",
2424
settings.LogFile, settings.WorkDir);
25-
_logger.LogInformation("Found {count} branches", branches.Count);
25+
this.logger.LogInformation("Found {count} branches", branches.Count);
2626
}
2727

2828
return Task.FromResult(value);

new-cli/GitVersion.Cli.Generator/TypeVisitor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ namespace GitVersion;
33
internal class TypeVisitor(Func<INamedTypeSymbol, bool> searchQuery, CancellationToken cancellation)
44
: SymbolVisitor
55
{
6-
private readonly HashSet<INamedTypeSymbol> _exportedTypes = new(SymbolEqualityComparer.Default);
6+
private readonly HashSet<INamedTypeSymbol> exportedTypes = new(SymbolEqualityComparer.Default);
77

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

1010
public override void VisitAssembly(IAssemblySymbol symbol)
1111
{
@@ -28,7 +28,7 @@ public override void VisitNamedType(INamedTypeSymbol type)
2828

2929
if (searchQuery(type))
3030
{
31-
_exportedTypes.Add(type);
31+
this.exportedTypes.Add(type);
3232
}
3333
}
3434
}

new-cli/GitVersion.Configuration/ConfigCommand.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ public record ConfigSettings : GitVersionSettings;
88
[Command("config", "Manages the GitVersion configuration file.")]
99
public class ConfigCommand(ILogger<ConfigCommand> logger, IService service) : ICommand<ConfigSettings>
1010
{
11-
private readonly ILogger _logger = logger.NotNull();
12-
private readonly IService _service = service.NotNull();
11+
private readonly ILogger logger = logger.NotNull();
12+
private readonly IService service = service.NotNull();
1313

1414
public Task<int> InvokeAsync(ConfigSettings settings, CancellationToken cancellationToken = default)
1515
{
16-
var value = _service.Call();
17-
_logger.LogInformation($"Command : 'config', LogFile : '{settings.LogFile}', WorkDir : '{settings.WorkDir}' ");
16+
var value = this.service.Call();
17+
this.logger.LogInformation($"Command : 'config', LogFile : '{settings.LogFile}', WorkDir : '{settings.WorkDir}' ");
1818
return Task.FromResult(value);
1919
}
2020
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ public record ConfigInitSettings : ConfigSettings;
88
[Command<ConfigCommand>("init", "Inits the configuration for current repository.")]
99
public class ConfigInitCommand(ILogger<ConfigInitCommand> logger, IService service) : ICommand<ConfigInitSettings>
1010
{
11-
private readonly ILogger _logger = logger.NotNull();
12-
private readonly IService _service = service.NotNull();
11+
private readonly ILogger logger = logger.NotNull();
12+
private readonly IService service = service.NotNull();
1313

1414
public Task<int> InvokeAsync(ConfigInitSettings settings, CancellationToken cancellationToken = default)
1515
{
16-
var value = _service.Call();
17-
_logger.LogInformation($"Command : 'config init', LogFile : '{settings.LogFile}', WorkDir : '{settings.WorkDir}' ");
16+
var value = this.service.Call();
17+
this.logger.LogInformation($"Command : 'config init', LogFile : '{settings.LogFile}', WorkDir : '{settings.WorkDir}' ");
1818
return Task.FromResult(value);
1919
}
2020
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ public record ConfigShowSettings : ConfigSettings;
88
[Command<ConfigCommand>("show", "Shows the effective configuration.")]
99
public class ConfigShowCommand(ILogger<ConfigShowCommand> logger, IService service) : ICommand<ConfigShowSettings>
1010
{
11-
private readonly ILogger _logger = logger.NotNull();
12-
private readonly IService _service = service.NotNull();
11+
private readonly ILogger logger = logger.NotNull();
12+
private readonly IService service = service.NotNull();
1313

1414
public Task<int> InvokeAsync(ConfigShowSettings settings, CancellationToken cancellationToken = default)
1515
{
16-
var value = _service.Call();
17-
_logger.LogInformation($"Command : 'config show', LogFile : '{settings.LogFile}', WorkDir : '{settings.WorkDir}' ");
16+
var value = this.service.Call();
17+
this.logger.LogInformation($"Command : 'config show', LogFile : '{settings.LogFile}', WorkDir : '{settings.WorkDir}' ");
1818
return Task.FromResult(value);
1919
}
2020
}

new-cli/GitVersion.Core/Infrastructure/LoggingEnricher.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ namespace GitVersion.Infrastructure;
66
public class LoggingEnricher : ILogEventEnricher
77
{
88
public static readonly LoggingLevelSwitch LogLevel = new();
9-
private string? _cachedLogFilePath;
10-
private LogEventProperty? _cachedLogFilePathProp;
9+
private string? cachedLogFilePath;
10+
private LogEventProperty? cachedLogFilePathProp;
1111

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

1515
public const string LogFilePathPropertyName = "LogFilePath";
1616

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

23-
if (_cachedLogFilePathProp != null && _path.Equals(_cachedLogFilePath))
23+
if (this.cachedLogFilePathProp != null && path.Equals(this.cachedLogFilePath))
2424
{
2525
// The Path hasn't changed, so let's use the cached property
26-
logFilePathProp = _cachedLogFilePathProp;
26+
logFilePathProp = this.cachedLogFilePathProp;
2727
}
2828
else
2929
{
3030
// We've got a new path for the log. Let's create a new property
3131
// and cache it for future log events to use
32-
_cachedLogFilePath = _path;
33-
_cachedLogFilePathProp = logFilePathProp = propFactory.CreateProperty(LogFilePathPropertyName, _path);
32+
this.cachedLogFilePath = path;
33+
this.cachedLogFilePathProp = logFilePathProp = propFactory.CreateProperty(LogFilePathPropertyName, path);
3434
}
3535

3636
logEvent.AddPropertyIfAbsent(logFilePathProp);
3737
}
3838

3939
public static void Configure(string? logFile, Verbosity verbosity)
4040
{
41-
if (!string.IsNullOrWhiteSpace(logFile)) _path = logFile;
41+
if (!string.IsNullOrWhiteSpace(logFile)) path = logFile;
4242
LogLevel.MinimumLevel = GetLevelForVerbosity(verbosity);
4343
}
4444

new-cli/GitVersion.Normalization/NormalizeCommand.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ public record NormalizeSettings : GitVersionSettings;
88
[Command("normalize", "Normalizes the git repository for GitVersion calculations.")]
99
public class NormalizeCommand(ILogger<NormalizeCommand> logger, IService service) : ICommand<NormalizeSettings>
1010
{
11-
private readonly ILogger _logger = logger.NotNull();
12-
private readonly IService _service = service.NotNull();
11+
private readonly ILogger logger = logger.NotNull();
12+
private readonly IService service = service.NotNull();
1313

1414
public Task<int> InvokeAsync(NormalizeSettings settings, CancellationToken cancellationToken = default)
1515
{
16-
var value = _service.Call();
17-
_logger.LogInformation($"Command : 'normalize', LogFile : '{settings.LogFile}', WorkDir : '{settings.WorkDir}' ");
16+
var value = this.service.Call();
17+
this.logger.LogInformation($"Command : 'normalize', LogFile : '{settings.LogFile}', WorkDir : '{settings.WorkDir}' ");
1818
return Task.FromResult(value);
1919
}
2020
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ namespace GitVersion.Commands;
66
[Command<OutputCommand>("assemblyinfo", "Outputs version to assembly")]
77
public class OutputAssemblyInfoCommand(ILogger<OutputAssemblyInfoCommand> logger, IService service) : ICommand<OutputAssemblyInfoSettings>
88
{
9-
private readonly ILogger _logger = logger.NotNull();
10-
private readonly IService _service = service.NotNull();
9+
private readonly ILogger logger = logger.NotNull();
10+
private readonly IService service = service.NotNull();
1111

1212
public Task<int> InvokeAsync(OutputAssemblyInfoSettings settings, CancellationToken cancellationToken = default)
1313
{
14-
var value = _service.Call();
14+
var value = this.service.Call();
1515
var versionInfo = settings.VersionInfo.Value;
16-
_logger.LogInformation($"Command : 'output assemblyinfo', LogFile : '{settings.LogFile}', WorkDir : '{settings.OutputDir}', InputFile: '{settings.InputFile}', AssemblyInfo: '{settings.AssemblyinfoFile}' ");
17-
_logger.LogInformation($"Version info: {versionInfo}");
16+
this.logger.LogInformation($"Command : 'output assemblyinfo', LogFile : '{settings.LogFile}', WorkDir : '{settings.OutputDir}', InputFile: '{settings.InputFile}', AssemblyInfo: '{settings.AssemblyinfoFile}' ");
17+
this.logger.LogInformation($"Version info: {versionInfo}");
1818
return Task.FromResult(value);
1919
}
2020
}

new-cli/GitVersion.Output/OutputCommand.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ namespace GitVersion.Commands;
66
[Command("output", "Outputs the version object.")]
77
public class OutputCommand(ILogger<OutputCommand> logger, IService service) : ICommand<OutputSettings>
88
{
9-
private readonly ILogger _logger = logger.NotNull();
10-
private readonly IService _service = service.NotNull();
9+
private readonly ILogger logger = logger.NotNull();
10+
private readonly IService service = service.NotNull();
1111

1212
public Task<int> InvokeAsync(OutputSettings settings, CancellationToken cancellationToken = default)
1313
{
14-
var value = _service.Call();
15-
_logger.LogInformation($"Command : 'output', LogFile : '{settings.LogFile}', WorkDir : '{settings.WorkDir}' ");
14+
var value = this.service.Call();
15+
this.logger.LogInformation($"Command : 'output', LogFile : '{settings.LogFile}', WorkDir : '{settings.WorkDir}' ");
1616
return Task.FromResult(value);
1717
}
1818
}

0 commit comments

Comments
 (0)