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

Upgrade to .Net 8.0 #1287

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
3 changes: 0 additions & 3 deletions .devcontainer/Dockerfile

This file was deleted.

9 changes: 1 addition & 8 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
{
"name": "C# (.NET)",
"build": {
"dockerfile": "Dockerfile",
"args": {
// Update 'VARIANT' to pick a .NET Core version: 3.1, 6.0
// Append -bullseye or -focal to pin to an OS version.
"VARIANT": "6.0-bullseye"
}
},
"image": "mcr.microsoft.com/devcontainers/dotnet:8.0",

// Configure tool-specific properties.
"customizations": {
Expand Down
7 changes: 6 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# Please see the documentation for more information:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://containers.dev/guide/dependabot

version: 2
updates:
Expand All @@ -13,3 +14,7 @@ updates:
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.413",
"version": "8.0.403",
"rollForward": "minor"
}
}
3 changes: 2 additions & 1 deletion src/Octoshift/Octoshift.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>OctoshiftCLI</RootNamespace>
<LangVersion>12</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Octoshift/Services/CodeScanningAlertService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected internal virtual async Task MigrateAlerts(string sourceOrg, string sou

// no reason to call the target on a dry run - there will be no alerts
var targetAlerts = dryRun ?
new List<CodeScanningAlert>() :
[] :
(await _targetGithubApi.GetCodeScanningAlertsForRepository(targetOrg, targetRepo, branch)).ToList();

var successCount = 0;
Expand Down
8 changes: 4 additions & 4 deletions src/Octoshift/Services/OctoLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal static class LogLevel
public class OctoLogger
{
public virtual bool Verbose { get; set; }
private readonly HashSet<string> _secrets = new();
private readonly HashSet<string> _secrets = [];
private readonly string _logFilePath;
private readonly string _verboseFilePath;
private readonly bool _debugMode;
Expand All @@ -31,11 +31,11 @@ public class OctoLogger

private const string GENERIC_ERROR_MESSAGE = "An unexpected error happened. Please see the logs for details.";

private readonly List<string> _redactionPatterns = new()
{
private readonly List<string> _redactionPatterns =
[
"\\b(?<=token=)(.+?)\\b",
"\\b(?<=X-Amz-Credential=)(.+?)\\b",
};
];

public OctoLogger()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>12</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class AbortMigrationCommandBaseTests
private readonly Mock<ITargetGithubApiFactory> _mockGithubApiFactory = new();
private readonly Mock<OctoLogger> _mockOctoLogger = TestHelpers.CreateMock<OctoLogger>();
private readonly ServiceProvider _serviceProvider;
private readonly AbortMigrationCommandBase _command = new();
private readonly AbortMigrationCommandBase _command = [];

private const string REPO_MIGRATION_ID = "RM_MIGRATION_ID";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class CreateTeamCommandTests
private readonly Mock<OctoLogger> _mockOctoLogger = TestHelpers.CreateMock<OctoLogger>();

private readonly ServiceProvider _serviceProvider;
private readonly CreateTeamCommandBase _command = new();
private readonly CreateTeamCommandBase _command = [];

public CreateTeamCommandTests()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class CreateTeamCommandHandlerTests
private const string GITHUB_ORG = "FooOrg";
private const string TEAM_NAME = "foo-team";
private const string IDP_GROUP = "foo-group";
private readonly List<string> TEAM_MEMBERS = new() { "dylan", "dave" };
private readonly List<string> TEAM_MEMBERS = ["dylan", "dave"];
private const int IDP_GROUP_ID = 42;
private const string TEAM_SLUG = "foo-slug";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class GenerateMannequinCsvCommandBaseTests
private readonly Mock<OctoLogger> _mockOctoLogger = TestHelpers.CreateMock<OctoLogger>();
private readonly Mock<ITargetGithubApiFactory> _mockGithubApiFactory = new();
private readonly ServiceProvider _serviceProvider;
private readonly GenerateMannequinCsvCommandBase _command = new();
private readonly GenerateMannequinCsvCommandBase _command = [];
private const string GITHUB_ORG = "FooOrg";

public GenerateMannequinCsvCommandBaseTests()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class GrantMigratorRoleCommandBaseTests
private readonly Mock<OctoLogger> _mockOctoLogger = TestHelpers.CreateMock<OctoLogger>();

private readonly ServiceProvider _serviceProvider;
private readonly GrantMigratorRoleCommandBase _command = new();
private readonly GrantMigratorRoleCommandBase _command = [];

public GrantMigratorRoleCommandBaseTests()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ReclaimMannequinCommandBaseTests
private readonly Mock<ConfirmationService> _mockConfirmationService = TestHelpers.CreateMock<ConfirmationService>();
private readonly Mock<ITargetGithubApiFactory> _mockGithubApiFactory = new();
private readonly ServiceProvider _serviceProvider;
private readonly ReclaimMannequinCommandBase _command = new();
private readonly ReclaimMannequinCommandBase _command = [];

private const string GITHUB_ORG = "FooOrg";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class RevokeMigratorRoleCommandBaseTests
private readonly Mock<OctoLogger> _mockOctoLogger = TestHelpers.CreateMock<OctoLogger>();

private readonly ServiceProvider _serviceProvider;
private readonly RevokeMigratorRoleCommandBase _command = new();
private readonly RevokeMigratorRoleCommandBase _command = [];

public RevokeMigratorRoleCommandBaseTests()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class WaitForMigrationCommandBaseTests
private readonly Mock<OctoLogger> _mockOctoLogger = TestHelpers.CreateMock<OctoLogger>();
private readonly Mock<WarningsCountLogger> _mockWarningsCountLogger = TestHelpers.CreateMock<WarningsCountLogger>();
private readonly ServiceProvider _serviceProvider;
private readonly WaitForMigrationCommandBase _command = new();
private readonly WaitForMigrationCommandBase _command = [];

private const string REPO_MIGRATION_ID = "RM_MIGRATION_ID";
public WaitForMigrationCommandBaseTests()
Expand Down
11 changes: 5 additions & 6 deletions src/OctoshiftCLI.Tests/Octoshift/Services/GithubApiTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net;
using System.Net.Http;
Expand Down Expand Up @@ -1994,20 +1993,20 @@ ... on User {
{
CreateAttributionInvitation = null
},
Errors = new Collection<ErrorData>{new ErrorData
Errors = [new ErrorData
{
Type = "UNPROCESSABLE",
Message = "Target must be a member of the octocat organization",
Path = new Collection<string> { "createAttributionInvitation" },
Locations = new Collection<Location> {
Path = ["createAttributionInvitation"],
Locations = [
new Location()
{
Line = 2,
Column = 14
}
}
}
]
}
]
};

_githubClientMock
Expand Down
29 changes: 14 additions & 15 deletions src/OctoshiftCLI.Tests/Octoshift/Services/ReclaimServiceTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using FluentAssertions;
using Moq;
Expand Down Expand Up @@ -605,13 +604,13 @@ public async Task ReclaimMannequinsSkipInvitation_No_EMU_Throws_Error_Fails_Fast

var reclaimMannequinResponse = new ReattributeMannequinToUserResult()
{
Errors = new Collection<ErrorData>()
{
Errors =
[
new ErrorData()
{
Message = "is not an Enterprise Managed Users (EMU) organization"
}
}
]
};

_mockGithubApi.Setup(x => x.GetOrganizationId(TARGET_ORG).Result).Returns(ORG_ID);
Expand Down Expand Up @@ -941,14 +940,14 @@ public async Task ReclaimMannequin_FailedToReclaim_LogsError_Throws_OctoshiftCli
{
CreateAttributionInvitation = null
},
Errors = new Collection<ErrorData>{new ErrorData
Errors = [new ErrorData
{
Type = "UNPROCESSABLE",
Message = failureMessage,
Path = new Collection<string> { "createAttributionInvitation" },
Locations = new Collection<Location> { new Location() { Line = 2, Column = 14 } }
}
Path = ["createAttributionInvitation"],
Locations = [new Location() { Line = 2, Column = 14 }]
}
]
};

_mockGithubApi.Setup(x => x.GetOrganizationId(TARGET_ORG).Result).Returns(ORG_ID);
Expand Down Expand Up @@ -982,14 +981,14 @@ public async Task ReclaimMannequin_TwoMannequins_FailedToReclaimOne_LogsError_Th
{
CreateAttributionInvitation = null
},
Errors = new Collection<ErrorData>{new ErrorData
Errors = [new ErrorData
{
Type = "UNPROCESSABLE",
Message = failureMessage,
Path = new Collection<string> { "createAttributionInvitation" },
Locations = new Collection<Location> { new Location() { Line = 2, Column = 14 } }
}
Path = ["createAttributionInvitation"],
Locations = [new Location() { Line = 2, Column = 14 }]
}
]
};

