Skip to content

Commit 92fda54

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

151 files changed

Lines changed: 1237 additions & 1220 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

src/GitVersion.App.Tests/Helpers/ArgumentBuilder.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ public override string ToString()
1212
{
1313
var arguments = new StringBuilder();
1414

15-
if (!this.WorkingDirectory.IsNullOrWhiteSpace())
15+
if (!WorkingDirectory.IsNullOrWhiteSpace())
1616
{
17-
arguments.Append(" /targetpath \"").Append(this.WorkingDirectory).Append('\"');
17+
arguments.Append(" /targetpath \"").Append(WorkingDirectory).Append('\"');
1818
}
1919

20-
if (!this.LogFile.IsNullOrWhiteSpace())
20+
if (!LogFile.IsNullOrWhiteSpace())
2121
{
22-
arguments.Append(" /l \"").Append(this.LogFile).Append('\"');
22+
arguments.Append(" /l \"").Append(LogFile).Append('\"');
2323
}
2424

2525
arguments.Append(additionalArguments);

src/GitVersion.App.Tests/TagCheckoutInBuildAgentTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using GitVersion.Agents;
2-
using GitVersion.Core.Tests.Helpers;
32
using GitVersion.Helpers;
43
using GitVersion.Testing.Extensions;
4+
using GitVersion.Tests;
55
using LibGit2Sharp;
66

77
namespace GitVersion.App.Tests;

src/GitVersion.App/ArgumentParser.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ private static bool ParseSwitches(Arguments arguments, string? name, IReadOnlyLi
292292

293293
if (name.IsSwitch("verbosity"))
294294
{
295-
ParseVerbosity(arguments, value);
295+
arguments.Verbosity = ParseVerbosity(value);
296296
return true;
297297
}
298298

@@ -437,13 +437,8 @@ private static void ParseOutput(Arguments arguments, IEnumerable<string>? values
437437
}
438438
}
439439

440-
private static void ParseVerbosity(Arguments arguments, string? value)
441-
{
442-
if (!Enum.TryParse(value, true, out arguments.Verbosity))
443-
{
444-
throw new WarningException($"Could not parse Verbosity value '{value}'");
445-
}
446-
}
440+
private static Verbosity ParseVerbosity(string? value) =>
441+
Enum.TryParse(value, true, out Verbosity verbosity) ? verbosity : throw new WarningException($"Could not parse Verbosity value '{value}'");
447442

448443
private static void ParseOverrideConfig(Arguments arguments, IReadOnlyCollection<string>? values)
449444
{

src/GitVersion.App/Arguments.cs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,40 @@ namespace GitVersion;
55

66
internal class Arguments
77
{
8-
public AuthenticationInfo Authentication = new();
8+
public AuthenticationInfo Authentication { get; set; } = new();
99

10-
public string? ConfigurationFile;
11-
public IReadOnlyDictionary<object, object?> OverrideConfiguration = new Dictionary<object, object?>();
12-
public bool ShowConfiguration;
10+
public string? ConfigurationFile { get; set; }
11+
public IReadOnlyDictionary<object, object?> OverrideConfiguration { get; set; } = new Dictionary<object, object?>();
12+
public bool ShowConfiguration { get; set; }
1313

14-
public string? TargetPath;
14+
public string? TargetPath { get; set; }
1515

16-
public string? TargetUrl;
17-
public string? TargetBranch;
18-
public string? CommitId;
19-
public string? ClonePath;
16+
public string? TargetUrl { get; set; }
17+
public string? TargetBranch { get; set; }
18+
public string? CommitId { get; set; }
19+
public string? ClonePath { get; set; }
2020

21-
public bool Diag;
22-
public bool IsVersion;
23-
public bool IsHelp;
21+
public bool Diag { get; set; }
22+
public bool IsVersion { get; set; }
23+
public bool IsHelp { get; set; }
2424

25-
public bool NoFetch;
26-
public bool NoCache;
27-
public bool NoNormalize;
28-
public bool AllowShallow;
25+
public bool NoFetch { get; set; }
26+
public bool NoCache { get; set; }
27+
public bool NoNormalize { get; set; }
28+
public bool AllowShallow { get; set; }
2929

30-
public string? LogFilePath;
31-
public string? ShowVariable;
32-
public string? Format;
33-
public string? OutputFile;
34-
public ISet<OutputType> Output = new HashSet<OutputType>();
35-
public Verbosity Verbosity = Verbosity.Normal;
30+
public string? LogFilePath { get; set; }
31+
public string? ShowVariable { get; set; }
32+
public string? Format { get; set; }
33+
public string? OutputFile { get; set; }
34+
public ISet<OutputType> Output { get; set; } = new HashSet<OutputType>();
35+
public Verbosity Verbosity { get; set; } = Verbosity.Normal;
3636

37-
public bool UpdateWixVersionFile;
38-
public bool UpdateProjectFiles;
39-
public bool UpdateAssemblyInfo;
40-
public bool EnsureAssemblyInfo;
41-
public ISet<string> UpdateAssemblyInfoFileName = new HashSet<string>();
37+
public bool UpdateWixVersionFile { get; set; }
38+
public bool UpdateProjectFiles { get; set; }
39+
public bool UpdateAssemblyInfo { get; set; }
40+
public bool EnsureAssemblyInfo { get; set; }
41+
public ISet<string> UpdateAssemblyInfoFileName { get; set; } = new HashSet<string>();
4242

4343
public GitVersionOptions ToOptions()
4444
{
@@ -54,9 +54,9 @@ public GitVersionOptions ToOptions()
5454

5555
AuthenticationInfo =
5656
{
57-
Username = this.Authentication.Username,
58-
Password = this.Authentication.Password,
59-
Token = this.Authentication.Token
57+
Username = Authentication.Username,
58+
Password = Authentication.Password,
59+
Token = Authentication.Token
6060
},
6161

6262
ConfigurationInfo =
@@ -99,7 +99,7 @@ public GitVersionOptions ToOptions()
9999
OutputFile = OutputFile
100100
};
101101

102-
var workingDirectory = this.TargetPath?.TrimEnd('/', '\\');
102+
var workingDirectory = TargetPath?.TrimEnd('/', '\\');
103103
if (workingDirectory != null)
104104
{
105105
gitVersionOptions.WorkingDirectory = workingDirectory;

src/GitVersion.App/OverrideConfigurationOptionParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ private static bool IsSupportedPropertyType(Type propertyType)
5050
|| unwrappedType == typeof(VersionStrategies[]);
5151
}
5252

53-
internal void SetValue(string key, string value) => overrideConfiguration[key] = QuotedStringHelpers.UnquoteText(value);
53+
internal void SetValue(string key, string value) => this.overrideConfiguration[key] = QuotedStringHelpers.UnquoteText(value);
5454

5555
internal IReadOnlyDictionary<object, object?> GetOverrideConfiguration() => this.overrideConfiguration;
5656
}

src/GitVersion.BuildAgents/Agents/AppVeyor.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ internal class AppVeyor(IEnvironment environment, ILog log, IFileSystem fileSyst
1313

1414
public override string SetBuildNumber(GitVersionVariables variables)
1515
{
16-
var buildNumber = Environment.GetEnvironmentVariable("APPVEYOR_BUILD_NUMBER");
17-
var apiUrl = Environment.GetEnvironmentVariable("APPVEYOR_API_URL") ?? throw new Exception("APPVEYOR_API_URL environment variable not set");
16+
var buildNumber = this.environment.GetEnvironmentVariable("APPVEYOR_BUILD_NUMBER");
17+
var apiUrl = this.environment.GetEnvironmentVariable("APPVEYOR_API_URL") ?? throw new Exception("APPVEYOR_API_URL environment variable not set");
1818

1919
using var httpClient = GetHttpClient(apiUrl);
2020

@@ -40,7 +40,7 @@ public override string SetBuildNumber(GitVersionVariables variables)
4040

4141
public override string[] SetOutputVariables(string name, string? value)
4242
{
43-
var apiUrl = Environment.GetEnvironmentVariable("APPVEYOR_API_URL") ?? throw new Exception("APPVEYOR_API_URL environment variable not set");
43+
var apiUrl = this.environment.GetEnvironmentVariable("APPVEYOR_API_URL") ?? throw new Exception("APPVEYOR_API_URL environment variable not set");
4444
var httpClient = GetHttpClient(apiUrl);
4545

4646
var body = new
@@ -66,10 +66,10 @@ public override string[] SetOutputVariables(string name, string? value)
6666

6767
public override string? GetCurrentBranch(bool usingDynamicRepos)
6868
{
69-
var pullRequestBranchName = Environment.GetEnvironmentVariable("APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH");
69+
var pullRequestBranchName = this.environment.GetEnvironmentVariable("APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH");
7070
return !pullRequestBranchName.IsNullOrWhiteSpace()
7171
? pullRequestBranchName
72-
: this.Environment.GetEnvironmentVariable("APPVEYOR_REPO_BRANCH");
72+
: this.environment.GetEnvironmentVariable("APPVEYOR_REPO_BRANCH");
7373
}
7474

7575
public override bool PreventFetch() => false;

src/GitVersion.BuildAgents/Agents/AzurePipelines.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ public override string[] SetOutputVariables(string name, string? value) =>
1919

2020
public override string? GetCurrentBranch(bool usingDynamicRepos)
2121
{
22-
var gitBranch = Environment.GetEnvironmentVariable("GIT_BRANCH");
22+
var gitBranch = this.environment.GetEnvironmentVariable("GIT_BRANCH");
2323
if (gitBranch is not null)
2424
return gitBranch;
2525

26-
var sourceBranch = Environment.GetEnvironmentVariable("BUILD_SOURCEBRANCH");
26+
var sourceBranch = this.environment.GetEnvironmentVariable("BUILD_SOURCEBRANCH");
2727

2828
// https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml
2929
// BUILD_SOURCEBRANCH must be used only for "real" branches, not for tags.
@@ -37,7 +37,7 @@ public override string SetBuildNumber(GitVersionVariables variables)
3737
{
3838
// For AzurePipelines, we'll get the Build Number and insert GitVersion variables where
3939
// specified
40-
var buildNumberEnv = Environment.GetEnvironmentVariable("BUILD_BUILDNUMBER");
40+
var buildNumberEnv = this.environment.GetEnvironmentVariable("BUILD_BUILDNUMBER");
4141
if (buildNumberEnv.IsNullOrWhiteSpace())
4242
return variables.FullSemVer;
4343

src/GitVersion.BuildAgents/Agents/BitBucketPipelines.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ public override void WriteIntegration(Action<string?> writer, GitVersionVariable
5555
.Select(variable => $"export GITVERSION_{variable.Key.ToUpperInvariant()}={variable.Value}")
5656
.ToList();
5757

58-
this.FileSystem.File.WriteAllLines(this.propertyFile, exports);
58+
this.fileSystem.File.WriteAllLines(this.propertyFile, exports);
5959

6060
var psExports = variables
6161
.Select(variable => $"$GITVERSION_{variable.Key.ToUpperInvariant()} = \"{variable.Value}\"")
6262
.ToList();
6363

64-
this.FileSystem.File.WriteAllLines(this.ps1File, psExports);
64+
this.fileSystem.File.WriteAllLines(this.ps1File, psExports);
6565
}
6666

6767
public override string? GetCurrentBranch(bool usingDynamicRepos)
@@ -72,7 +72,7 @@ public override void WriteIntegration(Action<string?> writer, GitVersionVariable
7272

7373
private string? EvaluateEnvironmentVariable(string variableName)
7474
{
75-
var branchName = Environment.GetEnvironmentVariable(variableName);
75+
var branchName = this.environment.GetEnvironmentVariable(variableName);
7676
this.Log.Info("Evaluating environment variable {0} : {1}", variableName, branchName ?? "(null)");
7777
return branchName;
7878
}

src/GitVersion.BuildAgents/Agents/BuildKite.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ internal class BuildKite(IEnvironment environment, ILog log, IFileSystem fileSys
1010

1111
protected override string EnvironmentVariable => EnvironmentVariableName;
1212

13-
public override bool CanApplyToCurrentContext() => "true".Equals(Environment.GetEnvironmentVariable(EnvironmentVariable), StringComparison.OrdinalIgnoreCase);
13+
public override bool CanApplyToCurrentContext() => "true".Equals(this.environment.GetEnvironmentVariable(EnvironmentVariable), StringComparison.OrdinalIgnoreCase);
1414

1515
public override string SetBuildNumber(GitVersionVariables variables) =>
1616
string.Empty; // There is no equivalent function in BuildKite.
@@ -20,10 +20,10 @@ public override string[] SetOutputVariables(string name, string? value) =>
2020

2121
public override string? GetCurrentBranch(bool usingDynamicRepos)
2222
{
23-
var pullRequest = Environment.GetEnvironmentVariable("BUILDKITE_PULL_REQUEST");
23+
var pullRequest = this.environment.GetEnvironmentVariable("BUILDKITE_PULL_REQUEST");
2424
if (string.IsNullOrEmpty(pullRequest) || pullRequest == "false")
2525
{
26-
return Environment.GetEnvironmentVariable("BUILDKITE_BRANCH");
26+
return this.environment.GetEnvironmentVariable("BUILDKITE_BRANCH");
2727
}
2828

2929
// For pull requests BUILDKITE_BRANCH refers to the head, so adjust the

0 commit comments

Comments
 (0)