Skip to content

Commit 6b85b97

Browse files
committed
code cleanup
1 parent e64a293 commit 6b85b97

File tree

8 files changed

+20
-24
lines changed

8 files changed

+20
-24
lines changed

src/GitVersionTask.MsBuild/GitVersionTaskBase.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
using GitVersionTask.MsBuild;
22
using Microsoft.Build.Framework;
3-
using Microsoft.Build.Utilities;
43

54
namespace GitVersion.MSBuildTask
65
{
76
public abstract class GitVersionTaskBase : ITask
87
{
98
protected GitVersionTaskBase()
109
{
11-
this.Log = new TaskLoggingHelper(this);
10+
Log = new TaskLoggingHelper(this);
1211
}
1312

1413
[Required]

src/GitVersionTask.MsBuild/LibGit2Sharp/LibGit2SharpLoader.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// This code originally copied and adapted from https://raw.githubusercontent.com/dotnet/sourcelink/master/src/Microsoft.Build.Tasks.Git/TaskImplementation.cs
22

3+
4+
using System.IO;
5+
using System.Reflection;
36
#if NET472
47
using System;
58
using System.Collections.Generic;
69
#endif
710

8-
using System.IO;
9-
using System.Reflection;
10-
1111
namespace GitVersion.MSBuildTask.LibGit2Sharp
1212
{
1313
public class LibGit2SharpLoader

src/GitVersionTask.MsBuild/PlatformAbstraction/Native/NativeMethods.Windows.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ internal static string RtlGetVersion()
3434
{
3535
return $"{osvi.dwMajorVersion}.{osvi.dwMinorVersion}.{osvi.dwBuildNumber}";
3636
}
37-
else
38-
{
39-
return null;
40-
}
37+
38+
return null;
4139
}
4240
}
4341
}

src/GitVersionTask.MsBuild/PlatformAbstraction/Native/PlatformApis.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,11 @@ private static string GetDarwinVersion()
6464
// it is OS X 10.0
6565
return "10.0";
6666
}
67-
else
68-
{
69-
// Mac OS X 10.1 mapped to Darwin 5.x, and the mapping continues that way
70-
// So just subtract 4 from the Darwin version.
71-
// https://en.wikipedia.org/wiki/Darwin_%28operating_system%29
72-
return $"10.{version.Major - 4}";
73-
}
67+
68+
// Mac OS X 10.1 mapped to Darwin 5.x, and the mapping continues that way
69+
// So just subtract 4 from the Darwin version.
70+
// https://en.wikipedia.org/wiki/Darwin_%28operating_system%29
71+
return $"10.{version.Major - 4}";
7472
}
7573

7674
private static string GetFreeBSDVersion()

src/GitVersionTask.MsBuild/PlatformAbstraction/RuntimeEnvironment.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,13 @@ private static string GetWindowsProductVersion()
7373
{
7474
return "7";
7575
}
76-
else if (ver.Minor == 2)
76+
77+
if (ver.Minor == 2)
7778
{
7879
return "8";
7980
}
80-
else if (ver.Minor == 3)
81+
82+
if (ver.Minor == 3)
8183
{
8284
return "81";
8385
}

src/GitVersionTask.MsBuild/TaskLoggingHelper.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using Microsoft.Build.Framework;
21
using System;
32
using System.Text;
3+
using Microsoft.Build.Framework;
44

55
namespace GitVersionTask.MsBuild
66
{
@@ -217,7 +217,7 @@ public void LogWarningFromException(Exception exception, bool showStackTrace)
217217

218218
if (showStackTrace)
219219
{
220-
message += System.Environment.NewLine + exception.StackTrace;
220+
message += Environment.NewLine + exception.StackTrace;
221221
}
222222

223223
LogWarning(message);
@@ -333,13 +333,13 @@ public void LogErrorFromException(Exception exception, bool showStackTrace, bool
333333

334334
string message;
335335

336-
if (!showDetail && (System.Environment.GetEnvironmentVariable("MSBUILDDIAGNOSTICS") == null)) // This env var is also used in ToolTask
336+
if (!showDetail && (Environment.GetEnvironmentVariable("MSBUILDDIAGNOSTICS") == null)) // This env var is also used in ToolTask
337337
{
338338
message = exception.Message;
339339

340340
if (showStackTrace)
341341
{
342-
message += System.Environment.NewLine + exception.StackTrace;
342+
message += Environment.NewLine + exception.StackTrace;
343343
}
344344
}
345345
else

src/GitVersionTask.MsBuild/TaskProxy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public static class TaskProxy
1212
public static Func<UpdateAssemblyInfo, bool> UpdateAssemblyInfo;
1313
public static Func<WriteVersionInfoToBuildLog, bool> WriteVersionInfoToBuildLog;
1414

15-
public static Exception InitialiseException = null;
15+
public static Exception InitialiseException;
1616
static TaskProxy()
1717
{
1818
try

src/GitVersionTask/GitVersionTasks.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using GitVersion.Extensions;
44
using GitVersion.Logging;
55
using GitVersion.MSBuildTask.Tasks;
6-
using Microsoft.Build.Framework;
76
using Microsoft.Extensions.DependencyInjection;
87
using Microsoft.Extensions.Options;
98

0 commit comments

Comments
 (0)