var reclaimMannequinResponse2 = new CreateAttributionInvitationResult()
Expand Down Expand Up @@ -1107,13 +1106,13 @@ public async Task ReclaimMannequinSkipInvitation_No_EMU_Throws_Error_Fails_Fast(

var reclaimMannequinResponse = new ReattributeMannequinToUserResult()
{
Errors = new Collection<ErrorData>()
{
Errors =
[
new ErrorData()
{
Message = "is not an Enterprise Managed Users (EMU) organization"
}
}
]
};

_mockGithubApi.Setup(x => x.GetOrganizationId(TARGET_ORG).Result).Returns(ORG_ID);
Expand Down
6 changes: 2 additions & 4 deletions src/OctoshiftCLI.Tests/OctoshiftCLI.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>

<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>

<LangVersion>10</LangVersion>
<LangVersion>12</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class AddTeamToRepoCommandTests
private readonly Mock<OctoLogger> _mockOctoLogger = TestHelpers.CreateMock<OctoLogger>();

private readonly ServiceProvider _serviceProvider;
private readonly AddTeamToRepoCommand _command = new();
private readonly AddTeamToRepoCommand _command = [];

public AddTeamToRepoCommandTests()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public ConfigureAutoLinkCommandHandlerTests()
public async Task Happy_Path()
{
_mockGithubApi.Setup(x => x.GetAutoLinks(It.IsAny<string>(), It.IsAny<string>()))
.ReturnsAsync(new List<(int Id, string KeyPrefix, string UrlTemplate)>());
.ReturnsAsync([]);

var args = new ConfigureAutoLinkCommandArgs
{
Expand Down Expand Up @@ -77,10 +77,10 @@ public async Task Idempotency_AutoLink_Exists()
public async Task Idempotency_KeyPrefix_Exists()
{
_mockGithubApi.Setup(x => x.GetAutoLinks(It.IsAny<string>(), It.IsAny<string>()))
.ReturnsAsync(new List<(int Id, string KeyPrefix, string UrlTemplate)>
{
.ReturnsAsync(
[
(1, KEY_PREFIX, "SomethingElse"),
});
]);

var actualLogOutput = new List<string>();
_mockOctoLogger.Setup(m => m.LogInformation(It.IsAny<string>())).Callback<string>(s => actualLogOutput.Add(s));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class ConfigureAutoLinkCommandTests
private readonly Mock<OctoLogger> _mockOctoLogger = TestHelpers.CreateMock<OctoLogger>();

private readonly ServiceProvider _serviceProvider;
private readonly ConfigureAutoLinkCommand _command = new();
private readonly ConfigureAutoLinkCommand _command = [];

public ConfigureAutoLinkCommandTests()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class DisableRepoCommandTests
private readonly Mock<OctoLogger> _mockOctoLogger = TestHelpers.CreateMock<OctoLogger>();

private readonly ServiceProvider _serviceProvider;
private readonly DisableRepoCommand _command = new();
private readonly DisableRepoCommand _command = [];

public DisableRepoCommandTests()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class GenerateScriptCommandTests
private readonly Mock<IVersionProvider> _mockVersionProvider = new();

private readonly ServiceProvider _serviceProvider;
private readonly GenerateScriptCommand _command = new();
private readonly GenerateScriptCommand _command = [];

public GenerateScriptCommandTests()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class IntegrateBoardsCommandTests
private readonly Mock<EnvironmentVariableProvider> _mockEnvironmentVariableProvider = TestHelpers.CreateMock<EnvironmentVariableProvider>();

private readonly ServiceProvider _serviceProvider;
private readonly IntegrateBoardsCommand _command = new();
private readonly IntegrateBoardsCommand _command = [];

public IntegrateBoardsCommandTests()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class InventoryReportCommandTests
private readonly Mock<PipelinesCsvGeneratorService> _mockPipelinesCsvGeneratorService = TestHelpers.CreateMock<PipelinesCsvGeneratorService>();

private readonly ServiceProvider _serviceProvider;
private readonly InventoryReportCommand _command = new();
private readonly InventoryReportCommand _command = [];

public InventoryReportCommandTests()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class LockRepoCommandTests
private readonly Mock<OctoLogger> _mockOctoLogger = TestHelpers.CreateMock<OctoLogger>();

private readonly ServiceProvider _serviceProvider;
private readonly LockRepoCommand _command = new();
private readonly LockRepoCommand _command = [];

public LockRepoCommandTests()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class MigrateRepoCommandTests
private readonly Mock<WarningsCountLogger> _warningsCountLogger = TestHelpers.CreateMock<WarningsCountLogger>();

private readonly ServiceProvider _serviceProvider;
private readonly MigrateRepoCommand _command = new();
private readonly MigrateRepoCommand _command = [];

public MigrateRepoCommandTests()
{
Expand Down
Loading
Loading