generate base on 1.34 (#1654)

* Implement code changes to enhance functionality and improve performance

* chore: update version to 18.0 in version.json

* fix: correct initialization of opblackList in PluralHelper

* chore: update SDK version to 18.0 in README.md

* Fixdocfx (#82)

* fix: update file references and clean up validation comments in models

* chore: add symlink to CONTRIBUTING.md for easier access

* fix: update documentation to include full type names for WebSocket and Predicate

* fix: include CONTRIBUTING.md in docfx.json build content

* refactor: update IKubernetes interface and template for consistency

* feat: add Microsoft.CodeAnalysis.CSharp package and improve source normalization in generator context

* chore: update package versions in Directory.Packages.props for compatibility and improvements

* chore: update Microsoft.VisualStudio.SlnGen and Nerdbank.GitVersioning package versions for compatibility

* Implement code changes to enhance functionality and improve performance

* chore: update version to 18.0 in version.json

* fix: correct initialization of opblackList in PluralHelper

* chore: update SDK version to 18.0 in README.md

* refactor: update IKubernetes interface and template for consistency

* feat: add Microsoft.CodeAnalysis.CSharp package and improve source normalization in generator context

* chore: update package versions in Directory.Packages.props for compatibility and improvements

* chore: update Microsoft.VisualStudio.SlnGen and Nerdbank.GitVersioning package versions for compatibility

* chore: downgrade xunit.runner.visualstudio and Xunit.StaFact package versions for compatibility

* chore: update package versions in Directory.Packages.props for compatibility and improvements

* style: format code for consistency and readability

* feat: update certificate loading logic for .NET 9 compatibility

* fix: update certificate loading method for .NET 9 compatibility
This commit is contained in:
Boshi Lian
2025-09-22 14:18:16 -07:00
committed by GitHub
parent 11a9641fbe
commit 96955064cb
16 changed files with 7327 additions and 4501 deletions

View File

@@ -3,51 +3,52 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="BouncyCastle.Cryptography" Version="2.5.1" />
<PackageVersion Include="FluentAssertions" Version="8.2.0" />
<PackageVersion Include="BouncyCastle.Cryptography" Version="2.6.2" />
<PackageVersion Include="FluentAssertions" Version="8.6.0" />
<PackageVersion Include="Fractions" Version="7.3.0" />
<PackageVersion Include="JsonPatch.Net" Version="3.3.0" />
<PackageVersion Include="MartinCostello.Logging.XUnit" Version="0.5.1" />
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="9.0.4" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.4" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.4" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageVersion Include="Microsoft.TestPlatform.ObjectModel" Version="17.13.0" />
<PackageVersion Include="MartinCostello.Logging.XUnit" Version="0.6.0" />
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="9.0.8" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.8" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.8" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageVersion Include="Microsoft.TestPlatform.ObjectModel" Version="17.14.1" />
<PackageVersion Include="Moq" Version="4.20.72" />
<PackageVersion Include="Nito.AsyncEx" Version="5.1.2" />
<PackageVersion Include="Nito.AsyncEx.Coordination" Version="5.1.2" />
<PackageVersion Include="OpenTelemetry.Exporter.Console" Version="1.11.2" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.11.1" />
<PackageVersion Include="OpenTelemetry.Exporter.Console" Version="1.12.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.12.0" />
<PackageVersion Include="Portable.BouncyCastle" Version="1.9.0" />
<PackageVersion Include="SharpZipLib" Version="1.4.2" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="8.1.1" />
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="9.0.4" />
<PackageVersion Include="System.IO.Abstractions.TestingHelpers" Version="22.0.14" />
<PackageVersion Include="System.Reactive" Version="6.0.1" />
<PackageVersion Include="System.Text.Json" Version="9.0.4" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="9.0.4" />
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="9.0.8" />
<PackageVersion Include="System.IO.Abstractions.TestingHelpers" Version="22.0.15" />
<PackageVersion Include="System.Reactive" Version="6.0.2" />
<PackageVersion Include="System.Text.Json" Version="9.0.8" />
<PackageVersion Include="Vecc.YamlDotNet.Analyzers.StaticGenerator" Version="16.3.0" />
<PackageVersion Include="Wiremock.Net" Version="1.7.4" />
<PackageVersion Include="Wiremock.Net" Version="1.12.0" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.2" />
<PackageVersion Include="Xunit.StaFact" Version="1.2.69" />
<PackageVersion Include="YamlDotNet" Version="16.3.0" />
</ItemGroup>
<ItemGroup>
<PackageVersion Include="Autofac" Version="8.2.1" />
<PackageVersion Include="Autofac" Version="8.4.0" />
<PackageVersion Include="CaseExtensions" Version="1.1.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.13.0" />
<PackageVersion Include="Namotion.Reflection" Version="3.3.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.14.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
<PackageVersion Include="Namotion.Reflection" Version="3.4.2" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="NJsonSchema" Version="11.2.0" />
<PackageVersion Include="NJsonSchema.Annotations" Version="11.2.0" />
<PackageVersion Include="NSwag.Core" Version="14.3.0" />
<PackageVersion Include="NJsonSchema" Version="11.4.0" />
<PackageVersion Include="NJsonSchema.Annotations" Version="11.4.0" />
<PackageVersion Include="NSwag.Core" Version="14.5.0" />
<PackageVersion Include="Scriban" Version="6.2.1" />
</ItemGroup>
<ItemGroup>
<GlobalPackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.0.0" />
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<GlobalPackageReference Include="Microsoft.VisualStudio.SlnGen" Version="12.0.3" />
<GlobalPackageReference Include="Nerdbank.GitVersioning" Version="3.7.112" />
<GlobalPackageReference Include="Microsoft.VisualStudio.SlnGen" Version="12.0.23" />
<GlobalPackageReference Include="Nerdbank.GitVersioning" Version="3.7.115" />
<GlobalPackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
</ItemGroup>
</Project>

View File

@@ -154,6 +154,7 @@ ${GEN_DIR}/openapi/csharp.sh ${REPO_DIR}/src/KubernetesClient ${REPO_DIR}/csharp
| SDK Version | Kubernetes Version | .NET Targeting |
|-------------|--------------------|-----------------------------------------------------|
| 18.0 | 1.34 | net8.0;net9.0;net48*;netstandard2.0* |
| 17.0 | 1.33 | net8.0;net9.0;net48*;netstandard2.0* |
| 16.0 | 1.32 | net8.0;net9.0;net48*;netstandard2.0* |
| 15.0 | 1.31 | net6.0;net8.0;net48*;netstandard2.0* |

View File

@@ -1,3 +1,3 @@
export KUBERNETES_BRANCH=v1.33.0
export KUBERNETES_BRANCH=v1.34.0
export CLIENT_VERSION=0.0.1
export PACKAGE_NAME=k8s

View File

@@ -1,6 +1,6 @@
namespace k8s;
public partial interface IKubernetes : IBasicKubernetes, IDisposable
public partial interface IKubernetes : IDisposable
{
/// <summary>
/// The base URI of the service.

View File

@@ -71,7 +71,7 @@ namespace LibKubernetesGenerator
sc = scriptObjectFactory.CreateScriptObject();
sc.SetValue("groups", groups, true);
context.RenderToContext($"IBasicKubernetes.cs.template", sc, $"IBasicKubernetes.g.cs");
context.RenderToContext($"IKubernetes.cs.template", sc, $"IKubernetes.g.cs");
context.RenderToContext($"AbstractKubernetes.cs.template", sc, $"AbstractKubernetes.g.cs");
}
}

View File

@@ -1,5 +1,6 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.CSharp;
using Scriban;
using Scriban.Runtime;
using System.Text;
@@ -19,7 +20,10 @@ namespace LibKubernetesGenerator
{
var template = Template.Parse(EmbedResource.GetResource(templatefile));
var generated = template.Render(tc);
context.AddSource(generatedfile, SourceText.From(generated, Encoding.UTF8));
var syntaxTree = CSharpSyntaxTree.ParseText(generated);
var normalized = syntaxTree.GetRoot().NormalizeWhitespace().ToFullString();
context.AddSource(generatedfile, SourceText.From(normalized, Encoding.UTF8));
}
}
}

