Skip to content

Commit f05ae26

Browse files
committed
added "?? throw new ArgumentNullException(nameof({field}))" to the injected arguments
1 parent ecce434 commit f05ae26

21 files changed

+63
-60
lines changed

src/GitVersionCore/Cache/GitVersionCache.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public class GitVersionCache : IGitVersionCache
1616

1717
public GitVersionCache(IFileSystem fileSystem, ILog log)
1818
{
19-
this.fileSystem = fileSystem;
20-
this.log = log;
19+
this.fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
20+
this.log = log ?? throw new ArgumentNullException(nameof(log));
2121
}
2222

2323
public void WriteVariablesToDiskCache(IGitPreparer gitPreparer, GitVersionCacheKey cacheKey, VersionVariables variablesFromCache)

src/GitVersionCore/Configuration/BranchConfigurationCalculator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class BranchConfigurationCalculator : IBranchConfigurationCalculator
1616

1717
public BranchConfigurationCalculator(ILog log, GitVersionContext context)
1818
{
19-
this.log = log;
19+
this.log = log ?? throw new ArgumentNullException(nameof(log));
2020
this.context = context;
2121
}
2222

src/GitVersionCore/Configuration/ConfigFileLocator.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.IO;
23
using GitVersion.Logging;
34

@@ -10,8 +11,8 @@ public abstract class ConfigFileLocator : IConfigFileLocator
1011

1112
protected ConfigFileLocator(IFileSystem fileSystem, ILog log)
1213
{
13-
FileSystem = fileSystem;
14-
Log = log;
14+
FileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
15+
Log = log ?? throw new ArgumentNullException(nameof(log));
1516
}
1617

1718
public abstract bool HasConfigFileAt(string workingDirectory);

src/GitVersionCore/Configuration/ConfigurationProvider.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.IO;
23
using System.Text;
34
using GitVersion.Configuration.Init.Wizard;
@@ -15,11 +16,11 @@ public class ConfigurationProvider : IConfigurationProvider
1516

1617
public ConfigurationProvider(IFileSystem fileSystem, ILog log, IConfigFileLocator configFileLocator, IGitPreparer gitPreparer, IConfigInitWizard configInitWizard)
1718
{
18-
this.fileSystem = fileSystem;
19-
this.log = log;
20-
this.configFileLocator = configFileLocator;
21-
this.gitPreparer = gitPreparer;
22-
this.configInitWizard = configInitWizard;
19+
this.fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
20+
this.log = log ?? throw new ArgumentNullException(nameof(log));
21+
this.configFileLocator = configFileLocator ?? throw new ArgumentNullException(nameof(configFileLocator));
22+
this.gitPreparer = gitPreparer ?? throw new ArgumentNullException(nameof(gitPreparer));
23+
this.configInitWizard = configInitWizard ?? throw new ArgumentNullException(nameof(this.configInitWizard));
2324
}
2425

2526
public Config Provide(bool applyDefaults = true, Config overrideConfig = null)

src/GitVersionCore/Configuration/Init/Wizard/ConfigInitStepFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public ConfigInitStepFactory()
1313

1414
public ConfigInitStepFactory(IServiceProvider sp)
1515
{
16-
this.sp = sp;
16+
this.sp = sp ?? throw new ArgumentNullException(nameof(sp));
1717
}
1818

1919
public T CreateStep<T>() => sp.GetService<T>();

src/GitVersionCore/Configuration/Init/Wizard/ConfigInitWizard.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Collections.Generic;
23

34
namespace GitVersion.Configuration.Init.Wizard
@@ -9,8 +10,8 @@ public class ConfigInitWizard : IConfigInitWizard
910

1011
public ConfigInitWizard(IConsole console, IConfigInitStepFactory stepFactory)
1112
{
12-
this.console = console;
13-
this.stepFactory = stepFactory;
13+
this.console = console ?? throw new ArgumentNullException(nameof(console));
14+
this.stepFactory = stepFactory ?? throw new ArgumentNullException(nameof(stepFactory));
1415
}
1516

