Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
51f2d59
fix(src): use Regex cache in PathFilter
arturcic Jun 29, 2026
ebe79f9
fix(src): make overloaded methods adjacent (S4136)
arturcic Jun 29, 2026
dd40db0
fix(src): resolve LibGit2Sharp Sonar issues
arturcic Jun 29, 2026
d26b4dc
fix(src): resolve BuildAgents Sonar issues (S112, S1125)
arturcic Jun 29, 2026
eb68415
fix: resolve assorted Sonar issues
arturcic Jun 29, 2026
a4f5363
fix(app): resolve FileAppender Sonar issues (S108, S4663)
arturcic Jun 29, 2026
6b147e2
fix(config): resolve assorted Sonar issues
arturcic Jun 29, 2026
22ef9e5
fix(output): resolve Sonar issues (S3267, S1450)
arturcic Jun 29, 2026
e4f7688
fix(new-cli): resolve CommandBaseGenerator Sonar issue (S1125)
arturcic Jun 29, 2026
733ef48
fix(core): encapsulate public Options fields as properties (S1104)
arturcic Jun 29, 2026
c488cca
fix(core): match interface default parameter values in TaggedSemantic…
arturcic Jun 29, 2026
daaa657
fix(core): rename NextVersion.Equals parameter to match base (S927)
arturcic Jun 29, 2026
eb968dd
fix(core): resolve MINOR Sonar issues (S3260, S3267, S1210)
arturcic Jun 29, 2026
b2175c4
style: update editorconfig rules and enforce collection expressions
arturcic Jun 29, 2026
eb51e6a
fix(core): throw specific exceptions instead of System.Exception (S112)
arturcic Jun 29, 2026
6aef2ab
fix(core): seal equality types (S4035)
arturcic Jun 29, 2026
4dbe054
style(build): use collection expressions in ci solution (IDE0305)
arturcic Jun 29, 2026
eede7d4
fix(core): resolve MAJOR Sonar issues (S3925, S3358, S1066)
arturcic Jun 29, 2026
42cddbf
style: enforce braces for all control flow statements
arturcic Jun 29, 2026
617d169
style: enforce braces on control-flow statements (IDE0011)
arturcic Jun 29, 2026
b02f15e
style: disable S1192 (duplicate string literals) in test projects
arturcic Jun 29, 2026
9ff7871
fix: resolve remaining PR #4990 Sonar issues (S3220, S1125)
arturcic Jun 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ csharp_prefer_static_local_function = true:warning
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent

# Code-block preferences
csharp_prefer_braces = when_multiline:none
csharp_prefer_braces = true:error
csharp_prefer_simple_using_statement = true:warning

# Expression-level preferences
Expand Down Expand Up @@ -161,13 +161,16 @@ dotnet_style_qualification_for_event = false:error
dotnet_diagnostic.IDE0009.severity = error

# IDE0005: Using directive is unnecessary.
dotnet_diagnostic.ide0005.severity = warning
dotnet_diagnostic.IDE0005.severity = warning

# IDE0305: Use collection expression for fluent
dotnet_diagnostic.IDE0305.severity = error

# RCS1037: Remove trailing white-space.
dotnet_diagnostic.rcs1037.severity = error
dotnet_diagnostic.RCS1037.severity = error

# RCS1036: Remove redundant empty line.
dotnet_diagnostic.rcs1036.severity = error
dotnet_diagnostic.RCS1036.severity = error

dotnet_diagnostic.S2325.severity = none
dotnet_diagnostic.S4136.severity = none
Expand All @@ -181,3 +184,9 @@ resharper_arrange_object_creation_when_type_not_evident_highlighting = none
resharper_unused_auto_property_accessor_global_highlighting = none

resharper_unused_method_return_value_global_highlighting = none

