Skip to content

Commit

Permalink
Upgrade to .NET 8.0 (#102)
Browse files Browse the repository at this point in the history
* Checkpoint

* Skip impossible test for now...

* Dockerfile too

* Fix rebase issues.

* A bit of clean up

* Not sure

* Apply suggestions from code review
  • Loading branch information
IEvangelist committed Nov 30, 2023
1 parent fd9dd57 commit cef2113
Show file tree
Hide file tree
Showing 44 changed files with 176 additions and 191 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- '**.sln'

env:
DOTNET_VERSION: '7.0.x' # SDK version
DOTNET_VERSION: '8.0.x' # SDK version

jobs:
build:
Expand All @@ -20,7 +20,7 @@ jobs:

steps:
- uses: actions/checkout@main
- name: Setup .NET Core
- name: Setup .NET
uses: actions/setup-dotnet@main
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@main

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand All @@ -51,10 +51,10 @@ jobs:
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

- name: Setup .NET 7.0
- name: Setup .NET
uses: actions/setup-dotnet@main
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- name: Install dependencies
run: dotnet restore
Expand Down
23 changes: 23 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Bogus" Version="34.0.2" />
<PackageVersion Include="CommandLineParser" Version="2.9.1" />
<PackageVersion Include="GitHub.Actions.Core" Version="8.0.3" />
<PackageVersion Include="MarkdownBuilder" Version="0.2.0" />
<PackageVersion Include="Microsoft.Deployment.DotNet.Releases" Version="1.0.0" />
<PackageVersion Include="Microsoft.Extensions.Caching.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageVersion Include="Octokit" Version="9.0.0" />
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env

# Copy everything and restore
WORKDIR /app
Expand All @@ -16,6 +16,6 @@ LABEL com.github.actions.icon="alert-circle"
LABEL com.github.actions.color="yellow"

# Build the runtime image
FROM mcr.microsoft.com/dotnet/runtime:7.0
FROM mcr.microsoft.com/dotnet/runtime:8.0
COPY --from=build-env /app/out .
ENTRYPOINT [ "dotnet", "/DotNet.VersionSweeper.dll" ]
1 change: 1 addition & 0 deletions dotnet-versionsweeper.sln
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.github\workflows\build-and-test.yml = .github\workflows\build-and-test.yml
CODE-OF-CONDUCT.md = CODE-OF-CONDUCT.md
.github\workflows\codeql-analysis.yml = .github\workflows\codeql-analysis.yml
Directory.Packages.props = Directory.Packages.props
Dockerfile = Dockerfile
.github\workflows\dog-food.yml = .github\workflows\dog-food.yml
dotnet-versionsweeper.json = dotnet-versionsweeper.json
Expand Down
2 changes: 1 addition & 1 deletion src/DotNet.Extensions/DotNet.Extensions.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
2 changes: 0 additions & 2 deletions src/DotNet.Extensions/EnumerableExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.Concurrent;

namespace DotNet.Extensions;

// https://blogs.msdn.microsoft.com/pfxteam/2012/03/05/implementing-a-simple-foreachasync-part-2/
Expand Down
1 change: 1 addition & 0 deletions src/DotNet.Extensions/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

global using System;
global using System.Collections.Concurrent;
global using System.Collections.Generic;
global using System.Linq;
global using System.Text;
Expand Down
14 changes: 7 additions & 7 deletions src/DotNet.GitHub/DotNet.GitHub.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MarkdownBuilder" Version="0.2.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
<PackageReference Include="Octokit" Version="7.0.1" />
<PackageReference Include="MarkdownBuilder" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Http" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
<PackageReference Include="Octokit" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/DotNet.GitHub/GraphQLRequest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace DotNet.GitHub;
Expand Down
16 changes: 6 additions & 10 deletions src/DotNet.GitHub/RateLimitAwareQueue.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace DotNet.GitHub;

public sealed class RateLimitAwareQueue
public sealed class RateLimitAwareQueue(IGitHubIssueService gitHubIssueService)
{
const int DelayBetweenPostCalls = 1_000;

readonly HashSet<string> _uniqueTitles = new(StringComparer.OrdinalIgnoreCase);
readonly ConcurrentQueue<(GitHubApiArgs, NewIssue)> _newIssuesQueue = new();
readonly ConcurrentQueue<(GitHubApiArgs, IssueUpdate)> _updateIssuesQueue = new();
readonly IGitHubIssueService _gitHubIssueService;

public RateLimitAwareQueue(IGitHubIssueService gitHubIssueService) =>
_gitHubIssueService = gitHubIssueService;

public void Enqueue(GitHubApiArgs args, NewIssue issue)
{
Expand All @@ -31,8 +27,8 @@ public void Enqueue(GitHubApiArgs args, IssueUpdate issue) =>
while (_newIssuesQueue is { IsEmpty: false }
&& _newIssuesQueue.TryDequeue(out (GitHubApiArgs, NewIssue) newItem))
{
(GitHubApiArgs args, NewIssue newIssue) = newItem;
Issue issue = await _gitHubIssueService.PostIssueAsync(
var (args, newIssue) = newItem;
var issue = await gitHubIssueService.PostIssueAsync(
args.Owner, args.RepoName, args.Token, newIssue);

yield return ("Created issue", issue.HtmlUrl);
Expand All @@ -43,8 +39,8 @@ public void Enqueue(GitHubApiArgs args, IssueUpdate issue) =>
while (_updateIssuesQueue is { IsEmpty: false }
&& _updateIssuesQueue.TryDequeue(out (GitHubApiArgs, IssueUpdate) updatedItem))
{
(GitHubApiArgs args, IssueUpdate newIssue) = updatedItem;
Issue issue = await _gitHubIssueService.UpdateIssueAsync(
var (args, newIssue) = updatedItem;
var issue = await gitHubIssueService.UpdateIssueAsync(
args.Owner, args.RepoName, args.Token, args.IssueNumber, newIssue);

yield return ("Updated issue", issue.HtmlUrl);
Expand Down
4 changes: 2 additions & 2 deletions src/DotNet.GitHubActions/DotNet.GitHubActions.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/DotNet.IO/DotNet.IO.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/DotNet.IO/Project/ProjectJson.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace DotNet.IO;
Expand Down
12 changes: 4 additions & 8 deletions src/DotNet.IO/Solution/SolutionFileReader.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace DotNet.IO;

public sealed partial class SolutionFileReader : ISolutionFileReader
public sealed partial class SolutionFileReader(IProjectFileReader projectFileReader)
: ISolutionFileReader
{
readonly IProjectFileReader _projectFileReader;

public SolutionFileReader(IProjectFileReader projectFileReader) =>
_projectFileReader = projectFileReader;

public async ValueTask<Solution> ReadSolutionAsync(string solutionPath)
{
Solution solution = new();
Expand All @@ -32,7 +28,7 @@ public async ValueTask<Solution> ReadSolutionAsync(string solutionPath)
continue;
}

Project project = await _projectFileReader.ReadProjectAsync(fullPath);
var project = await projectFileReader.ReadProjectAsync(fullPath);
solution.Projects.Add(project);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/DotNet.Models/DotNet.Models.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand All @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Deployment.DotNet.Releases" Version="1.0.0" />
<PackageReference Include="Microsoft.Deployment.DotNet.Releases" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/DotNet.Models/FrameworkRelease.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace DotNet.Models;
Expand Down Expand Up @@ -29,7 +29,7 @@ var version when version.StartsWith("net", StringComparison.OrdinalIgnoreCase) =
public SupportPhase SupportPhase => EndOfLifeDate switch
{
var date when date is null && Version is "4.8" => SupportPhase.Active,
var date when date > DateTimeOffset.UtcNow => SupportPhase.GoLive,
var date when date > DateTimeOffset.UtcNow => SupportPhase.Active,

_ => SupportPhase.EOL
};
Expand Down
4 changes: 2 additions & 2 deletions src/DotNet.Models/Solution.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace DotNet.Models;
Expand All @@ -7,5 +7,5 @@ public sealed class Solution
{
public string FullPath { get; set; } = null!;

public HashSet<Project> Projects { get; } = new();
public HashSet<Project> Projects { get; } = [];
}
4 changes: 2 additions & 2 deletions src/DotNet.Models/SolutionSupportReport.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace DotNet.Models;

public record SolutionSupportReport(Solution Solution)
{
public HashSet<ProjectSupportReport> ProjectSupportReports { get; } = new();
public HashSet<ProjectSupportReport> ProjectSupportReports { get; } = [];
}
18 changes: 6 additions & 12 deletions src/DotNet.Releases/Core/CoreReleaseIndexService.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.ObjectModel;

namespace DotNet.Releases;

internal sealed class CoreReleaseIndexService : ICoreReleaseIndexService
public sealed class CoreReleaseIndexService(IMemoryCache cache) : ICoreReleaseIndexService
{
const string NetCoreKey = nameof(NetCoreKey);

readonly IMemoryCache _cache;

public CoreReleaseIndexService(IMemoryCache cache) => _cache = cache;

Task<ReadOnlyDictionary<Product, IReadOnlyCollection<ProductRelease>>?>
Task<ReadOnlyDictionary<Product, ReadOnlyCollection<ProductRelease>>?>
ICoreReleaseIndexService.GetReleasesAsync() =>
_cache.GetOrCreateAsync(
cache.GetOrCreateAsync(
NetCoreKey,
async entry =>
static async entry =>
{
ProductCollection products = await ProductCollection.GetAsync();
var map = new ConcurrentDictionary<Product, IReadOnlyCollection<ProductRelease>>();
var map = new ConcurrentDictionary<Product, ReadOnlyCollection<ProductRelease>>();
await Parallel.ForEachAsync(products, async (product, token) =>
{
map[product] = await product.GetReleasesAsync();
Expand Down
8 changes: 3 additions & 5 deletions src/DotNet.Releases/Core/ICoreReleaseIndexService.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.ObjectModel;

namespace DotNet.Releases;

public interface ICoreReleaseIndexService
{
Task<ReadOnlyDictionary<Product, IReadOnlyCollection<ProductRelease>>?> GetReleasesAsync();
Task<ReadOnlyDictionary<Product, ReadOnlyCollection<ProductRelease>>?> GetReleasesAsync();

async ValueTask<Product?> GetNextLtsVersionAsync(string releaseVersion)
{
var version = new ReleaseVersion(releaseVersion);
ReadOnlyDictionary<Product, IReadOnlyCollection<ProductRelease>>? products = await GetReleasesAsync();
ReadOnlyDictionary<Product, ReadOnlyCollection<ProductRelease>>? products = await GetReleasesAsync();

return products?.SelectMany(kvp => kvp.Value)
.Where(release => release.Version > version && !release.Product.IsOutOfSupport())
Expand Down
12 changes: 6 additions & 6 deletions src/DotNet.Releases/DotNet.Releases.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down Expand Up @@ -41,11 +41,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Deployment.DotNet.Releases" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
<PackageReference Include="Microsoft.Deployment.DotNet.Releases" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
<PackageReference Include="System.Linq.Async" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit cef2113

Please sign in to comment.