1617
public Config Run(Config config, string workingDirectory)

src/GitVersionCore/Configuration/Init/Wizard/ConfigInitWizardStep.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ public abstract class ConfigInitWizardStep
1313

1414
protected ConfigInitWizardStep(IConsole console, IFileSystem fileSystem, ILog log, IConfigInitStepFactory stepFactory)
1515
{
16-
Console = console;
17-
FileSystem = fileSystem;
18-
Log = log;
19-
StepFactory = stepFactory;
16+
Console = console ?? throw new ArgumentNullException(nameof(console));
17+
FileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
18+
Log = log ?? throw new ArgumentNullException(nameof(log));
19+
StepFactory = stepFactory ?? throw new ArgumentNullException(nameof(stepFactory));
2020
}
2121

2222
public bool Apply(Queue<ConfigInitWizardStep> steps, Config config, string workingDirectory)

src/GitVersionCore/Extensions/WixVersionFileUpdater.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ public class WixVersionFileUpdater : IDisposable
1818
public WixVersionFileUpdater(string workingDirectory, VersionVariables variables, IFileSystem fileSystem, ILog log)
1919
{
2020
this.variables = variables;
21-
this.fileSystem = fileSystem;
22-
this.log = log;
21+
this.fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
22+
this.log = log ?? throw new ArgumentNullException(nameof(log));
2323
this.WixVersionFile = Path.Combine(workingDirectory, WIX_VERSION_FILE);
2424
}
2525

src/GitVersionCore/GitPreparer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class GitPreparer : IGitPreparer
1919

2020
public GitPreparer(ILog log, Arguments arguments)
2121
{
22-
this.log = log;
22+
this.log = log ?? throw new ArgumentNullException(nameof(log));
2323

2424
TargetUrl = arguments.TargetUrl;
2525
WorkingDirectory = arguments.TargetPath.TrimEnd('/', '\\');

src/GitVersionCore/GitVersionCalculator.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ public GitVersionCalculator(IFileSystem fileSystem, ILog log, IConfigFileLocator
2525
IBuildServerResolver buildServerResolver, IGitVersionCache gitVersionCache,
2626
IGitVersionFinder gitVersionFinder, IGitPreparer gitPreparer, IVariableProvider variableProvider, IOptions<Arguments> options)
2727
{
28-
this.fileSystem = fileSystem;
29-
this.log = log;
30-
this.configFileLocator = configFileLocator;
31-
this.configurationProvider = configurationProvider;
32-
this.buildServerResolver = buildServerResolver;
33-
this.gitVersionCache = gitVersionCache;
34-
this.gitVersionFinder = gitVersionFinder;
35-
this.gitPreparer = gitPreparer;
36-
this.variableProvider = variableProvider;
28+
this.fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
29+
this.log = log ?? throw new ArgumentNullException(nameof(log));
30+
this.configFileLocator = configFileLocator ?? throw new ArgumentNullException(nameof(configFileLocator));
31+
this.configurationProvider = configurationProvider ?? throw new ArgumentNullException(nameof(configurationProvider));
32+
this.buildServerResolver = buildServerResolver ?? throw new ArgumentNullException(nameof(buildServerResolver));
33+
this.gitVersionCache = gitVersionCache ?? throw new ArgumentNullException(nameof(gitVersionCache));
34+
this.gitVersionFinder = gitVersionFinder ?? throw new ArgumentNullException(nameof(gitVersionFinder));
35+
this.gitPreparer = gitPreparer ?? throw new ArgumentNullException(nameof(gitPreparer));
36+
this.variableProvider = variableProvider ?? throw new ArgumentNullException(nameof(variableProvider));
3737
this.arguments = options.Value;
3838
}
3939

0 commit comments

Comments
 (0)