From 1237f5292ae5ace2058a0d9e1c6407780d0c433e Mon Sep 17 00:00:00 2001 From: David Pine Date: Wed, 18 Jan 2023 20:06:03 -0600 Subject: [PATCH] Upgrade to .NET 7. --- .github/workflows/build-validation.yml | 6 +++--- .github/workflows/codeql-analysis.yml | 10 +++++----- .github/workflows/pr-validation.yml | 6 +++--- .github/workflows/publish-nuget.yml | 10 +++++----- LICENSE | 2 +- .../Client/HaveIBeenPwned.BlazorApp.Client.csproj | 8 ++++---- .../Server/HaveIBeenPwned.BlazorApp.Server.csproj | 10 +++++----- .../HaveIBeenPwned.MinimalApi.csproj | 4 ++-- .../HaveIBeenPwned.WebApi.csproj | 4 ++-- .../HaveIBeenPwned.Client.Abstractions.csproj | 4 ++-- .../HaveIBeenPwned.Client.PollyExtensions.csproj | 12 ++++++------ .../DefaultPwnedClient.Breaches.cs | 8 ++++---- .../DefaultPwnedClient.Passwords.cs | 2 +- .../DefaultPwnedClient.Pastes.cs | 2 +- .../Extensions/StringExtensions.cs | 4 +--- .../HaveIBeenPwned.Client.csproj | 10 +++++----- src/HaveIBeenPwned.Client/IPwnedBreachesClient.cs | 4 +++- src/HaveIBeenPwned.Client/IPwnedPasswordsClient.cs | 4 +++- src/HaveIBeenPwned.Client/IPwnedPastesClient.cs | 4 +++- src/HaveIBeenPwned.Client/Options/HibpOptions.cs | 2 +- .../HaveIBeenPwned.Client.AbstractionsTests.csproj | 10 +++++----- ...HaveIBeenPwned.Client.PollyExtensionsTests.csproj | 10 +++++----- .../HaveIBeenPwned.ClientTests.csproj | 10 +++++----- 23 files changed, 75 insertions(+), 71 deletions(-) diff --git a/.github/workflows/build-validation.yml b/.github/workflows/build-validation.yml index 51ce164..072b56d 100644 --- a/.github/workflows/build-validation.yml +++ b/.github/workflows/build-validation.yml @@ -14,7 +14,7 @@ on: default: 'Manual build' env: - DOTNET_VERSION: '6.0.x' # set this to the dot net version to use + DOTNET_VERSION: '7.0.x' # set this to the dot net version to use jobs: build: @@ -25,7 +25,7 @@ jobs: os: [ubuntu-latest, windows-latest, macOS-latest] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@main - name: 'Print manual build reason' if: ${{ github.event_name == 'workflow_dispatch' }} @@ -33,7 +33,7 @@ jobs: echo 'Reason: ${{ github.event.inputs.reason }}' - name: Setup .NET - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@main with: dotnet-version: ${{ env.DOTNET_VERSION }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 2171225..1830ace 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -28,7 +28,7 @@ on: default: 'Manual build' env: - DOTNET_VERSION: '6.0.x' # set this to the dot net version to use + DOTNET_VERSION: '7.0.x' # set this to the dot net version to use jobs: analyze: @@ -49,7 +49,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@main with: # We must fetch at least the immediate parents so that if this is # a pull request then we can checkout the head. @@ -62,7 +62,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v1 + uses: github/codeql-action/init@main with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -78,7 +78,7 @@ jobs: # uses a compiled language - name: Setup .NET - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@main with: dotnet-version: ${{ env.DOTNET_VERSION }} @@ -98,4 +98,4 @@ jobs: # dotnet build ./src/HaveIBeenPwned.Client.PollyExtensions/HaveIBeenPwned.Client.PollyExtensions.csproj --configuration Release --no-restore - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + uses: github/codeql-action/analyze@main diff --git a/.github/workflows/pr-validation.yml b/.github/workflows/pr-validation.yml index 9045124..83b3b47 100644 --- a/.github/workflows/pr-validation.yml +++ b/.github/workflows/pr-validation.yml @@ -8,7 +8,7 @@ on: - '**.csproj' env: - DOTNET_VERSION: '6.0.x' # set this to the dot net version to use + DOTNET_VERSION: '7.0.x' # set this to the dot net version to use jobs: validate: @@ -19,9 +19,9 @@ jobs: os: [ubuntu-latest, windows-latest, macOS-latest] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@main - name: Setup .NET - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@main with: dotnet-version: ${{ env.DOTNET_VERSION }} diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml index 6650f01..8c5d3a2 100644 --- a/.github/workflows/publish-nuget.yml +++ b/.github/workflows/publish-nuget.yml @@ -2,7 +2,7 @@ name: publish nuget on: push: tags: - - 2.* + - '**' jobs: publish: @@ -26,7 +26,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: 6.0.x + dotnet-version: 7.0.x - name: Restore dependencies run: | @@ -54,19 +54,19 @@ jobs: nuget push **\*.nupkg -Source 'https://api.nuget.org/v3/index.json' -NoSymbols -NonInteractive -ApiKey ${{secrets.NUGET_API_KEY}} - name: Upload abstractions package - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@main with: name: HaveIBeenPwned.Client.Abstractions.${{ steps.regex-match.outputs.match }}.nupkg path: packages/ - name: Upload client package - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@main with: name: HaveIBeenPwned.Client.${{ steps.regex-match.outputs.match }}.nupkg path: packages/ - name: Upload polly extensions package - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@main with: name: HaveIBeenPwned.Client.PollyExtensions.${{ steps.regex-match.outputs.match }}.nupkg path: packages/ diff --git a/LICENSE b/LICENSE index 31611c0..1ad371d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021 David Pine +Copyright (c) 2021-2023 David Pine Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/samples/HaveIBeenPwned.BlazorApp/Client/HaveIBeenPwned.BlazorApp.Client.csproj b/samples/HaveIBeenPwned.BlazorApp/Client/HaveIBeenPwned.BlazorApp.Client.csproj index 005f160..ecc4249 100644 --- a/samples/HaveIBeenPwned.BlazorApp/Client/HaveIBeenPwned.BlazorApp.Client.csproj +++ b/samples/HaveIBeenPwned.BlazorApp/Client/HaveIBeenPwned.BlazorApp.Client.csproj @@ -1,15 +1,15 @@  - net6.0 + net7.0 enable enable - - - + + + diff --git a/samples/HaveIBeenPwned.BlazorApp/Server/HaveIBeenPwned.BlazorApp.Server.csproj b/samples/HaveIBeenPwned.BlazorApp/Server/HaveIBeenPwned.BlazorApp.Server.csproj index c8b0902..e6d387d 100644 --- a/samples/HaveIBeenPwned.BlazorApp/Server/HaveIBeenPwned.BlazorApp.Server.csproj +++ b/samples/HaveIBeenPwned.BlazorApp/Server/HaveIBeenPwned.BlazorApp.Server.csproj @@ -1,16 +1,16 @@ - net6.0 + net7.0 enable enable - - - - + + + + diff --git a/samples/HaveIBeenPwned.MinimalApi/HaveIBeenPwned.MinimalApi.csproj b/samples/HaveIBeenPwned.MinimalApi/HaveIBeenPwned.MinimalApi.csproj index 37ae5f2..67c4ef6 100644 --- a/samples/HaveIBeenPwned.MinimalApi/HaveIBeenPwned.MinimalApi.csproj +++ b/samples/HaveIBeenPwned.MinimalApi/HaveIBeenPwned.MinimalApi.csproj @@ -1,13 +1,13 @@  - net6.0 + net7.0 enable enable - + diff --git a/samples/HaveIBeenPwned.WebApi/HaveIBeenPwned.WebApi.csproj b/samples/HaveIBeenPwned.WebApi/HaveIBeenPwned.WebApi.csproj index 37ae5f2..67c4ef6 100644 --- a/samples/HaveIBeenPwned.WebApi/HaveIBeenPwned.WebApi.csproj +++ b/samples/HaveIBeenPwned.WebApi/HaveIBeenPwned.WebApi.csproj @@ -1,13 +1,13 @@  - net6.0 + net7.0 enable enable - + diff --git a/src/HaveIBeenPwned.Client.Abstractions/HaveIBeenPwned.Client.Abstractions.csproj b/src/HaveIBeenPwned.Client.Abstractions/HaveIBeenPwned.Client.Abstractions.csproj index 9c71c50..0afa5ba 100644 --- a/src/HaveIBeenPwned.Client.Abstractions/HaveIBeenPwned.Client.Abstractions.csproj +++ b/src/HaveIBeenPwned.Client.Abstractions/HaveIBeenPwned.Client.Abstractions.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 enable enable Abstractions for HaveIBeenPwned.Client library. @@ -54,7 +54,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/HaveIBeenPwned.Client.PollyExtensions/HaveIBeenPwned.Client.PollyExtensions.csproj b/src/HaveIBeenPwned.Client.PollyExtensions/HaveIBeenPwned.Client.PollyExtensions.csproj index 0ffd519..161b7bb 100644 --- a/src/HaveIBeenPwned.Client.PollyExtensions/HaveIBeenPwned.Client.PollyExtensions.csproj +++ b/src/HaveIBeenPwned.Client.PollyExtensions/HaveIBeenPwned.Client.PollyExtensions.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 enable enable This is an unofficial .NET HTTP client library exposing various "Have I Been Pwned" APIs, including Breaches, Pastes, and of course Pwned Passwords. @@ -50,18 +50,18 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/HaveIBeenPwned.Client/DefaultPwnedClient.Breaches.cs b/src/HaveIBeenPwned.Client/DefaultPwnedClient.Breaches.cs index bbb5198..007c22b 100644 --- a/src/HaveIBeenPwned.Client/DefaultPwnedClient.Breaches.cs +++ b/src/HaveIBeenPwned.Client/DefaultPwnedClient.Breaches.cs @@ -25,7 +25,7 @@ await client.GetFromJsonAsync( } catch (Exception ex) { - _logger.LogError(ex, ex.Message); + _logger.LogError(ex, "{ExceptionMessage}", ex.Message); return null!; } @@ -75,7 +75,7 @@ await client.GetFromJsonAsync( } catch (Exception ex) { - _logger.LogError(ex, ex.Message); + _logger.LogError(ex, "{ExceptionMessage}", ex.Message); return Array.Empty(); } @@ -101,7 +101,7 @@ await client.GetFromJsonAsync( } catch (Exception ex) { - _logger.LogError(ex, ex.Message); + _logger.LogError(ex, "{ExceptionMessage}", ex.Message); return Array.Empty(); } @@ -120,7 +120,7 @@ async Task IPwnedBreachesClient.GetDataClassesAsync() } catch (Exception ex) { - _logger.LogError(ex, ex.Message); + _logger.LogError(ex, "{ExceptionMessage}", ex.Message); return Array.Empty(); } diff --git a/src/HaveIBeenPwned.Client/DefaultPwnedClient.Passwords.cs b/src/HaveIBeenPwned.Client/DefaultPwnedClient.Passwords.cs index 20c6c02..3f626ec 100644 --- a/src/HaveIBeenPwned.Client/DefaultPwnedClient.Passwords.cs +++ b/src/HaveIBeenPwned.Client/DefaultPwnedClient.Passwords.cs @@ -37,7 +37,7 @@ async Task IPwnedPasswordsClient.GetPwnedPasswordAsync(string pla } catch (Exception ex) { - _logger.LogError(ex, ex.Message); + _logger.LogError(ex, "{ExceptionMessage}", ex.Message); } return pwnedPassword; diff --git a/src/HaveIBeenPwned.Client/DefaultPwnedClient.Pastes.cs b/src/HaveIBeenPwned.Client/DefaultPwnedClient.Pastes.cs index 3e14b8a..4d82e5a 100644 --- a/src/HaveIBeenPwned.Client/DefaultPwnedClient.Pastes.cs +++ b/src/HaveIBeenPwned.Client/DefaultPwnedClient.Pastes.cs @@ -25,7 +25,7 @@ await client.GetFromJsonAsync( } catch (Exception ex) { - _logger.LogError(ex, ex.Message); + _logger.LogError(ex, "{ExceptionMessage}", ex.Message); return Array.Empty(); } diff --git a/src/HaveIBeenPwned.Client/Extensions/StringExtensions.cs b/src/HaveIBeenPwned.Client/Extensions/StringExtensions.cs index 9f2aec7..42862c0 100644 --- a/src/HaveIBeenPwned.Client/Extensions/StringExtensions.cs +++ b/src/HaveIBeenPwned.Client/Extensions/StringExtensions.cs @@ -16,9 +16,7 @@ static class StringExtensions return value; } - using var sha1 = SHA1.Create(); - - var hash = sha1.ComputeHash(Encoding.UTF8.GetBytes(value)); + var hash = SHA1.HashData(Encoding.UTF8.GetBytes(value)); StringBuilder stringBuilder = new(hash.Length * 2); foreach (var b in hash) diff --git a/src/HaveIBeenPwned.Client/HaveIBeenPwned.Client.csproj b/src/HaveIBeenPwned.Client/HaveIBeenPwned.Client.csproj index 11ab934..1557cfd 100644 --- a/src/HaveIBeenPwned.Client/HaveIBeenPwned.Client.csproj +++ b/src/HaveIBeenPwned.Client/HaveIBeenPwned.Client.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 enable enable This is an unofficial .NET HTTP client library exposing various "Have I Been Pwned" APIs, including Breaches, Pastes, and of course Pwned Passwords. @@ -50,17 +50,17 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/HaveIBeenPwned.Client/IPwnedBreachesClient.cs b/src/HaveIBeenPwned.Client/IPwnedBreachesClient.cs index a6b722a..2a88c97 100644 --- a/src/HaveIBeenPwned.Client/IPwnedBreachesClient.cs +++ b/src/HaveIBeenPwned.Client/IPwnedBreachesClient.cs @@ -3,7 +3,9 @@ namespace HaveIBeenPwned.Client; -/// +/// +/// The "pwned" breaches client. +/// public interface IPwnedBreachesClient { /// diff --git a/src/HaveIBeenPwned.Client/IPwnedPasswordsClient.cs b/src/HaveIBeenPwned.Client/IPwnedPasswordsClient.cs index b2993e5..c7d3d9e 100644 --- a/src/HaveIBeenPwned.Client/IPwnedPasswordsClient.cs +++ b/src/HaveIBeenPwned.Client/IPwnedPasswordsClient.cs @@ -3,7 +3,9 @@ namespace HaveIBeenPwned.Client; -/// +/// +/// The "pwned" passwords client. +/// public interface IPwnedPasswordsClient { /// diff --git a/src/HaveIBeenPwned.Client/IPwnedPastesClient.cs b/src/HaveIBeenPwned.Client/IPwnedPastesClient.cs index 69c0b13..b329c9d 100644 --- a/src/HaveIBeenPwned.Client/IPwnedPastesClient.cs +++ b/src/HaveIBeenPwned.Client/IPwnedPastesClient.cs @@ -3,7 +3,9 @@ namespace HaveIBeenPwned.Client; -/// +/// +/// The "pwned" pastes client. +/// public interface IPwnedPastesClient { /// diff --git a/src/HaveIBeenPwned.Client/Options/HibpOptions.cs b/src/HaveIBeenPwned.Client/Options/HibpOptions.cs index 97022ae..a573d7e 100644 --- a/src/HaveIBeenPwned.Client/Options/HibpOptions.cs +++ b/src/HaveIBeenPwned.Client/Options/HibpOptions.cs @@ -7,7 +7,7 @@ namespace HaveIBeenPwned.Client.Options; /// The "Have I Been Pwned" API options object. /// See /// -public class HibpOptions : IOptions +public sealed class HibpOptions : IOptions { static readonly string LibraryVersion = typeof(HibpOptions).Assembly diff --git a/tests/HaveIBeenPwned.Client.AbstractionsTests/HaveIBeenPwned.Client.AbstractionsTests.csproj b/tests/HaveIBeenPwned.Client.AbstractionsTests/HaveIBeenPwned.Client.AbstractionsTests.csproj index b20aeb5..e5d73f7 100644 --- a/tests/HaveIBeenPwned.Client.AbstractionsTests/HaveIBeenPwned.Client.AbstractionsTests.csproj +++ b/tests/HaveIBeenPwned.Client.AbstractionsTests/HaveIBeenPwned.Client.AbstractionsTests.csproj @@ -1,20 +1,20 @@ - net6.0 + net7.0 enable enable false - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/HaveIBeenPwned.Client.PollyExtensionsTests/HaveIBeenPwned.Client.PollyExtensionsTests.csproj b/tests/HaveIBeenPwned.Client.PollyExtensionsTests/HaveIBeenPwned.Client.PollyExtensionsTests.csproj index 242db29..d8c1d34 100644 --- a/tests/HaveIBeenPwned.Client.PollyExtensionsTests/HaveIBeenPwned.Client.PollyExtensionsTests.csproj +++ b/tests/HaveIBeenPwned.Client.PollyExtensionsTests/HaveIBeenPwned.Client.PollyExtensionsTests.csproj @@ -1,20 +1,20 @@ - net6.0 + net7.0 enable enable false - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/HaveIBeenPwned.ClientTests/HaveIBeenPwned.ClientTests.csproj b/tests/HaveIBeenPwned.ClientTests/HaveIBeenPwned.ClientTests.csproj index f65eb1a..73d6297 100644 --- a/tests/HaveIBeenPwned.ClientTests/HaveIBeenPwned.ClientTests.csproj +++ b/tests/HaveIBeenPwned.ClientTests/HaveIBeenPwned.ClientTests.csproj @@ -1,20 +1,20 @@ - net6.0 + net7.0 enable enable false - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all