Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dependencies] Updating Nullable.Extended.Analyzer (Code analysis) to 1.14.6129 #117

Merged
merged 4 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Please ADD ALL Changes to the UNRELEASED SECTION and not a specific release
- Dependencies - Updated xunit.analyzers to 1.7.0
- Dependencies - Updated xunit to 2.6.3
- Dependencies - Updated xunit.runner.visualstudio to 2.5.5
- Dependencies - Updated Nullable.Extended.Analyzer to 1.14.6129
### Removed
### Deployment Changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<PackageReference Include="Meziantou.Analyzer" Version="2.0.120" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.8.14" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="NSubstitute.Analyzers.CSharp" Version="1.0.16" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Nullable.Extended.Analyzer" Version="1.10.4539" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Nullable.Extended.Analyzer" Version="1.14.6129" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Philips.CodeAnalysis.DuplicateCodeAnalyzer" Version="1.1.7" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Philips.CodeAnalysis.MaintainabilityAnalyzers" Version="1.4.0" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Roslynator.Analyzers" Version="4.7.0" PrivateAssets="All" ExcludeAssets="runtime" />
Expand Down
8 changes: 4 additions & 4 deletions src/FunFair.BuildVersion.Detection/BranchClassification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ namespace FunFair.BuildVersion.Detection;