View File

@@ -13,6 +13,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Common" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>

View File

@@ -11,11 +11,12 @@ namespace LibKubernetesGenerator
{
private readonly Dictionary<string, string> _classNameToPluralMap;
private readonly ClassNameHelper classNameHelper;
private readonly HashSet<string> opblackList = new HashSet<string>()
{
private readonly HashSet<string> opblackList =
[
"listClusterCustomObject",
"listNamespacedCustomObject",
};
"listCustomObjectForAllNamespaces",
];
public PluralHelper(ClassNameHelper classNameHelper, OpenApiDocument swagger)
{

View File

@@ -8,7 +8,7 @@ namespace k8s;
/// <summary>
/// </summary>
public partial interface IBasicKubernetes
public partial interface IKubernetes
{
{{for group in groups}}
I{{group}}Operations {{group}} { get; }

11715
swagger.json

File diff suppressed because it is too large Load Diff

View File

@@ -188,10 +188,18 @@ namespace k8s.Tests
}
else
{
#if NET9_0_OR_GREATER
serverCertificate = X509CertificateLoader.LoadPkcs12(Convert.FromBase64String(serverCertificateData), "");
#else
serverCertificate = new X509Certificate2(Convert.FromBase64String(serverCertificateData), "");
#endif
}
#if NET9_0_OR_GREATER
var clientCertificate = X509CertificateLoader.LoadCertificate(Convert.FromBase64String(clientCertificateData));
#else
var clientCertificate = new X509Certificate2(Convert.FromBase64String(clientCertificateData), "");
#endif
var clientCertificateValidationCalled = false;
@@ -294,10 +302,18 @@ namespace k8s.Tests
}
else
{
#if NET9_0_OR_GREATER
serverCertificate = X509CertificateLoader.LoadPkcs12(serverCertificateData, "");
#else
serverCertificate = new X509Certificate2(serverCertificateData, "");
#endif
}
#if NET9_0_OR_GREATER
var clientCertificate = X509CertificateLoader.LoadCertificate(clientCertificateData);
#else
var clientCertificate = new X509Certificate2(clientCertificateData, "");
#endif
var clientCertificateValidationCalled = false;

View File

@@ -85,8 +85,13 @@ namespace k8s.Tests
{
var certCollection = CertUtils.LoadPemFileCert("assets/ca-bundle.crt");
#if NET9_0_OR_GREATER
using var intermediateCert = X509CertificateLoader.LoadCertificateFromFile("assets/ca-bundle-intermediate.crt");
using var rootCert = X509CertificateLoader.LoadCertificateFromFile("assets/ca-bundle-root.crt");
#else
using var intermediateCert = new X509Certificate2("assets/ca-bundle-intermediate.crt");
using var rootCert = new X509Certificate2("assets/ca-bundle-root.crt");
#endif
Assert.Equal(2, certCollection.Count);

View File

@@ -68,7 +68,11 @@ namespace k8s.Tests
public void ValidCert()
{
var caCert = CertUtils.LoadPemFileCert("assets/ca.crt");
#if NET9_0_OR_GREATER
var testCert = X509CertificateLoader.LoadCertificateFromFile("assets/ca.crt");
#else
var testCert = new X509Certificate2("assets/ca.crt");
#endif
var chain = new X509Chain();
var errors = SslPolicyErrors.RemoteCertificateChainErrors;
@@ -81,7 +85,11 @@ namespace k8s.Tests
public void InvalidCert()
{
var caCert = CertUtils.LoadPemFileCert("assets/ca.crt");
#if NET9_0_OR_GREATER
var testCert = X509CertificateLoader.LoadCertificateFromFile("assets/ca2.crt");
#else
var testCert = new X509Certificate2("assets/ca2.crt");
#endif
var chain = new X509Chain();
var errors = SslPolicyErrors.RemoteCertificateChainErrors;
@@ -110,7 +118,11 @@ namespace k8s.Tests
public void InvalidBundleCert()
{
var caCert = CertUtils.LoadPemFileCert("assets/ca-bundle.crt");
#if NET9_0_OR_GREATER
var testCert = X509CertificateLoader.LoadCertificateFromFile("assets/ca2.crt");
#else
var testCert = new X509Certificate2("assets/ca2.crt");
#endif
var chain = new X509Chain();
var errors = SslPolicyErrors.RemoteCertificateChainErrors;

View File

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