Skip to content

Commit c457b11

Browse files
committed
Fixed code inspection problems
1 parent 4177904 commit c457b11

File tree

3 files changed

+59
-41
lines changed

3 files changed

+59
-41
lines changed
Lines changed: 55 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.IO;
2-
using System.Text;
1+
using System.Text;
32

43
public class ArgumentBuilder
54
{
@@ -8,53 +7,86 @@ public ArgumentBuilder(string workingDirectory)
87
this.workingDirectory = workingDirectory;
98
}
109

11-
public string WorkingDirectory
10+
11+
public ArgumentBuilder(string workingDirectory, string exec, string execArgs, string projectFile, string projectArgs, string logFile, bool isTeamCity)
1212
{
13-
get { return workingDirectory; }
13+
this.workingDirectory = workingDirectory;
14+
this.exec = exec;
15+
this.execArgs = execArgs;
16+
this.projectFile = projectFile;
17+
this.projectArgs = projectArgs;
18+
this.logFile = logFile;
19+
this.isTeamCity = isTeamCity;
1420
}
1521

16-
public string Exec { get; set; }
22+
public ArgumentBuilder(string workingDirectory, string additionalArguments, bool isTeamCity)
23+
{
24+
this.workingDirectory = workingDirectory;
25+
this.isTeamCity = isTeamCity;
26+
this.additionalArguments = additionalArguments;
27+
}
1728

18-
public string ExecArgs { get; set; }
1929

20-
public string ProjectFile { get; set; }
30+
public string WorkingDirectory
31+
{
32+
get { return workingDirectory; }
33+
}
2134

22-
public string ProjectArgs { get; set; }
2335

24-
public string LogFile { get; set; }
36+
public string LogFile
37+
{
38+
get { return logFile; }
39+
}
2540

26-
public bool IsTeamCity { get; set; }
41+
public bool IsTeamCity
42+
{
43+
get { return isTeamCity; }
44+
}
2745

28-
public string AdditionalArguments { get; set; }
2946

3047
public override string ToString()
3148
{
3249
var arguments = new StringBuilder();
3350

34-
arguments.AppendFormat("\"{0}\"", WorkingDirectory);
51+
arguments.AppendFormat("\"{0}\"", workingDirectory);
3552

36-
if (!string.IsNullOrWhiteSpace(Exec))
37-
arguments.AppendFormat(" /exec \"{0}\"", Exec);
53+
if (!string.IsNullOrWhiteSpace(exec))
54+
{
55+
arguments.AppendFormat(" /exec \"{0}\"", exec);
56+
}
3857

39-
if (!string.IsNullOrWhiteSpace(ExecArgs))
40-
arguments.AppendFormat(" /execArgs \"{0}\"", ExecArgs);
58+
if (!string.IsNullOrWhiteSpace(execArgs))
59+
{
60+
arguments.AppendFormat(" /execArgs \"{0}\"", execArgs);
61+
}
4162

42-
if (!string.IsNullOrWhiteSpace(ProjectFile))
43-
arguments.AppendFormat(" /proj \"{0}\"", ProjectFile);
63+
if (!string.IsNullOrWhiteSpace(projectFile))
64+
{
65+
arguments.AppendFormat(" /proj \"{0}\"", projectFile);
66+
}
4467

45-
if (!string.IsNullOrWhiteSpace(ProjectArgs))
46-
arguments.AppendFormat(" /projargs \"{0}\"", ProjectArgs);
68+
if (!string.IsNullOrWhiteSpace(projectArgs))
69+
{
70+
arguments.AppendFormat(" /projargs \"{0}\"", projectArgs);
71+
}
4772

48-
arguments.Append(AdditionalArguments);
73+
arguments.Append(additionalArguments);
4974

50-
if (!string.IsNullOrWhiteSpace(LogFile))
75+
if (!string.IsNullOrWhiteSpace(logFile))
5176
{
52-
arguments.AppendFormat(" /l \"{0}\"", LogFile);
77+
arguments.AppendFormat(" /l \"{0}\"", logFile);
5378
}
5479

5580
return arguments.ToString();
5681
}
5782

5883

84+
readonly string additionalArguments;
85+
readonly string exec;
86+
readonly string execArgs;
87+
readonly bool isTeamCity;
88+
readonly string logFile;
89+
readonly string projectArgs;
90+
readonly string projectFile;
5991
readonly string workingDirectory;
6092
}

GitVersionExe.Tests/ExecCmdLineArgumentTest.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.IO;
1+
using System.IO;
32
using NUnit.Framework;
43
using Shouldly;
54

GitVersionExe.Tests/GitVersionHelper.cs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,14 @@ public static ExecutionResults ExecuteIn(string workingDirectory,
1111
string exec = null, string execArgs = null, string projectFile = null, string projectArgs = null,
1212
bool isTeamCity = false)
1313
{
14-
var args = new ArgumentBuilder(workingDirectory)
15-
{
16-
Exec = exec,
17-
ExecArgs = execArgs,
18-
ProjectFile = projectFile,
19-
ProjectArgs = projectArgs,
20-
IsTeamCity = isTeamCity,
21-
LogFile = Path.Combine(workingDirectory, "log.txt")
22-
};
23-
14+
var logFile = Path.Combine(workingDirectory, "log.txt");
15+
var args = new ArgumentBuilder(workingDirectory, exec, execArgs, projectFile, projectArgs, logFile, isTeamCity);
2416
return ExecuteIn(args);
2517
}
2618

2719
public static ExecutionResults ExecuteIn(string workingDirectory, string arguments, bool isTeamCity = false)
2820
{
29-
var args = new ArgumentBuilder(workingDirectory)
30-
{
31-
AdditionalArguments = arguments,
32-
IsTeamCity = isTeamCity,
33-
};
34-
21+
var args = new ArgumentBuilder(workingDirectory, arguments, isTeamCity);
3522
return ExecuteIn(args);
3623
}
3724

0 commit comments

Comments
 (0)