# Test projects
# Repeated string literals in tests (branch names, versions, config keys) are
# intentionally inline for readability, so don't flag duplicate literals there.
[**/*.Tests/**.cs]
dotnet_diagnostic.S1192.severity = none
8 changes: 7 additions & 1 deletion build/artifacts/Tasks/ArtifactsDotnetToolTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,19 @@ public override bool ShouldRun(BuildContext context)
public override void Run(BuildContext context)
{
if (context.Version == null)
{
return;
}

var rootPrefix = string.Empty;
var version = context.Version.NugetVersion;

foreach (var dockerImage in context.Images)
{
if (context.SkipImageTesting(dockerImage)) continue;
if (context.SkipImageTesting(dockerImage))
{
continue;
}

var cmd = $"{rootPrefix}/scripts/test-global-tool.sh --version {version} --nugetPath {rootPrefix}/nuget --repoPath {rootPrefix}/repo";

Expand Down
2 changes: 2 additions & 0 deletions build/artifacts/Tasks/ArtifactsExecutableTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ public override void Run(BuildContext context)
private static void PackageTest(BuildContextBase context, string packageToTest)
{
if (context.Version == null)
{
return;
}

var outputDirectory = Paths.Packages.Combine("test");

Expand Down
8 changes: 7 additions & 1 deletion build/artifacts/Tasks/ArtifactsMsBuildCoreTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,19 @@ public override bool ShouldRun(BuildContext context)
public override void Run(BuildContext context)
{
if (context.Version == null)
{
return;
}

var rootPrefix = string.Empty;
var version = context.Version.NugetVersion;

foreach (var dockerImage in context.Images)
{
if (context.SkipImageTesting(dockerImage)) continue;
if (context.SkipImageTesting(dockerImage))
{
continue;
}

var cmd = $"{rootPrefix}/scripts/test-msbuild-task.sh --version {version} --nugetPath {rootPrefix}/nuget --repoPath {rootPrefix}/repo/tests/integration --targetframework net{dockerImage.TargetFramework}";

Expand Down
3 changes: 3 additions & 0 deletions build/artifacts/Tasks/ArtifactsMsBuildFullTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ public override bool ShouldRun(BuildContext context)
public override void Run(BuildContext context)
{
if (context.Version == null)
{
return;
}

var version = context.Version.NugetVersion;
var fullSemVer = context.Version.GitVersion.FullSemVer;

Expand Down
8 changes: 7 additions & 1 deletion build/artifacts/Tasks/ArtifactsNativeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,19 @@ public override bool ShouldRun(BuildContext context)
public override void Run(BuildContext context)
{
if (context.Version?.SemVersion == null)
{
return;
}

var version = context.Version.SemVersion.ToLower();
var rootPrefix = string.Empty;

foreach (var dockerImage in context.Images)
{
if (context.SkipImageTesting(dockerImage)) continue;
if (context.SkipImageTesting(dockerImage))
{
continue;
}

var runtime = "linux";
if (dockerImage.Distro.StartsWith("alpine"))
Expand Down
6 changes: 5 additions & 1 deletion build/artifacts/Tasks/ArtifactsPrepare.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ public override void Run(BuildContext context)
{
foreach (var dockerImage in context.Images)
{
if (context.SkipImageTesting(dockerImage)) continue;
if (context.SkipImageTesting(dockerImage))
{
continue;
}

context.DockerPullImage(dockerImage);
}
}
Expand Down
8 changes: 2 additions & 6 deletions build/build/Tasks/Package/PackageChocolatey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,12 @@ public override void Run(BuildContext context)
var artifactPath = context.MakeAbsolute(Paths.ArtifactsBinPortable).FullPath;

var portableSettings = GetChocolateyPackSettings(context, "GitVersion.Portable");
portableSettings.Files = context.GetFiles(artifactPath + "/**/*.*")
.Select(file => new ChocolateyNuSpecContent { Source = file.FullPath, Target = file.FullPath.Replace(artifactPath, "") })
.ToArray();
portableSettings.Files = [.. context.GetFiles(artifactPath + "/**/*.*").Select(file => new ChocolateyNuSpecContent { Source = file.FullPath, Target = file.FullPath.Replace(artifactPath, "") })];

context.ChocolateyPack(portableSettings);

var metaPackageSettings = GetChocolateyPackSettings(context, "GitVersion");
metaPackageSettings.Files = context.GetFiles(artifactPath + "/**/*.txt")
.Select(file => new ChocolateyNuSpecContent { Source = file.FullPath, Target = file.FullPath.Replace(artifactPath, "") })
.ToArray();
metaPackageSettings.Files = [.. context.GetFiles(artifactPath + "/**/*.txt").Select(file => new ChocolateyNuSpecContent { Source = file.FullPath, Target = file.FullPath.Replace(artifactPath, "") })];

metaPackageSettings.Dependencies =
[
Expand Down
5 changes: 4 additions & 1 deletion build/build/Tasks/Package/PackagePrepare.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ private static void PackPrepareNative(BuildContext context)
var outputPath = PackPrepareNative(context, runtime);

// testing windows and macos artifacts, the linux is tested with docker
if (platform == PlatformFamily.Linux) continue;
if (platform == PlatformFamily.Linux)
{
continue;
}

if (context.IsRunningOnAmd64() && runtime.EndsWith("x64") || context.IsRunningOnArm64() && runtime.EndsWith("arm64"))
{
Expand Down
8 changes: 7 additions & 1 deletion build/common/Addins/GitVersion/GitVersionRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ public GitVersion Run(GitVersionSettings settings)
Run(settings, GetArguments(settings), new ProcessSettings { RedirectStandardOutput = true }, process =>
{
output = string.Join("\n", process.GetStandardOutput());
if (this._log.Verbosity >= Verbosity.Diagnostic) return;
if (this._log.Verbosity >= Verbosity.Diagnostic)
{
return;
}

var regex = ParseErrorRegex();
var errors = regex.Matches(output)
.SelectMany(match => new[] { match.Groups[1].Value, match.Groups[2].Value });
Expand All @@ -49,7 +53,9 @@ public GitVersion Run(GitVersionSettings settings)
});

if (!settings.OutputTypes.Contains(GitVersionOutput.Json))
{
return new GitVersion();
}

var jsonStartIndex = output.IndexOf('{');
var jsonEndIndex = output.IndexOf('}');
Expand Down
5 changes: 4 additions & 1 deletion build/common/Tasks/Default.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ public override void Run(ICakeContext context)
{
var entryAssembly = Assembly.GetEntryAssembly();
var tasks = entryAssembly?.FindAllDerivedTypes(typeof(IFrostingTask)).Where(x => !x.Name.Contains("Internal")).ToList();
if (tasks == null) return;
if (tasks == null)
{
return;
}

var defaultTask = tasks.Find(x => x.Name.Contains(nameof(Default)));
if (defaultTask != null && tasks.Remove(defaultTask))
Expand Down
24 changes: 19 additions & 5 deletions build/common/Utilities/ContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public IEnumerable<string> ExecuteCommand(FilePath exe, string? args, DirectoryP
}

context.StartProcess(exe, processSettings, out var redirectedOutput);
return redirectedOutput.ToList();
return [.. redirectedOutput];
}

private IEnumerable<string> ExecGitCmd(string? cmd, DirectoryPath? workDir = null)
Expand Down Expand Up @@ -84,9 +84,20 @@ public bool IsEnabled(string envVar, bool nullOrEmptyAsEnabled = true)

public string GetOS()
{
if (context.IsRunningOnWindows()) return "Windows";
if (context.IsRunningOnLinux()) return "Linux";
if (context.IsRunningOnMacOs()) return "macOs";
if (context.IsRunningOnWindows())
{
return "Windows";
}

if (context.IsRunningOnLinux())
{
return "Linux";
}

if (context.IsRunningOnMacOs())
{
return "macOs";
}

return string.Empty;
}
Expand Down Expand Up @@ -138,7 +149,10 @@ public void EndGroup()

public bool ShouldRun(bool criteria, string skipMessage)
{
if (criteria) return true;
if (criteria)
{
return true;
}

context.Information(skipMessage);
return false;
Expand Down
18 changes: 14 additions & 4 deletions build/common/Utilities/DockerContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ public bool SkipImageTesting(DockerImage dockerImage)

public void DockerBuildImage(DockerImage dockerImage)
{
if (context.Version == null) return;
if (context.Version == null)
{
return;
}

var (distro, targetFramework, arch, registry, _) = dockerImage;

Expand All @@ -65,7 +68,7 @@ public void DockerBuildImage(DockerImage dockerImage)
Rm = true,
Pull = true,
// NoCache = true,
Tag = tags.ToArray(),
Tag = [.. tags],
Platform = [$"linux/{suffix}"],
Output = ["type=docker,oci-mediatypes=true"],
File = workDir.CombineWithFilePath("Dockerfile").FullPath,
Expand Down Expand Up @@ -185,7 +188,11 @@ private IEnumerable<string> GetDockerTags(DockerImage dockerImage,
var distro = dockerImage.Distro;
var targetFramework = dockerImage.TargetFramework;

if (context.Version == null) return [];
if (context.Version == null)
{
return [];
}

var tags = new List<string>
{
$"{name}:{context.Version.Version}-{distro}-{targetFramework}",
Expand All @@ -209,7 +216,10 @@ private IEnumerable<string> GetDockerTags(DockerImage dockerImage,
}
}

if (!arch.HasValue) return tags.Distinct();
if (!arch.HasValue)
{
return tags.Distinct();
}

var suffix = arch.Value.ToSuffix();
return tags.Select(x => $"{x}-{suffix}").Distinct();
Expand Down
27 changes: 23 additions & 4 deletions build/common/Utilities/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,22 @@ public bool IsEqualInvariant(string other) =>
/// </summary>
public static string EscapeProcessArgument(this string literalValue, bool alwaysQuote = false)
{
if (string.IsNullOrEmpty(literalValue)) return "\"\"";
if (string.IsNullOrEmpty(literalValue))
{
return "\"\"";
}

if (literalValue.AsSpan().IndexOfAny(CharsRequiringQuoting) == -1) // Happy path
{
if (!alwaysQuote) return literalValue;
if (literalValue[^1] != '\\') return $"\"{literalValue}\"";
if (!alwaysQuote)
{
return literalValue;
}

if (literalValue[^1] != '\\')
{
return $"\"{literalValue}\"";
}
}

return BuildEscapedArgument(literalValue);
Expand All @@ -99,16 +109,23 @@ private static string BuildEscapedArgument(string s)
while (true)
{
var relativeIndex = s.AsSpan(nextPosition).IndexOfAny(CharsRequiringEscaping);
if (relativeIndex == -1) break;
if (relativeIndex == -1)
{
break;
}

var nextEscapeChar = nextPosition + relativeIndex;
sb.Append(s, nextPosition, relativeIndex);
nextPosition = nextEscapeChar + 1;

if (s[nextEscapeChar] == '"')
{
sb.Append("\\\"");
}
else
{
nextPosition = AppendEscapedBackslashes(sb, s, nextPosition);
}
}

return sb.Append(s, nextPosition, s.Length - nextPosition).Append('"').ToString();
Expand All @@ -123,7 +140,9 @@ private static int AppendEscapedBackslashes(StringBuilder sb, string s, int next
nextPosition++;
}
if (nextPosition == s.Length || s[nextPosition] == '"')
{
numBackslashes <<= 1;
}

sb.Append('\\', numBackslashes);
return nextPosition;
Expand Down
6 changes: 5 additions & 1 deletion build/docker/Tasks/DockerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ public override void Run(BuildContext context)
{
foreach (var dockerImage in context.Images)
{
if (context.SkipImageTesting(dockerImage)) continue;
if (context.SkipImageTesting(dockerImage))
{
continue;
}

context.DockerTestImage(dockerImage);
}
}
Expand Down
10 changes: 8 additions & 2 deletions build/docs/Tasks/PublishDocs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,18 @@ private static void PublishDocumentation(BuildContext context)
context.EnsureDirectoryExists(schemaTargetDir);
context.CopyDirectory(Paths.Schemas, schemaTargetDir);

if (!context.GitHasUncommitedChanges(publishFolder)) return;
if (!context.GitHasUncommitedChanges(publishFolder))
{
return;
}

context.Information("Stage all changes...");
context.GitAddAll(publishFolder);

if (!context.GitHasStagedChanges(publishFolder)) return;
if (!context.GitHasStagedChanges(publishFolder))
{
return;
}

context.Information("Commit all changes...");
context.GitCommit(
Expand Down
Loading
Loading