Skip to content

Commit

Permalink
(GH-380) Multi-Target .NET 6, 7 & 8 (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalberger committed Nov 26, 2023
1 parent 88ce616 commit 8720609
Show file tree
Hide file tree
Showing 48 changed files with 136 additions and 230 deletions.
1 change: 1 addition & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ install:
- ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 5.0.408 -InstallDir $env:DOTNET_INSTALL_DIR'
- ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 6.0.417 -InstallDir $env:DOTNET_INSTALL_DIR'
- ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 7.0.404 -InstallDir $env:DOTNET_INSTALL_DIR'
- ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 8.0.100 -InstallDir $env:DOTNET_INSTALL_DIR'
- ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path"
- ps: dotnet --info

Expand Down
3 changes: 3 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@ jobs:
- task: UseDotNet@2
inputs:
version: '7.x'
- task: UseDotNet@2
inputs:
version: '8.x'
- powershell: ./build.ps1
displayName: 'Cake Build'
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"sdk": {
"allowPrerelease": true,
"version": "7.0.404",
"version": "8.0.100",
"rollForward": "latestFeature"
}
}
3 changes: 3 additions & 0 deletions nuspec/nuget/Cake.Issues.PullRequests.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@ See the Project Site for an overview of the whole ecosystem of addins for workin
<file src="net7.0\Cake.Issues.PullRequests.dll" target="lib\net7.0" />
<file src="net7.0\Cake.Issues.PullRequests.pdb" target="lib\net7.0" />
<file src="net7.0\Cake.Issues.PullRequests.xml" target="lib\net7.0" />
<file src="net8.0\Cake.Issues.PullRequests.dll" target="lib\net8.0" />
<file src="net8.0\Cake.Issues.PullRequests.pdb" target="lib\net8.0" />
<file src="net8.0\Cake.Issues.PullRequests.xml" target="lib\net8.0" />
</files>
</package>
3 changes: 3 additions & 0 deletions nuspec/nuget/Cake.Issues.Reporting.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@ See the Project Site for an overview of the whole ecosystem of addins for workin
<file src="net7.0\Cake.Issues.Reporting.dll" target="lib\net7.0" />
<file src="net7.0\Cake.Issues.Reporting.pdb" target="lib\net7.0" />
<file src="net7.0\Cake.Issues.Reporting.xml" target="lib\net7.0" />
<file src="net8.0\Cake.Issues.Reporting.dll" target="lib\net8.0" />
<file src="net8.0\Cake.Issues.Reporting.pdb" target="lib\net8.0" />
<file src="net8.0\Cake.Issues.Reporting.xml" target="lib\net8.0" />
</files>
</package>
3 changes: 3 additions & 0 deletions nuspec/nuget/Cake.Issues.Testing.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@ Common helpers for testing add-ins based on Cake.Issues
<file src="net7.0\Cake.Issues.Testing.dll" target="lib\net7.0" />
<file src="net7.0\Cake.Issues.Testing.pdb" target="lib\net7.0" />
<file src="net7.0\Cake.Issues.Testing.xml" target="lib\net7.0" />
<file src="net8.0\Cake.Issues.Testing.dll" target="lib\net8.0" />
<file src="net8.0\Cake.Issues.Testing.pdb" target="lib\net8.0" />
<file src="net8.0\Cake.Issues.Testing.xml" target="lib\net8.0" />
</files>
</package>
3 changes: 3 additions & 0 deletions nuspec/nuget/Cake.Issues.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,8 @@ See the Project Site for an overview of the whole ecosystem of addins for workin
<file src="net7.0\Cake.Issues.dll" target="lib\net7.0" />
<file src="net7.0\Cake.Issues.pdb" target="lib\net7.0" />
<file src="net7.0\Cake.Issues.xml" target="lib\net7.0" />
<file src="net8.0\Cake.Issues.dll" target="lib\net8.0" />
<file src="net8.0\Cake.Issues.pdb" target="lib\net8.0" />
<file src="net8.0\Cake.Issues.xml" target="lib\net8.0" />
</files>
</package>
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,10 @@
/// <summary>
/// Implementation of a <see cref="BaseCheckingCommitIdCapability{T}"/> for use in test cases.
/// </summary>
public class FakeCheckingCommitIdCapability : BaseCheckingCommitIdCapability<FakePullRequestSystem>
/// <param name="log">The Cake log context.</param>
/// <param name="pullRequestSystem">Pull request system to which this capability belongs.</param>
public class FakeCheckingCommitIdCapability(ICakeLog log, FakePullRequestSystem pullRequestSystem) : BaseCheckingCommitIdCapability<FakePullRequestSystem>(log, pullRequestSystem)
{
/// <summary>
/// Initializes a new instance of the <see cref="FakeCheckingCommitIdCapability"/> class.
/// </summary>
/// <param name="log">The Cake log context.</param>
/// <param name="pullRequestSystem">Pull request system to which this capability belongs.</param>
public FakeCheckingCommitIdCapability(ICakeLog log, FakePullRequestSystem pullRequestSystem)
: base(log, pullRequestSystem)
{
}

/// <summary>
/// Gets the Cake log context.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
/// </summary>
public class FakeDiscussionThreadsCapability : BaseDiscussionThreadsCapability<FakePullRequestSystem>
{
private readonly List<IPullRequestDiscussionThread> discussionThreads = new ();
private readonly List<IPullRequestDiscussionThread> resolvedThreads = new ();
private readonly List<IPullRequestDiscussionThread> reopenedThreads = new ();
private readonly List<IPullRequestDiscussionThread> discussionThreads = [];
private readonly List<IPullRequestDiscussionThread> resolvedThreads = [];
private readonly List<IPullRequestDiscussionThread> reopenedThreads = [];

/// <summary>
/// Initializes a new instance of the <see cref="FakeDiscussionThreadsCapability"/> class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/// </summary>
public class FakeFilteringByModifiedFilesCapability : BaseFilteringByModifiedFilesCapability<FakePullRequestSystem>
{
private readonly List<FilePath> modifiedFiles = new ();
private readonly List<FilePath> modifiedFiles = [];

/// <summary>
/// Initializes a new instance of the <see cref="FakeFilteringByModifiedFilesCapability"/> class.
Expand Down
14 changes: 3 additions & 11 deletions src/Cake.Issues.PullRequests.Tests/FakePullRequestSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,10 @@
/// <summary>
/// Implementation of a <see cref="BasePullRequestSystem"/> for use in test cases.
/// </summary>
public class FakePullRequestSystem : BasePullRequestSystem
/// <param name="log">The Cake log instance.</param>
public class FakePullRequestSystem(ICakeLog log) : BasePullRequestSystem(log)
{
private readonly List<IIssue> postedIssues = new ();

/// <summary>
/// Initializes a new instance of the <see cref="FakePullRequestSystem"/> class.
/// </summary>
/// <param name="log">The Cake log instance.</param>
public FakePullRequestSystem(ICakeLog log)
: base(log)
{
}
private readonly List<IIssue> postedIssues = [];

/// <summary>
/// Gets the log instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
public class FakePullRequestSystemBuilder
{
private readonly ICakeLog log;
private readonly List<IPullRequestDiscussionThread> discussionThreads = new ();
private readonly List<FilePath> modifiedFiles = new ();
private readonly List<IPullRequestDiscussionThread> discussionThreads = [];
private readonly List<FilePath> modifiedFiles = [];
private bool withCheckingCommitIdCapability;
private bool withDiscussionThreadsCapability;
private bool withFilteringByModifiedFilesCapability;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,10 @@
/// <summary>
/// Implementation of a <see cref="BasePullRequestSystemCapability{T}"/> for use in test cases.
/// </summary>
public class FakePullRequestSystemCapability : BasePullRequestSystemCapability<FakePullRequestSystem>
/// <param name="log">The Cake log context.</param>
/// <param name="pullRequestSystem">Pull request system to which this capability belongs.</param>
public class FakePullRequestSystemCapability(ICakeLog log, FakePullRequestSystem pullRequestSystem) : BasePullRequestSystemCapability<FakePullRequestSystem>(log, pullRequestSystem)
{
/// <summary>
/// Initializes a new instance of the <see cref="FakePullRequestSystemCapability"/> class.
/// </summary>
/// <param name="log">The Cake log context.</param>
/// <param name="pullRequestSystem">Pull request system to which this capability belongs.</param>
public FakePullRequestSystemCapability(ICakeLog log, FakePullRequestSystem pullRequestSystem)
: base(log, pullRequestSystem)
{
}

/// <summary>
/// Gets the Cake log context.
Expand Down
2 changes: 1 addition & 1 deletion src/Cake.Issues.PullRequests/BasePullRequestSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public abstract class BasePullRequestSystem
: BaseIssueComponent<IReportIssuesToPullRequestSettings>, IPullRequestSystem
{
private readonly List<IPullRequestSystemCapability> capabilities = new ();
private readonly List<IPullRequestSystemCapability> capabilities = [];

/// <summary>
/// Initializes a new instance of the <see cref="BasePullRequestSystem"/> class.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<Product>Cake.Issues</Product>
<Copyright>Copyright © BBT Software AG and contributors</Copyright>
Expand Down
2 changes: 1 addition & 1 deletion src/Cake.Issues.PullRequests/IssueFilterer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ internal class IssueFilterer
private static void ValidateModifiedFiles(IEnumerable<FilePath> modifiedFilePaths)
{
var absoluteFilePaths = modifiedFilePaths.Where(x => !x.IsRelative).ToList();
if (absoluteFilePaths.Any())
if (absoluteFilePaths.Count > 0)
{
throw new PullRequestIssuesException(
$"Absolute file paths are not supported for modified files:{Environment.NewLine}{string.Join(Environment.NewLine, absoluteFilePaths.Select(x => " " + x))}");
Expand Down
28 changes: 14 additions & 14 deletions src/Cake.Issues.PullRequests/Orchestrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private bool InitializePullRequestSystem(IReportIssuesToPullRequestSettings sett
/// <param name="reportIssuesToPullRequestSettings">Settings for posting the issues.</param>
/// <param name="issues">Issues to post.</param>
/// <returns>Issues reported to the pull request.</returns>
private IEnumerable<IIssue> PostAndResolveComments(
private List<IIssue> PostAndResolveComments(
IReportIssuesToPullRequestSettings reportIssuesToPullRequestSettings,
IList<IIssue> issues)
{
Expand Down Expand Up @@ -168,7 +168,7 @@ private bool InitializePullRequestSystem(IReportIssuesToPullRequestSettings sett
if (!issues.Any())
{
this.log.Information("No new issues were posted");
return new List<IIssue>();
return [];
}

// Filter issues which should not be posted.
Expand All @@ -182,7 +182,7 @@ private bool InitializePullRequestSystem(IReportIssuesToPullRequestSettings sett
existingThreads)
.ToList();

if (remainingIssues.Any())
if (remainingIssues.Count > 0)
{
if (!string.IsNullOrWhiteSpace(reportIssuesToPullRequestSettings.CommitId))
{
Expand All @@ -195,7 +195,7 @@ private bool InitializePullRequestSystem(IReportIssuesToPullRequestSettings sett
"Skipping posting of issues since commit {0} is outdated. Current commit is {1}",
reportIssuesToPullRequestSettings.CommitId,
checkCommitIdCapability.GetLastSourceCommitId());
return new List<IIssue>();
return [];
}
}

Expand Down Expand Up @@ -232,7 +232,7 @@ private bool InitializePullRequestSystem(IReportIssuesToPullRequestSettings sett
/// <param name="issues">Issues for which matching comments should be found.</param>
/// <param name="existingThreads">Existing discussion threads on the pull request.</param>
/// <returns>Dictionary with issues associated matching comments on the pull request.</returns>
private IDictionary<IIssue, IssueCommentInfo> GetCommentsForIssue(
private Dictionary<IIssue, IssueCommentInfo> GetCommentsForIssue(
IList<IIssue> issues,
IReadOnlyCollection<IPullRequestDiscussionThread> existingThreads)
{
Expand All @@ -254,9 +254,9 @@ private bool InitializePullRequestSystem(IReportIssuesToPullRequestSettings sett
var wontFixCommentsList = wontFixComments.ToList();
var resolvedCommentsList = resolvedComments.ToList();

if (!activeCommentsList.Any() &&
!wontFixCommentsList.Any() &&
!resolvedCommentsList.Any())
if (activeCommentsList.Count == 0 &&
wontFixCommentsList.Count == 0 &&
resolvedCommentsList.Count == 0)
{
continue;
}
Expand Down Expand Up @@ -303,7 +303,7 @@ private bool InitializePullRequestSystem(IReportIssuesToPullRequestSettings sett
.Where(x => FilePathsAreMatching(issue, x) && x.CommentIdentifier == issue.Identifier)
.ToList();

if (matchingThreads.Any())
if (matchingThreads.Count > 0)
{
this.log.Verbose(
"Found {0} matching thread(s) for the issue in file {1} on line {2}",
Expand All @@ -325,7 +325,7 @@ private bool InitializePullRequestSystem(IReportIssuesToPullRequestSettings sett
select
comment).ToList();

if (!matchingComments.Any())
if (matchingComments.Count == 0)
{
continue;
}
Expand Down Expand Up @@ -378,7 +378,7 @@ private bool InitializePullRequestSystem(IReportIssuesToPullRequestSettings sett
issueComments.NotNull(nameof(issueComments));
reportIssuesToPullRequestSettings.NotNull(nameof(reportIssuesToPullRequestSettings));

if (!existingThreads.Any())
if (existingThreads.Count == 0)
{
this.log.Verbose("No existing threads to resolve.");
return;
Expand All @@ -398,7 +398,7 @@ private bool InitializePullRequestSystem(IReportIssuesToPullRequestSettings sett
/// <param name="issueComments">Issues and their related existing comments on the pull request.</param>
/// <param name="reportIssuesToPullRequestSettings">Settings for posting the issues.</param>
/// <returns>List of threads which can be resolved.</returns>
private IEnumerable<IPullRequestDiscussionThread> GetThreadsToResolve(
private List<IPullRequestDiscussionThread> GetThreadsToResolve(
IReadOnlyCollection<IPullRequestDiscussionThread> existingThreads,
IDictionary<IIssue, IssueCommentInfo> issueComments,
IReportIssuesToPullRequestSettings reportIssuesToPullRequestSettings)
Expand Down Expand Up @@ -442,7 +442,7 @@ private bool InitializePullRequestSystem(IReportIssuesToPullRequestSettings sett
issueComments.NotNull(nameof(issueComments));
reportIssuesToPullRequestSettings.NotNull(nameof(reportIssuesToPullRequestSettings));

if (!existingThreads.Any())
if (existingThreads.Count == 0)
{
this.log.Verbose("No existing threads to reopen.");
return;
Expand All @@ -462,7 +462,7 @@ private bool InitializePullRequestSystem(IReportIssuesToPullRequestSettings sett
/// <param name="issueComments">Issues and their related existing comments on the pull request.</param>
/// <param name="reportIssuesToPullRequestSettings">Settings for posting the issues.</param>
/// <returns>List of threads which should be reopened.</returns>
private IEnumerable<IPullRequestDiscussionThread> GetThreadsToReopen(
private List<IPullRequestDiscussionThread> GetThreadsToReopen(
IReadOnlyCollection<IPullRequestDiscussionThread> existingThreads,
IDictionary<IIssue, IssueCommentInfo> issueComments,
IReportIssuesToPullRequestSettings reportIssuesToPullRequestSettings)
Expand Down
22 changes: 7 additions & 15 deletions src/Cake.Issues.PullRequests/ProviderIssueLimits.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
namespace Cake.Issues.PullRequests
{
/// <inheritdoc />
public class ProviderIssueLimits : IProviderIssueLimits
/// <param name="maxIssuesToPost">Maximum amount of issues to be posted in a single run.</param>
/// <param name="maxIssuesToPostAcrossRuns">Maximum amount of issues to be posted across all runs.</param>
public class ProviderIssueLimits(
int? maxIssuesToPost = null,
int? maxIssuesToPostAcrossRuns = null) : IProviderIssueLimits
{
/// <summary>
/// Initializes a new instance of the <see cref="ProviderIssueLimits"/> class.
/// </summary>
/// <param name="maxIssuesToPost">Maximum amount of issues to be posted in a single run.</param>
/// <param name="maxIssuesToPostAcrossRuns">Maximum amount of issues to be posted across all runs.</param>
public ProviderIssueLimits(
int? maxIssuesToPost = null,
int? maxIssuesToPostAcrossRuns = null)
{
this.MaxIssuesToPost = maxIssuesToPost;
this.MaxIssuesToPostAcrossRuns = maxIssuesToPostAcrossRuns;
}

/// <inheritdoc />
public int? MaxIssuesToPost { get; set; }
public int? MaxIssuesToPost { get; set; } = maxIssuesToPost;

/// <inheritdoc />
public int? MaxIssuesToPostAcrossRuns { get; set; }
public int? MaxIssuesToPostAcrossRuns { get; set; } = maxIssuesToPostAcrossRuns;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/// </summary>
public class PullRequestDiscussionThread : IPullRequestDiscussionThread
{
private readonly List<IPullRequestDiscussionComment> comments = new ();
private readonly List<IPullRequestDiscussionComment> comments = [];

/// <summary>
/// Initializes a new instance of the <see cref="PullRequestDiscussionThread"/> class.
Expand Down
4 changes: 2 additions & 2 deletions src/Cake.Issues.PullRequests/PullRequestIssueResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
/// </summary>
public class PullRequestIssueResult
{
private readonly List<IIssue> reportedIssues = new ();
private readonly List<IIssue> postedIssues = new ();
private readonly List<IIssue> reportedIssues = [];
private readonly List<IIssue> postedIssues = [];

/// <summary>
/// Initializes a new instance of the <see cref="PullRequestIssueResult"/> class.
Expand Down
12 changes: 0 additions & 12 deletions src/Cake.Issues.PullRequests/PullRequestIssuesException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,5 @@ public PullRequestIssuesException(string message, Exception innerException)
: base(message, innerException)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="PullRequestIssuesException"/> class with serialized data.
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about
/// the exception being thrown.</param>
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about
/// the source or destination. </param>
protected PullRequestIssuesException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
}

0 comments on commit 8720609

Please sign in to comment.