add net7 remove net5 (#1085)

* add net7

* remove net5

* fix build

* fix versions

* revert to 10.0 due to ci

* fix automapper

* update ver matrix

* fix warning

* fix net7 test err

* more target to basic and model pkg
This commit is contained in:
Boshi Lian
2022-12-05 08:59:04 -08:00
committed by GitHub
parent a435aa44f4
commit 763f1f0778
19 changed files with 56 additions and 29 deletions

View File

@@ -16,8 +16,8 @@ jobs:
with: with:
dotnet-version: | dotnet-version: |
3.1.x 3.1.x
5.0.x
6.0.x 6.0.x
7.0.x
# - name: Check Format # - name: Check Format
# # don't check formatting on Windows b/c of CRLF issues. # # don't check formatting on Windows b/c of CRLF issues.
# if: matrix.os == 'ubuntu-latest' # if: matrix.os == 'ubuntu-latest'
@@ -37,10 +37,10 @@ jobs:
fetch-depth: 0 fetch-depth: 0
- name: Add msbuild to PATH - name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1 uses: microsoft/setup-msbuild@v1.1
- name: Setup dotnet SDK 6 - name: Setup dotnet SDK 7
uses: actions/setup-dotnet@v3 uses: actions/setup-dotnet@v3
with: with:
dotnet-version: '6.0.x' dotnet-version: '7.0.x'
- name: Restore nugets (msbuild) - name: Restore nugets (msbuild)
run: msbuild .\src\KubernetesClient.Models\ -t:restore -p:RestorePackagesConfig=true run: msbuild .\src\KubernetesClient.Models\ -t:restore -p:RestorePackagesConfig=true
- name: Build (msbuild) - name: Build (msbuild)
@@ -57,8 +57,8 @@ jobs:
with: with:
dotnet-version: | dotnet-version: |
3.1.x 3.1.x
5.0.x
6.0.x 6.0.x
7.0.x
- name: Minikube - name: Minikube
run: minikube start run: minikube start
- name: Test - name: Test

View File

@@ -30,8 +30,8 @@ jobs:
with: with:
dotnet-version: | dotnet-version: |
3.1.x 3.1.x
5.0.x
6.0.x 6.0.x
7.0.x
# Initializes the CodeQL tools for scanning. # Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL - name: Initialize CodeQL

View File

@@ -19,8 +19,8 @@ jobs:
with: with:
dotnet-version: | dotnet-version: |
3.1.x 3.1.x
5.0.x
6.0.x 6.0.x
7.0.x
- name: dotnet restore - name: dotnet restore
run: dotnet restore --verbosity minimal --configfile nuget.config run: dotnet restore --verbosity minimal --configfile nuget.config

View File

@@ -19,8 +19,8 @@ jobs:
with: with:
dotnet-version: | dotnet-version: |
3.1.x 3.1.x
5.0.x
6.0.x 6.0.x
7.0.x
- name: dotnet restore - name: dotnet restore
run: dotnet restore --verbosity minimal --configfile nuget.config run: dotnet restore --verbosity minimal --configfile nuget.config

View File

@@ -1,7 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup> <ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" /> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0" PrivateAssets="all" /> <PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.0-preview1.22518.1" PrivateAssets="all" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.5.119" PrivateAssets="all" /> <PackageReference Include="Nerdbank.GitVersioning" Version="3.5.119" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" /> <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup> </ItemGroup>

View File

@@ -149,6 +149,7 @@ ${GEN_DIR}/openapi/csharp.sh ${REPO_DIR}/src/KubernetesClient ${REPO_DIR}/csharp
| SDK Version | Kubernetes Version | .NET Targeting | | SDK Version | Kubernetes Version | .NET Targeting |
|-------------|--------------------|------------------------------------------------------| |-------------|--------------------|------------------------------------------------------|
| 9.1 | 1.25 | netstandard2.1;net6.0;net7.0;net48*;netstandard2.0* |
| 9.0 | 1.25 | netstandard2.1;net5.0;net6.0;net48*;netstandard2.0* | | 9.0 | 1.25 | netstandard2.1;net5.0;net6.0;net48*;netstandard2.0* |
| 8.0 | 1.24 | netstandard2.1;net5.0;net6.0;net48*;netstandard2.0* | | 8.0 | 1.24 | netstandard2.1;net5.0;net6.0;net48*;netstandard2.0* |
| 7.2 | 1.23 | netstandard2.1;net5.0;net6.0;net48*;netstandard2.0* | | 7.2 | 1.23 | netstandard2.1;net5.0;net6.0;net48*;netstandard2.0* |

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@@ -1,7 +1,7 @@
{ {
"sdk": { "sdk": {
"version": "6.0.400", "version": "7.0.100",
"rollForward": "latestMajor" "rollForward": "latestMajor"
}, },
"msbuild-sdks": { "msbuild-sdks": {

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFrameworks>netstandard2.0;net6.0;net7.0</TargetFrameworks>
<RootNamespace>k8s</RootNamespace> <RootNamespace>k8s</RootNamespace>
</PropertyGroup> </PropertyGroup>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<RootNamespace>k8s.kubectl</RootNamespace> <RootNamespace>k8s.kubectl</RootNamespace>

View File

@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFrameworks>netstandard2.0;net6.0;net7.0</TargetFrameworks>
<RootNamespace>k8s.Models</RootNamespace> <RootNamespace>k8s.Models</RootNamespace>
</PropertyGroup> </PropertyGroup>
@@ -12,7 +12,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="System.Text.Json" Version="6.0.6" /> <PackageReference Include="System.Text.Json" Version="6.0.6" />
<PackageReference Include="AutoMapper" Version="10.1.1" /> <PackageReference Include="AutoMapper" Version="12.0.0" Condition="'$(TargetFramework)' != 'netstandard2.0'" />
<PackageReference Include="AutoMapper" Version="10.1.1" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
<PackageReference Include="Fractions" Version="7.2.0" /> <PackageReference Include="Fractions" Version="7.2.0" />
<PackageReference Include="YamlDotNet" Version="12.1.0" /> <PackageReference Include="YamlDotNet" Version="12.1.0" />
</ItemGroup> </ItemGroup>

View File

@@ -1,6 +1,9 @@
// WARNING: DO NOT LEAVE COMMENTED CODE IN THIS FILE. IT GETS SCANNED BY GEN PROJECT SO IT CAN EXCLUDE ANY MANUALLY DEFINED MAPS // WARNING: DO NOT LEAVE COMMENTED CODE IN THIS FILE. IT GETS SCANNED BY GEN PROJECT SO IT CAN EXCLUDE ANY MANUALLY DEFINED MAPS
using AutoMapper; using AutoMapper;
#if NET6_0_OR_GREATER
using AutoMapper.Internal;
#endif
using k8s.Models; using k8s.Models;
using System.Reflection; using System.Reflection;
@@ -41,8 +44,15 @@ namespace k8s.Versioning
GetConfigurations(cfg); GetConfigurations(cfg);
configuration(cfg); configuration(cfg);
}); });
Mapper = MapperConfiguration.CreateMapper(); Mapper = MapperConfiguration
#if NET6_0_OR_GREATER
.Internal()
#endif
.CreateMapper();
KindVersionsMap = MapperConfiguration KindVersionsMap = MapperConfiguration
#if NET6_0_OR_GREATER
.Internal()
#endif
.GetAllTypeMaps() .GetAllTypeMaps()
.SelectMany(x => new[] { x.Types.SourceType, x.Types.DestinationType }) .SelectMany(x => new[] { x.Types.SourceType, x.Types.DestinationType })
.Where(x => x.GetCustomAttribute<KubernetesEntityAttribute>() != null) .Where(x => x.GetCustomAttribute<KubernetesEntityAttribute>() != null)
@@ -78,7 +88,12 @@ namespace k8s.Versioning
throw new InvalidOperationException($"Version converter does not have any registered types for Kind `{attr.Kind}`"); throw new InvalidOperationException($"Version converter does not have any registered types for Kind `{attr.Kind}`");
} }
if (!kindVersions.TryGetValue(apiVersion, out var targetType) || !kindVersions.TryGetValue(attr.ApiVersion, out var sourceType) || MapperConfiguration.FindTypeMapFor(sourceType, targetType) == null) if (!kindVersions.TryGetValue(apiVersion, out var targetType) || !kindVersions.TryGetValue(attr.ApiVersion, out var sourceType) ||
MapperConfiguration
#if NET6_0_OR_GREATER
.Internal()
#endif
.FindTypeMapFor(sourceType, targetType) == null)
{ {
throw new InvalidOperationException($"There is no conversion mapping registered for Kind `{attr.Kind}` from ApiVersion {attr.ApiVersion} to {apiVersion}"); throw new InvalidOperationException($"There is no conversion mapping registered for Kind `{attr.Kind}` from ApiVersion {attr.ApiVersion} to {apiVersion}");
} }
@@ -112,7 +127,11 @@ namespace k8s.Versioning
{ {
cfg.AllowNullCollections = true; cfg.AllowNullCollections = true;
cfg.DisableConstructorMapping(); cfg.DisableConstructorMapping();
cfg.ForAllMaps((typeMap, opt) => cfg
#if NET6_0_OR_GREATER
.Internal()
#endif
.ForAllMaps((typeMap, opt) =>
{ {
if (!typeof(IKubernetesObject).IsAssignableFrom(typeMap.Types.DestinationType)) if (!typeof(IKubernetesObject).IsAssignableFrom(typeMap.Types.DestinationType))
{ {

View File

@@ -92,6 +92,13 @@ namespace k8s
{ {
#if NET5_0_OR_GREATER #if NET5_0_OR_GREATER
HttpClientHandler.SslOptions.ClientCertificates.Add(clientCert); HttpClientHandler.SslOptions.ClientCertificates.Add(clientCert);
// TODO this is workaround for net7.0, remove it when the issue is fixed
// seems the client certificate is cached and cannot be updated
HttpClientHandler.SslOptions.LocalCertificateSelectionCallback = (sender, targetHost, localCertificates, remoteCertificate, acceptableIssuers) =>
{
return clientCert;
};
#else #else
HttpClientHandler.ClientCertificates.Add(clientCert); HttpClientHandler.ClientCertificates.Add(clientCert);
#endif #endif

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netstandard2.1;net5.0;net6.0</TargetFrameworks> <TargetFrameworks>netstandard2.1;net6.0;net7.0</TargetFrameworks>
<RootNamespace>k8s</RootNamespace> <RootNamespace>k8s</RootNamespace>
</PropertyGroup> </PropertyGroup>

View File

@@ -3,7 +3,7 @@
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
<SignAssembly>true</SignAssembly> <SignAssembly>true</SignAssembly>
<RootNamespace>k8s.E2E</RootNamespace> <RootNamespace>k8s.E2E</RootNamespace>
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks> <TargetFrameworks>netcoreapp3.1;net6.0;net7.0</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>

View File

@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
<RootNamespace>k8s.Tests</RootNamespace> <RootNamespace>k8s.Tests</RootNamespace>
@@ -14,7 +14,6 @@
<PackageReference Include="System.Reactive" Version="5.0.0" /> <PackageReference Include="System.Reactive" Version="5.0.0" />
<PackageReference Include="Nito.AsyncEx" Version="5.1.2" /> <PackageReference Include="Nito.AsyncEx" Version="5.1.2" />
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0" /> <PackageReference Include="Portable.BouncyCastle" Version="1.9.0" />
<PackageReference Include="AutoMapper" Version="10.1.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
<RootNamespace>k8s.Tests</RootNamespace> <RootNamespace>k8s.Tests</RootNamespace>
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks> <TargetFrameworks>netcoreapp3.1;net6.0;net7.0</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@@ -1,6 +1,6 @@
{ {
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", "$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "9.0", "version": "9.1",
"publicReleaseRefSpec": [ "publicReleaseRefSpec": [
"^refs/heads/master$", "^refs/heads/master$",
"^refs/tags/v\\d+\\.\\d+\\.\\d+" "^refs/tags/v\\d+\\.\\d+\\.\\d+"