public sealed class BranchClassification : IBranchClassification
{
private const string PULL_REQUEST_PREFIX = @"refs/pull/";
private const string PULL_REQUEST_SUFFIX = @"/head";
private const string PULL_REQUEST_PREFIX = "refs/pull/";
private const string PULL_REQUEST_SUFFIX = "/head";
private readonly string _hotfixBranch;

private readonly string _releaseBranch;

public BranchClassification(IBranchSettings branchSettings)
{
this._releaseBranch = BuildBranch(branchSettings: branchSettings, branch: @"release");
this._hotfixBranch = BuildBranch(branchSettings: branchSettings, branch: @"hotfix");
this._releaseBranch = BuildBranch(branchSettings: branchSettings, branch: "release");
this._hotfixBranch = BuildBranch(branchSettings: branchSettings, branch: "hotfix");
}

public bool IsRelease(string branchName, [NotNullWhen(true)] out NuGetVersion? version)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace FunFair.BuildVersion.Detection.ExternalBranchLocators;
public sealed class GitBranchEnvironmentVariableBranchLocator : EnvironmentVariableBranchLocator
{
public GitBranchEnvironmentVariableBranchLocator(ILogger<GitBranchEnvironmentVariableBranchLocator> logger)
: base(environmentVariable: @"GIT_BRANCH", logger: logger)
: base(environmentVariable: "GIT_BRANCH", logger: logger)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace FunFair.BuildVersion.Detection.ExternalBranchLocators;
public sealed class GitHubRefEnvironmentVariableBranchLocator : EnvironmentVariableBranchLocator
{
public GitHubRefEnvironmentVariableBranchLocator(ILogger<GitHubRefEnvironmentVariableBranchLocator> logger)
: base(environmentVariable: @"GITHUB_REF", logger: logger)
: base(environmentVariable: "GITHUB_REF", logger: logger)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<PackageReference Include="FunFair.CodeAnalysis" Version="7.0.4.198" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.120" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.8.14" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Nullable.Extended.Analyzer" Version="1.10.4539" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Nullable.Extended.Analyzer" Version="1.14.6129" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Philips.CodeAnalysis.DuplicateCodeAnalyzer" Version="1.1.7" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Philips.CodeAnalysis.MaintainabilityAnalyzers" Version="1.4.0" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Roslynator.Analyzers" Version="4.7.0" PrivateAssets="All" ExcludeAssets="runtime" />
Expand Down
11 changes: 4 additions & 7 deletions src/FunFair.BuildVersion.Detection/PreReleaseTagBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@ internal static class PreReleaseTagBuilder

public static StringBuilder NormalizeSourceBranchName(this string currentBranch, IBranchClassification branchClassification)
{
if (branchClassification.IsPullRequest(currentBranch: currentBranch, out long pullRequestId))
{
return new(@"pr-" + pullRequestId.ToString(CultureInfo.InvariantCulture));
}

return new(currentBranch.ToLowerInvariant());
return new(branchClassification.IsPullRequest(currentBranch: currentBranch, out long pullRequestId)
? "pr-" + pullRequestId.ToString(CultureInfo.InvariantCulture)
: currentBranch.ToLowerInvariant());
}

public static StringBuilder ReplaceInvalidCharacters(this StringBuilder suffix)
Expand Down Expand Up @@ -81,7 +78,7 @@ public static string EnsureNotBlank(this StringBuilder suffix)

if (string.IsNullOrWhiteSpace(usedSuffix))
{
return @"prerelease";
return "prerelease";
}

return usedSuffix;
Expand Down
16 changes: 8 additions & 8 deletions src/FunFair.BuildVersion.Detection/VersionDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ public NuGetVersion FindVersion(int buildNumber)

private NuGetVersion DetermineLatestReleaseFromPreviousReleaseBranches(int buildNumber)
{
IReadOnlyList<string> branches = this._branchDiscovery.FindBranches();

NuGetVersion? latestVersion = branches.Select(GetReleaseVersion)
.RemoveNulls()
.Max();

return AddBuildNumberToVersion(latestVersion ?? InitialVersion, buildNumber: buildNumber);

NuGetVersion? GetReleaseVersion(string branch)
{
this._logger.LogDebug($" * => {branch}");
Expand All @@ -50,14 +58,6 @@ private NuGetVersion DetermineLatestReleaseFromPreviousReleaseBranches(int build
? version
: null;
}

IReadOnlyList<string> branches = this._branchDiscovery.FindBranches();

NuGetVersion? latestVersion = branches.Select(GetReleaseVersion)
.RemoveNulls()
.Max();

return AddBuildNumberToVersion(latestVersion ?? InitialVersion, buildNumber: buildNumber);
}

private static NuGetVersion AddBuildNumberToVersion(NuGetVersion version, int buildNumber)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<PackageReference Include="FunFair.CodeAnalysis" Version="7.0.4.198" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.120" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.8.14" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Nullable.Extended.Analyzer" Version="1.10.4539" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Nullable.Extended.Analyzer" Version="1.14.6129" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Philips.CodeAnalysis.DuplicateCodeAnalyzer" Version="1.1.7" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Philips.CodeAnalysis.MaintainabilityAnalyzers" Version="1.4.0" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Roslynator.Analyzers" Version="4.7.0" PrivateAssets="All" ExcludeAssets="runtime" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<PackageReference Include="Meziantou.Analyzer" Version="2.0.120" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.8.14" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="NSubstitute.Analyzers.CSharp" Version="1.0.16" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Nullable.Extended.Analyzer" Version="1.10.4539" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Nullable.Extended.Analyzer" Version="1.14.6129" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Philips.CodeAnalysis.DuplicateCodeAnalyzer" Version="1.1.7" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Philips.CodeAnalysis.MaintainabilityAnalyzers" Version="1.4.0" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Roslynator.Analyzers" Version="4.7.0" PrivateAssets="All" ExcludeAssets="runtime" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<PackageReference Include="FunFair.CodeAnalysis" Version="7.0.4.198" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.120" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.8.14" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Nullable.Extended.Analyzer" Version="1.10.4539" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Nullable.Extended.Analyzer" Version="1.14.6129" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Philips.CodeAnalysis.DuplicateCodeAnalyzer" Version="1.1.7" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Philips.CodeAnalysis.MaintainabilityAnalyzers" Version="1.4.0" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Roslynator.Analyzers" Version="4.7.0" PrivateAssets="All" ExcludeAssets="runtime" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ public void Publish(NuGetVersion version)
if (!string.IsNullOrEmpty(env))
{
File.AppendAllLines(path: env,
new[]
{
$"BUILD_VERSION={version}"
});
[
$"BUILD_VERSION={version}"
]);
}
}
}
1 change: 1 addition & 0 deletions src/FunFair.BuildVersion/EnumExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ namespace FunFair.BuildVersion;
[SuppressMessage(category: "ReSharper", checkId: "PartialTypeWithSinglePart", Justification = "Needed for generated code")]
internal static partial class EnumExtensions
{
// Code generated
}
62 changes: 2 additions & 60 deletions src/FunFair.BuildVersion/ExecutableVersionInformation.cs
Original file line number Diff line number Diff line change
@@ -1,64 +1,6 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;

namespace FunFair.BuildVersion;
namespace FunFair.BuildVersion;

internal static class ExecutableVersionInformation
{
public static string ProgramVersion()
{
return CommonVersion(typeof(Program));
}

private static string CommonVersion(Type type)
{
Assembly assembly = type.Assembly;

return GetAssemblyFileVersionFile() ?? GetAssemblyFileVersion(assembly) ?? GetAssemblyVersion(assembly);
}

private static string? GetAssemblyFileVersionFile()
{
IReadOnlyList<string> args = Environment.GetCommandLineArgs();

if (args.Count == 0)
{
return null;
}

string location = args[0];

if (string.IsNullOrWhiteSpace(location) || !File.Exists(location))
{
return null;
}

FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(location);

return fileVersionInfo.ProductVersion!;
}

private static string? GetAssemblyFileVersion(Assembly assembly)
{
AssemblyFileVersionAttribute? fvi = assembly.GetCustomAttributes<AssemblyFileVersionAttribute>()
.FirstOrDefault();

return fvi?.Version;
}

private static string GetAssemblyVersion(Assembly assembly)
{
Console.Write("Finding Assembly Version");
Version? assemblyVersion = assembly.GetName()
.Version;

return assemblyVersion is null
? throw new VersionNotFoundException()
: assemblyVersion.ToString();
}
public const string ProgramVersion = ThisAssembly.Info.FileVersion;
}
3 changes: 2 additions & 1 deletion src/FunFair.BuildVersion/FunFair.BuildVersion.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,15 @@
<PackageReference Include="FunFair.CodeAnalysis" Version="7.0.4.198" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.120" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.8.14" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Nullable.Extended.Analyzer" Version="1.10.4539" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Nullable.Extended.Analyzer" Version="1.14.6129" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Philips.CodeAnalysis.DuplicateCodeAnalyzer" Version="1.1.7" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Philips.CodeAnalysis.MaintainabilityAnalyzers" Version="1.4.0" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="Roslynator.Analyzers" Version="4.7.0" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="SecurityCodeScan.VS2019" Version="5.6.7" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="SmartAnalyzers.CSharpExtensions.Annotations" Version="4.2.8" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.15.0.81779" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="SourceLink.Create.CommandLine" Version="2.8.3" PrivateAssets="All" ExcludeAssets="runtime" />
<PackageReference Include="ThisAssembly.AssemblyInfo" Version="1.4.1" PrivateAssets="All" ExcludeAssets="runtime"/>
<PackageReference Include="ToStringWithoutOverrideAnalyzer" Version="0.6.0" PrivateAssets="All" ExcludeAssets="runtime" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions src/FunFair.BuildVersion/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static int Main(params string[] args)
{
try
{
Console.WriteLine($"{typeof(Program).Namespace} {ExecutableVersionInformation.ProgramVersion()}");
Console.WriteLine($"{typeof(Program).Namespace} {ExecutableVersionInformation.ProgramVersion}");

return Parser.Default.ParseArguments<Options>(args)
.MapResult(parsedFunc: ParsedOk, notParsedFunc: NotParsed);
Expand Down Expand Up @@ -145,7 +145,7 @@ private static int FindBuildNumber(int buildNumberFromCommandLine)
return buildNumberFromCommandLine;
}

string? buildNumber = Environment.GetEnvironmentVariable(variable: @"BUILD_NUMBER");
string? buildNumber = Environment.GetEnvironmentVariable(variable: "BUILD_NUMBER");

if (!string.IsNullOrWhiteSpace(buildNumber))
{
Expand Down
Loading