Skip to content

Commit 5742f38

Browse files
authored
Merge pull request #2759 from Evangelink/add-readonly
Make fields `readonly` where applicable
2 parents a4e734a + 011b072 commit 5742f38

File tree

8 files changed

+11
-11
lines changed

8 files changed

+11
-11
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace GitVersion.App.Tests
1212
{
1313
public sealed class ProgramFixture
1414
{
15-
private IEnvironment environment;
15+
private readonly IEnvironment environment;
1616
public List<Action<IServiceCollection>> Overrides { get; } = new List<Action<IServiceCollection>>();
1717
private readonly Lazy<string> logger;
1818
private readonly Lazy<string> output;

src/GitVersion.App/GlobbingResolver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace GitVersion
99
{
1010
public class GlobbingResolver : IGlobbingResolver
1111
{
12-
private Matcher matcher = new Matcher(StringComparison.OrdinalIgnoreCase);
12+
private readonly Matcher matcher = new Matcher(StringComparison.OrdinalIgnoreCase);
1313

1414
public IEnumerable<string> Resolve(string workingDirectory, string pattern)
1515
{

src/GitVersion.App/OverrideConfigOptionParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ internal class OverrideConfigOptionParser
1010
private static readonly Lazy<ILookup<string, PropertyInfo>> _lazySupportedProperties =
1111
new Lazy<ILookup<string, PropertyInfo>>(GetSupportedProperties, true);
1212

13-
private Lazy<Config> _lazyConfig = new Lazy<Config>();
13+
private readonly Lazy<Config> _lazyConfig = new Lazy<Config>();
1414

1515
internal ILookup<string, PropertyInfo> SupportedProperties => _lazySupportedProperties.Value;
1616

src/GitVersion.Core/Core/GitPreparer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class GitPreparer : IGitPreparer
2020
private readonly IGitRepositoryInfo repositoryInfo;
2121
private readonly IRepositoryStore repositoryStore;
2222
private readonly ICurrentBuildAgent buildAgent;
23-
private RetryAction<LockedFileException> retryAction;
23+
private readonly RetryAction<LockedFileException> retryAction;
2424

2525
private const string DefaultRemoteName = "origin";
2626

src/GitVersion.Core/Helpers/RetryAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public void Execute(Action operation)
2424
}
2525
public class RetryAction<T, Result> where T : Exception
2626
{
27-
private RetryPolicy<Result> retryPolicy;
27+
private readonly RetryPolicy<Result> retryPolicy;
2828

2929
public RetryAction(int maxRetries = 5)
3030
{

src/GitVersion.Core/VersionCalculation/BaseVersionCalculators/VersionInBranchNameVersionStrategy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace GitVersion.VersionCalculation
1313
/// </summary>
1414
public class VersionInBranchNameVersionStrategy : VersionStrategyBase
1515
{
16-
private IRepositoryStore repositoryStore;
16+
private readonly IRepositoryStore repositoryStore;
1717

1818
public VersionInBranchNameVersionStrategy(IRepositoryStore repositoryStore, Lazy<GitVersionContext> versionContext) : base(versionContext)
1919
{

src/GitVersion.LibGit2Sharp/Git/GitRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace GitVersion
1111
internal sealed class GitRepository : IMutatingGitRepository
1212
{
1313
private readonly ILog log;
14-
private Lazy<IRepository> repositoryLazy;
14+
private readonly Lazy<IRepository> repositoryLazy;
1515
private IRepository repositoryInstance => repositoryLazy.Value;
1616

1717
public GitRepository(ILog log, IGitRepositoryInfo repositoryInfo)

src/GitVersion.LibGit2Sharp/Git/GitRepositoryInfo.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ internal class GitRepositoryInfo : IGitRepositoryInfo
1010
private readonly IOptions<GitVersionOptions> options;
1111
private GitVersionOptions gitVersionOptions => options.Value;
1212

13-
private Lazy<string?> dynamicGitRepositoryPath;
14-
private Lazy<string?> dotGitDirectory;
15-
private Lazy<string?> gitRootPath;
16-
private Lazy<string> projectRootDirectory;
13+
private readonly Lazy<string?> dynamicGitRepositoryPath;
14+
private readonly Lazy<string?> dotGitDirectory;
15+
private readonly Lazy<string?> gitRootPath;
16+
private readonly Lazy<string> projectRootDirectory;
1717

1818
public GitRepositoryInfo(IOptions<GitVersionOptions> options)
1919
{

0 commit comments

Comments
 (0)