Skip to content
This repository has been archived by the owner on Nov 19, 2019. It is now read-only.

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
matkoch committed Oct 24, 2019
1 parent 8a839fb commit 4adeb02
Show file tree
Hide file tree
Showing 24 changed files with 19 additions and 46 deletions.
2 changes: 0 additions & 2 deletions source/Nuke.CodeGeneration/Generators/ToolGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using Nuke.CodeGeneration.Model;
using Nuke.CodeGeneration.Writers;
using Nuke.Common.Utilities;
using Nuke.Common.Utilities.Collections;

// ReSharper disable UnusedMethodReturnValue.Local
Expand Down
2 changes: 1 addition & 1 deletion source/Nuke.CodeGeneration/Generators/WriterExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static T WriteSummary<T>(this T writerWrapper, Tool tool)
where T : IWriterWrapper
{
var paragraphs = new List<string>();
paragraphs.Add((tool.Help).Paragraph());
paragraphs.Add(tool.Help.Paragraph());
paragraphs.Add(GetOfficialUrlText(tool.OfficialUrl).Paragraph());
return writerWrapper.WriteSummary(paragraphs.ToArray());
}
Expand Down
2 changes: 1 addition & 1 deletion source/Nuke.CodeGeneration/ReferenceUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private static async System.Threading.Tasks.Task Update(string reference, Tool t
var index = tool.References.IndexOf(reference);
try
{
referencesDirectory = referencesDirectory ?? Path.GetDirectoryName(tool.SpecificationFile).NotNull();
referencesDirectory ??= Path.GetDirectoryName(tool.SpecificationFile).NotNull();
var referenceId = index.ToString().PadLeft(totalWidth: 3, paddingChar: '0');
var referenceFile = Path.Combine(
referencesDirectory,
Expand Down
4 changes: 2 additions & 2 deletions source/Nuke.Common.Tests/ParameterServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public class ParameterServiceTest
{
private ParameterService GetService(string[] commandLineArguments = null, IDictionary<string, string> environmentVariables = null)
{
commandLineArguments = commandLineArguments ?? new string[0];
environmentVariables = environmentVariables ?? new Dictionary<string, string>();
commandLineArguments ??= new string[0];
environmentVariables ??= new Dictionary<string, string>();

return new ParameterService(
() => commandLineArguments,
Expand Down
2 changes: 0 additions & 2 deletions source/Nuke.Common/CI/AppVeyor/AppVeyor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Nuke.Common.Tooling;
using Nuke.Common.Utilities;
using Refit;

namespace Nuke.Common.CI.AppVeyor
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public override void Write(CustomFileWriter writer)
writer.WriteLine("paths:");
using (writer.Indent())
{
(IncludePaths).ForEach(x => writer.WriteLine($"- {x}"));
(ExcludePaths).ForEach(x => writer.WriteLine($"- !{x}"));
IncludePaths.ForEach(x => writer.WriteLine($"- {x}"));
ExcludePaths.ForEach(x => writer.WriteLine($"- !{x}"));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

using System;
using System.Linq;
using JetBrains.Annotations;
using Nuke.Common.Utilities;

namespace Nuke.Common.CI.TeamCity.Configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// https://github.com/nuke-build/nuke/blob/master/LICENSE

using System;
using System.IO;
using System.Linq;
using Nuke.Common.Utilities;

Expand Down
2 changes: 0 additions & 2 deletions source/Nuke.Common/EnvironmentInfo.Parameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
// https://github.com/nuke-build/nuke/blob/master/LICENSE

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using JetBrains.Annotations;
using Nuke.Common.Execution;
using Nuke.Common.Utilities;

namespace Nuke.Common
{
Expand Down
2 changes: 1 addition & 1 deletion source/Nuke.Common/Execution/InjectionUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static class InjectionUtility
{
public static void InjectValues<T>(T instance = default, Func<InjectionAttributeBase, bool> filter = null)
{
filter = filter ?? (x => true);
filter ??= x => true;
InjectValuesInternal(instance, GetInjectionMembers(typeof(T)).Where(x => filter(x.Attribute)));
}

Expand Down
4 changes: 2 additions & 2 deletions source/Nuke.Common/Git/GitRepositoryExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static string GetGitHubDownloadUrl(this GitRepository repository, string
{
ControlFlow.Assert(repository.IsGitHubRepository(), "repository.IsGitHubRepository()");

branch = branch ?? repository.Branch.NotNull("repository.Branch != null");
branch ??= repository.Branch.NotNull("repository.Branch != null");
var relativePath = GetRepositoryRelativePath(file, repository);
return $"https://raw.githubusercontent.com/{repository.Identifier}/{branch}/{relativePath}";
}
Expand All @@ -94,7 +94,7 @@ public static string GetGitHubBrowseUrl(
{
ControlFlow.Assert(repository.IsGitHubRepository(), "repository.IsGitHubRepository()");

branch = branch ?? repository.Branch.NotNull("repository.Branch != null");
branch ??= repository.Branch.NotNull("repository.Branch != null");
var relativePath = GetRepositoryRelativePath(path, repository);
var method = GetMethod(relativePath, itemType, repository);
ControlFlow.Assert(path == null || method != null, "Could not determine item type.");
Expand Down
6 changes: 3 additions & 3 deletions source/Nuke.Common/IO/PathConstruction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public static string Combine([CanBeNull] string left, string right, char? separa
return !IsWinRoot(left) ? left : $@"{left}\";

AssertSeparatorChoice(left, separator);
separator = separator ?? GetSeparator(left);
separator ??= GetSeparator(left);

if (IsWinRoot(left))
return $@"{left}\{right}";
Expand All @@ -232,8 +232,8 @@ public static string NormalizePath([CanBeNull] string path, char? separator = nu
{
AssertSeparatorChoice(path, separator);

path = path ?? string.Empty;
separator = separator ?? GetSeparator(path);
path ??= string.Empty;
separator ??= GetSeparator(path);
var root = GetPathRoot(path);

var tail = root == null ? path : path.Substring(root.Length);
Expand Down
2 changes: 1 addition & 1 deletion source/Nuke.Common/IO/SerializationTasks.Json.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static T JsonDeserializeFromFile<T>(string path)
[Pure]
public static string JsonSerialize<T>(T obj, Configure<JsonSerializerSettings> configurator = null)
{
configurator = configurator ?? (x => x);
configurator ??= x => x;
var settings = new JsonSerializerSettings
{
Formatting = Formatting.Indented,
Expand Down
1 change: 0 additions & 1 deletion source/Nuke.Common/ParameterAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.Reflection;
using JetBrains.Annotations;
using Nuke.Common.Execution;
using Nuke.Common.Tooling;

namespace Nuke.Common
{
Expand Down
4 changes: 2 additions & 2 deletions source/Nuke.Common/ProjectModel/Solution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public IEnumerable<Project> GetProjects(string wildcardPattern)

public SolutionFolder AddSolutionFolder(string name, Guid? projectId = null, SolutionFolder solutionFolder = null)
{
projectId = projectId ?? Guid.NewGuid();
projectId ??= Guid.NewGuid();
var project = new SolutionFolder(this, projectId.Value, name, items: new Dictionary<string, string>());
AddPrimitiveProject(project, solutionFolder);
return project;
Expand All @@ -89,7 +89,7 @@ public Project AddProject(
IDictionary<string, string> configurationPlatforms = null,
SolutionFolder solutionFolder = null)
{
projectId = projectId ?? Guid.NewGuid();
projectId ??= Guid.NewGuid();
var project = new Project(this, projectId.Value, name, path, typeId, configurationPlatforms ?? new Dictionary<string, string>());
AddPrimitiveProject(project, solutionFolder);
return project;
Expand Down
1 change: 0 additions & 1 deletion source/Nuke.Common/ProjectModel/SolutionAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Linq;
using System.Reflection;
using JetBrains.Annotations;
using Nuke.Common.Execution;
using Nuke.Common.IO;

namespace Nuke.Common.ProjectModel
Expand Down
2 changes: 1 addition & 1 deletion source/Nuke.Common/Tooling/ProcessTasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static IProcess StartProcess(
toolPath = toolPathOverride;
}

outputFilter = outputFilter ?? (x => x);
outputFilter ??= x => x;
ControlFlow.Assert(File.Exists(toolPath), $"ToolPath '{toolPath}' does not exist.");
if (logInvocation ?? DefaultLogInvocation)
{
Expand Down
6 changes: 0 additions & 6 deletions source/Nuke.Common/Tools/CloudFoundry/CloudFoundryTasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,10 @@
// https://github.com/nuke-build/nuke/blob/master/LICENSE

using System;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using ICSharpCode.SharpZipLib.GZip;
using ICSharpCode.SharpZipLib.Tar;
using Nuke.Common.Tooling;
using static Nuke.Common.IO.HttpTasks;
using static Nuke.Common.IO.FileSystemTasks;

namespace Nuke.Common.Tools.CloudFoundry
{
Expand Down
6 changes: 0 additions & 6 deletions source/Nuke.Common/Tools/InnoSetup/InnoSetupSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@
// https://github.com/nuke-build/nuke/blob/master/LICENSE

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
using JetBrains.Annotations;

namespace Nuke.Common.Tools.InnoSetup
{
Expand Down
3 changes: 0 additions & 3 deletions source/Nuke.Common/Tools/MSBuild/MSBuildTasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
// https://github.com/nuke-build/nuke/blob/master/LICENSE

using System;
using System.Collections.Generic;
using System.Linq;
using Nuke.Common.IO;
using Nuke.Common.Tooling;

namespace Nuke.Common.Tools.MSBuild
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static IDictionary<TKey, TValue> ToDictionary<T, TKey, TValue>(
}
catch (ArgumentException exception)
{
exceptionFactory = exceptionFactory ?? ((ex, k) => ex);
exceptionFactory ??= (ex, k) => ex;
throw exceptionFactory(exception, key);
}
}
Expand Down
4 changes: 2 additions & 2 deletions source/Nuke.Common/Utilities/TemplateUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ public static string[] FillTemplate(
IReadOnlyCollection<string> definitions = null,
IReadOnlyDictionary<string, string> replacements = null)
{
definitions = definitions ?? new List<string>();
replacements = replacements ?? new Dictionary<string, string>();
definitions ??= new List<string>();
replacements ??= new Dictionary<string, string>();

// TODO: checked build?
// definitions.ForEach(x => ControlFlow.Assert(template.Contains(x),
Expand Down
1 change: 0 additions & 1 deletion source/Nuke.GlobalTool/Program.Complete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.Linq;
using JetBrains.Annotations;
using Nuke.Common;
using Nuke.Common.Execution;
using Nuke.Common.IO;
using Nuke.Common.Utilities;

Expand Down
1 change: 0 additions & 1 deletion source/Nuke.GlobalTool/Program.Setup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using System.Text;
using JetBrains.Annotations;
using Nuke.Common;
using Nuke.Common.Execution;
using Nuke.Common.IO;
using Nuke.Common.Tooling;
using Nuke.Common.Utilities;
Expand Down

0 comments on commit 4adeb02

Please sign in to comment.