Skip to content

Commit 81cfc10

Browse files
authored
Fix some build warnings. (#2021)
1 parent 28b0763 commit 81cfc10

11 files changed

+50
-41
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ dotnet_diagnostic.RS0016.severity = error
4040
dotnet_diagnostic.RS0017.severity = error
4141

4242
# we should care more about this one day
43-
dotnet_diagnostic.RS0041.severity = warn
43+
dotnet_diagnostic.RS0041.severity = warning
4444

4545
# public api warnings silk.net doesn't care about
4646
dotnet_diagnostic.RS0026.severity = none # Don't add multiple public overloads with optional parameters

build/nuke/Build.CodeSigning.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ partial class Build
3535
{
3636
if (!CanCodeSign)
3737
{
38-
ControlFlow.Fail("SignClient username and/or password not specified.");
38+
Assert.Fail("SignClient username and/or password not specified.");
3939
}
4040

4141
var outputs = Enumerable.Empty<Output>();

build/nuke/Build.Core.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Nuke.Common;
88
using Nuke.Common.Tooling;
99
using Nuke.Common.Tools.DotNet;
10+
using Serilog;
1011
using static Nuke.Common.IO.FileSystemTasks;
1112
using static Nuke.Common.Tools.DotNet.DotNetTasks;
1213
using static Nuke.Common.Tooling.ProcessTasks;
@@ -57,7 +58,7 @@ partial class Build
5758
}
5859
else
5960
{
60-
Logger.Warn("Skipping gradlew clean as the \"native\" feature-set has not been specified.");
61+
Log.Warning("Skipping gradlew clean as the \"native\" feature-set has not been specified.");
6162
}
6263

6364
return outputs;

build/nuke/Build.Generation.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Nuke.Common.Tools.DotNet;
1212
using Octokit;
1313
using Octokit.Internal;
14+
using Serilog;
1415
using static Nuke.Common.Tools.DotNet.DotNetTasks;
1516
using static Nuke.Common.Tools.Git.GitTasks;
1617
using static Nuke.Common.Tooling.ProcessTasks;
@@ -31,7 +32,7 @@ partial class Build
3132
var project = OriginalSolution.GetProject("Silk.NET.BuildTools");
3233
if (project == default)
3334
{
34-
Logger.Error("Couldn't find BuildTools in the solution file.");
35+
Log.Error("Couldn't find BuildTools in the solution file.");
3536
return;
3637
}
3738

@@ -52,14 +53,14 @@ partial class Build
5253
{
5354
DotNet($"sln \"{Path.GetFileName(OriginalSolution.FileName)}\" add \"{missedOut}\"");
5455
}
55-
56+
5657
PrUpdatedBindings();
5758
}
5859
}
5960
)
6061
);
61-
62-
62+
63+
6364
void PrUpdatedBindings()
6465
{
6566
var pushableToken = EnvironmentInfo.GetVariable<string>("PUSHABLE_GITHUB_TOKEN");
@@ -89,13 +90,13 @@ void PrUpdatedBindings()
8990
Git("reset --hard", RootDirectory);
9091
if (GitCurrentCommit(RootDirectory) != curCommit) // might get "nothing to commit", you never know...
9192
{
92-
Logger.Info("Checking for existing branch...");
93+
Log.Information("Checking for existing branch...");
9394
var exists = StartProcess("git", $"checkout \"{newBranch}\"", RootDirectory)
9495
.AssertWaitForExit()
9596
.ExitCode == 0;
9697
if (!exists)
9798
{
98-
Logger.Info("None found, creating a new one...");
99+
Log.Information("None found, creating a new one...");
99100
Git($"checkout -b \"{newBranch}\"");
100101
}
101102

@@ -108,7 +109,7 @@ void PrUpdatedBindings()
108109
new ProductHeaderValue("Silk.NET-CI"),
109110
new InMemoryCredentialStore(new Credentials(pushableToken))
110111
);
111-
112+
112113
var pr = github.PullRequest.Create
113114
("dotnet", "Silk.NET", new($"Regenerate bindings as of {DateTime.UtcNow:dd/MM/yyyy}", newBranch, curBranch))
114115
.GetAwaiter()

build/nuke/Build.NuGet.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Nuke.Common;
1010
using Nuke.Common.Tooling;
1111
using Nuke.Common.Tools.DotNet;
12+
using Serilog;
1213
using static Nuke.Common.Tools.DotNet.DotNetTasks;
1314

1415
partial class Build
@@ -44,7 +45,7 @@ async Task<IEnumerable<Output>> PushPackages()
4445
.Select(x => x.Select(v => v.Value).ToList())
4546
.ToList();
4647
var first = true;
47-
Logger.Info($"Searching for packages in \"{RootDirectory / "build" / "output_packages"}\"...");
48+
Log.Information($"Searching for packages in \"{RootDirectory / "build" / "output_packages"}\"...");
4849
foreach (var files in allFiles)
4950
{
5051
if (first)
@@ -64,7 +65,7 @@ async Task<IEnumerable<Output>> PushPackages()
6465
{
6566
if (NugetUsername is null || NugetPassword is null)
6667
{
67-
ControlFlow.Fail
68+
Assert.Fail
6869
(
6970
"Both \"NugetUsername\" and \"NugetPassword\" must be specified if either are used."
7071
);

build/nuke/Build.PublicApi.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using Nuke.Common.Tooling;
1111
using Octokit;
1212
using Octokit.Internal;
13+
using Serilog;
1314
using static Nuke.Common.Tools.Git.GitTasks;
1415
using static Nuke.Common.Tooling.ProcessTasks;
1516
using static Nuke.Common.Tools.DotNet.DotNetTasks;
@@ -133,10 +134,10 @@ string FormatCmd
133134
// about adding dodgy MSBuild targets that could swipe it
134135
var githubToken = EnvironmentInfo.GetVariable<string>("GITHUB_TOKEN");
135136
EnvironmentInfo.SetVariable("GITHUB_TOKEN", string.Empty);
136-
137+
137138
// run the format command
138139
InheritedShell($"{cmd} --verify-no-changes").AssertZeroExitCode();
139-
140+
140141
// add our github token back
141142
EnvironmentInfo.SetVariable("GITHUB_TOKEN", githubToken);
142143
await AddOrUpdatePrComment("public_api", "public_api_declared", true);
@@ -184,13 +185,13 @@ void MakePr()
184185
Git("reset --hard", RootDirectory);
185186
if (GitCurrentCommit(RootDirectory) != curCommit) // might get "nothing to commit", you never know...
186187
{
187-
Logger.Info("Checking for existing branch...");
188+
Log.Information("Checking for existing branch...");
188189
var exists = StartProcess("git", $"checkout \"{newBranch}\"", RootDirectory)
189190
.AssertWaitForExit()
190191
.ExitCode == 0;
191192
if (!exists)
192193
{
193-
Logger.Info("None found, creating a new one...");
194+
Log.Information("None found, creating a new one...");
194195
Git($"checkout -b \"{newBranch}\"");
195196
}
196197

build/nuke/Build.ReviewHelpers.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Linq;
77
using Nuke.Common;
88
using Nuke.Common.IO;
9+
using Serilog;
910

1011
partial class Build
1112
{
@@ -27,13 +28,13 @@ partial class Build
2728
var missedOut = GetNewProjects();
2829
if (missedOut.Any())
2930
{
30-
Logger.Warn("Commands to add these for your convenience:");
31+
Log.Warning("Commands to add these for your convenience:");
3132
foreach (var file in missedOut)
3233
{
33-
Logger.Warn($"dotnet sln \"{Path.GetFileName(OriginalSolution.FileName)}\" add \"{file}\"");
34+
Log.Warning($"dotnet sln \"{Path.GetFileName(OriginalSolution.FileName)}\" add \"{file}\"");
3435
}
3536

36-
ControlFlow.Fail("Action required.");
37+
Assert.Fail("Action required.");
3738
}
3839
}
3940
)
@@ -46,7 +47,7 @@ List<string> GetNewProjects()
4647
.Concat(RootDirectory.GlobFiles("**/*.csproj"))
4748
.Where(x => !x.ToString().Contains("submodules"))
4849
.ToArray();
49-
Logger.Info($"Found {files.Length} csproj files in \"{RootDirectory}\"");
50+
Log.Information($"Found {files.Length} csproj files in \"{RootDirectory}\"");
5051
foreach (var file in files)
5152
{
5253
var found = false;
@@ -61,7 +62,7 @@ List<string> GetNewProjects()
6162

6263
if (!found && !AllowedExclusions.Contains(Path.GetFileNameWithoutExtension(file)))
6364
{
64-
Logger.Error
65+
Log.Error
6566
(
6667
"A project has not been included in the solution and will not be shipped! " +
6768
$"\"{file}\" if this is acceptable please add the project name (excluding the path and " +

build/nuke/Build.SolutionGenerator.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using Nuke.Common.IO;
1313
using Nuke.Common.ProjectModel;
1414
using Nuke.Common.Utilities;
15+
using Serilog;
1516
using static Nuke.Common.IO.FileSystemTasks;
1617
using static Nuke.Common.ProjectModel.ProjectModelTasks;
1718

@@ -28,7 +29,7 @@ partial class Build
2829
"specified, but if you don't want to run a build just use \"nuke sln --projects ...\" to run a dummy target."
2930
)]
3031
readonly string[] Projects;
31-
32+
3233
[Parameter("If specified, ignores any generated solution present and builds the entire project.", Name = "All")]
3334
readonly bool BuildAll;
3435

@@ -42,7 +43,7 @@ void GenerateSolution()
4243
{
4344
if (Projects is not { Length: > 0 })
4445
{
45-
Logger.Trace("Nothing to do for GenerateSolution.");
46+
Log.Verbose("Nothing to do for GenerateSolution.");
4647
return;
4748
}
4849

@@ -101,7 +102,7 @@ AbsolutePath Concat(AbsolutePath path, string next)
101102

102103
// make a new Solution object to prevent us mutating the OriginalSolution
103104
var genSln = ParseSolution(OriginalSolution.Path);
104-
105+
105106
// remove irrelevant projects
106107
foreach (var project in genSln.GetProjects("*"))
107108
{
@@ -112,8 +113,8 @@ AbsolutePath Concat(AbsolutePath path, string next)
112113
}
113114

114115
genSln.SaveAs(RootDirectory / "Silk.NET.gen.sln");
115-
Logger.Info($"Generated solution containing {genSln.AllProjects.Count} projects");
116+
Log.Information($"Generated solution containing {genSln.AllProjects.Count} projects");
116117
}
117-
118+
118119
Target Sln => CommonTarget();
119120
}

build/nuke/Build.Support.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using Nuke.Common.Tools.DotNet;
2020
using Nuke.Common.Utilities;
2121
using Octokit;
22+
using Serilog;
2223
using static Nuke.Common.IO.FileSystemTasks;
2324
using static Nuke.Common.Tooling.ProcessTasks;
2425
using static Nuke.Common.Tools.DotNet.DotNetTasks;
@@ -147,27 +148,27 @@ async Task AddOrUpdatePrComment(string type, string file, bool editOnly = false,
147148
var githubToken = EnvironmentInfo.GetVariable<string>("GITHUB_TOKEN");
148149
if (string.IsNullOrWhiteSpace(githubToken))
149150
{
150-
Logger.Info("GitHub token not found, skipping writing a comment.");
151+
Log.Information("GitHub token not found, skipping writing a comment.");
151152
return;
152153
}
153154

154155
var @ref = GitHubActions.Instance?.Ref;
155156
if (string.IsNullOrWhiteSpace(@ref))
156157
{
157-
Logger.Info("Not running in GitHub Actions, skipping writing a comment.");
158+
Log.Information("Not running in GitHub Actions, skipping writing a comment.");
158159
return;
159160
}
160161

161162
var prMatch = PrRegex.Match(@ref);
162163
if (!prMatch.Success || prMatch.Groups.Count < 2)
163164
{
164-
Logger.Info($"Couldn't match {@ref} to a PR, skipping writing a comment.");
165+
Log.Information($"Couldn't match {@ref} to a PR, skipping writing a comment.");
165166
return;
166167
}
167168

168169
if (!int.TryParse(prMatch.Groups[1].Value, out var pr))
169170
{
170-
Logger.Info($"Couldn't parse {@prMatch.Groups[1].Value} as an int, skipping writing a comment.");
171+
Log.Information($"Couldn't parse {@prMatch.Groups[1].Value} as an int, skipping writing a comment.");
171172
return;
172173
}
173174

@@ -181,7 +182,7 @@ async Task AddOrUpdatePrComment(string type, string file, bool editOnly = false,
181182
.FirstOrDefault(x => x.Body.Contains($"`{type}`") && x.User.Name == "github-actions[bot]");
182183
if (existingComment is null && editOnly)
183184
{
184-
Logger.Info("Edit only mode is on and no existing comment found, skipping writing a comment.");
185+
Log.Information("Edit only mode is on and no existing comment found, skipping writing a comment.");
185186
return;
186187
}
187188

@@ -198,12 +199,12 @@ async Task AddOrUpdatePrComment(string type, string file, bool editOnly = false,
198199

199200
if (existingComment is not null)
200201
{
201-
Logger.Info("Updated the comment on the PR.");
202+
Log.Information("Updated the comment on the PR.");
202203
await github.Issue.Comment.Update("dotnet", "Silk.NET", existingComment.Id, commentText);
203204
}
204205
else
205206
{
206-
Logger.Info("Added a comment to the PR.");
207+
Log.Information("Added a comment to the PR.");
207208
await github.Issue.Comment.Create("dotnet", "Silk.NET", pr, commentText);
208209
}
209210
}

build/nuke/Native/Core.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using Nuke.Common.Tools.Git;
1818
using Octokit;
1919
using Octokit.Internal;
20+
using Serilog;
2021
using static Nuke.Common.IO.CompressionTasks;
2122
using static Nuke.Common.IO.FileSystemTasks;
2223
using static Nuke.Common.IO.HttpTasks;
@@ -33,7 +34,7 @@ partial class Build {
3334
static string JobsArg => string.IsNullOrWhiteSpace(GitHubActions.Instance?.Job)
3435
? $" -j{Jobs}"
3536
: string.Empty;
36-
37+
3738
static int Jobs => string.IsNullOrWhiteSpace(GitHubActions.Instance?.Job)
3839
? Environment.ProcessorCount - 1
3940
: 1;
@@ -90,13 +91,13 @@ public void PrUpdatedNativeBinary(string name, [CanBeNull] string glob = null)
9091
Git("reset --hard", RootDirectory);
9192
if (GitCurrentCommit(RootDirectory) != curCommit) // might get "nothing to commit", you never know...
9293
{
93-
Logger.Info("Checking for existing branch...");
94+
Log.Information("Checking for existing branch...");
9495
var exists = StartProcess("git", $"checkout \"{newBranch}\"", RootDirectory)
9596
.AssertWaitForExit()
9697
.ExitCode == 0;
9798
if (!exists)
9899
{
99-
Logger.Info("None found, creating a new one...");
100+
Log.Information("None found, creating a new one...");
100101
Git($"checkout -b \"{newBranch}\"");
101102
}
102103

@@ -118,4 +119,4 @@ public void PrUpdatedNativeBinary(string name, [CanBeNull] string glob = null)
118119
}
119120
}
120121
}
121-
}
122+
}

0 commit comments

Comments
 (0)