From 5da41c4d024c1bbdb6dcce9ca05cb15985abc54a Mon Sep 17 00:00:00 2001 From: Brendan Burns <5751682+brendandburns@users.noreply.github.com> Date: Fri, 16 Oct 2026 23:31:06 +0000 Subject: [PATCH 1/2] Port devcontainer and Scriban compatibility fixes from #1945 Keep the dependency updates from #1963 while adding PolySharp support and disabling Scriban generation limits. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .devcontainer/Dockerfile | 12 ++++++++++++ .devcontainer/devcontainer.json | 6 +++++- Directory.Packages.props | 1 + .../GeneratorExecutionContextExt.cs | 6 +++++- .../LibKubernetesGenerator.target | 2 ++ 5 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 .devcontainer/Dockerfile diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 000000000..44482175e --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,12 @@ +FROM mcr.microsoft.com/dotnet/sdk:10.0 + +# Install .NET 8 and .NET 9 SDKs side-by-side so the container supports net8.0, net9.0 and net10.0 builds. +RUN set -eux; \ + apt-get update; \ + apt-get install -y --no-install-recommends curl ca-certificates; \ + rm -rf /var/lib/apt/lists/*; \ + curl -fsSL https://dot.net/v1/dotnet-install.sh -o /tmp/dotnet-install.sh; \ + chmod +x /tmp/dotnet-install.sh; \ + /tmp/dotnet-install.sh --channel 9.0 --quality ga --install-dir /usr/share/dotnet --skip-non-versioned-files; \ + /tmp/dotnet-install.sh --channel 8.0 --quality ga --install-dir /usr/share/dotnet --skip-non-versioned-files; \ + rm -f /tmp/dotnet-install.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 1326700af..25e13d844 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,3 +1,7 @@ { - "image": "mcr.microsoft.com/dotnet/sdk:8.0" + "name": "csharp", + "build": { + "dockerfile": "Dockerfile", + "context": "." + } } \ No newline at end of file diff --git a/Directory.Packages.props b/Directory.Packages.props index f22453b14..e7383ca3f 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -18,6 +18,7 @@ + diff --git a/src/LibKubernetesGenerator/GeneratorExecutionContextExt.cs b/src/LibKubernetesGenerator/GeneratorExecutionContextExt.cs index 6c3653721..345fbf2cc 100644 --- a/src/LibKubernetesGenerator/GeneratorExecutionContextExt.cs +++ b/src/LibKubernetesGenerator/GeneratorExecutionContextExt.cs @@ -11,7 +11,11 @@ internal static class GeneratorExecutionContextExt { public static void RenderToContext(this IncrementalGeneratorPostInitializationContext context, string templatefile, ScriptObject sc, string generatedfile) { - var tc = new TemplateContext(); + var tc = new TemplateContext + { + LoopLimit = 0, + OutputLimit = 0, + }; tc.PushGlobal(sc); context.RenderToContext(templatefile, tc, generatedfile); } diff --git a/src/LibKubernetesGenerator/LibKubernetesGenerator.target b/src/LibKubernetesGenerator/LibKubernetesGenerator.target index 80a9cd252..0604a7f20 100644 --- a/src/LibKubernetesGenerator/LibKubernetesGenerator.target +++ b/src/LibKubernetesGenerator/LibKubernetesGenerator.target @@ -3,6 +3,7 @@ netstandard2.0 true true + true @@ -20,6 +21,7 @@ + From 610e5fd23da65f282583caef90d7dd51dc09f4a2 Mon Sep 17 00:00:00 2001 From: Brendan Burns <5751682+brendandburns@users.noreply.github.com> Date: Fri, 16 Oct 2026 23:57:39 +0000 Subject: [PATCH 2/2] Port xUnit v3 migration from #1797 Match Xunit.StaFact 4 with xunit.v3 4, retain VSTest and serial execution, and update output helpers and OS-specific facts. Remove the unused StaFact reference from the xUnit v2 Kubectl suite. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- Directory.Packages.props | 1 + README.md | 2 ++ tests/Kubectl.Tests/Kubectl.Tests.csproj | 1 - tests/KubernetesClient.Tests/AssemblyInfo.cs | 5 +++-- tests/KubernetesClient.Tests/AuthTests.cs | 1 - .../KubernetesClient.Tests/KubernetesClient.Tests.csproj | 4 ++-- tests/KubernetesClient.Tests/KubernetesMetricsTests.cs | 1 - .../LeaderElection/LeaderElectionTests.cs | 1 - tests/KubernetesClient.Tests/Logging/TestOutputLogger.cs | 2 +- .../Logging/TestOutputLoggerProvider.cs | 2 +- .../Logging/TestOutputLoggingExtensions.cs | 2 +- tests/KubernetesClient.Tests/Mock/MockKubeApiServer.cs | 2 +- .../OperatingSystemDependentFactAttribute.cs | 9 +++------ tests/KubernetesClient.Tests/PodExecTests.cs | 1 - tests/KubernetesClient.Tests/SerializationTests.cs | 1 - tests/KubernetesClient.Tests/V1StatusObjectViewTests.cs | 1 - tests/KubernetesClient.Tests/WatchTests.cs | 1 - tests/KubernetesClient.Tests/WebSocketTestBase.cs | 1 - 18 files changed, 15 insertions(+), 23 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index e7383ca3f..1958668de 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -29,6 +29,7 @@ + diff --git a/README.md b/README.md index ab022676b..6ef0a29fc 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,8 @@ Notice that this is a workaround and is not recommended for production use. ## Testing The project uses [XUnit](https://github.com/xunit/xunit) as unit testing framework. +The main client test suite uses xUnit v3; the other test projects use xUnit v2. +VSTest integration is retained for the existing `dotnet test` and CI coverage commands. To run the tests: diff --git a/tests/Kubectl.Tests/Kubectl.Tests.csproj b/tests/Kubectl.Tests/Kubectl.Tests.csproj index 16eaa3abb..9641998b9 100644 --- a/tests/Kubectl.Tests/Kubectl.Tests.csproj +++ b/tests/Kubectl.Tests/Kubectl.Tests.csproj @@ -14,7 +14,6 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/tests/KubernetesClient.Tests/AssemblyInfo.cs b/tests/KubernetesClient.Tests/AssemblyInfo.cs index 217120083..61e212bf4 100644 --- a/tests/KubernetesClient.Tests/AssemblyInfo.cs +++ b/tests/KubernetesClient.Tests/AssemblyInfo.cs @@ -1,3 +1,4 @@ -using Xunit; +using Xunit.Sdk; +using Xunit.v3; -[assembly: CollectionBehavior(DisableTestParallelization = true)] +[assembly: Parallelization(Mode = ParallelMode.None)] diff --git a/tests/KubernetesClient.Tests/AuthTests.cs b/tests/KubernetesClient.Tests/AuthTests.cs index 23abf6208..79c90e9ff 100644 --- a/tests/KubernetesClient.Tests/AuthTests.cs +++ b/tests/KubernetesClient.Tests/AuthTests.cs @@ -21,7 +21,6 @@ using System.Text; using System.Threading.Tasks; using Xunit; -using Xunit.Abstractions; namespace k8s.Tests { diff --git a/tests/KubernetesClient.Tests/KubernetesClient.Tests.csproj b/tests/KubernetesClient.Tests/KubernetesClient.Tests.csproj index aea509038..48bc1c094 100644 --- a/tests/KubernetesClient.Tests/KubernetesClient.Tests.csproj +++ b/tests/KubernetesClient.Tests/KubernetesClient.Tests.csproj @@ -1,12 +1,12 @@ false + false k8s.Tests net8.0;net9.0;net10.0 - @@ -23,7 +23,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/tests/KubernetesClient.Tests/KubernetesMetricsTests.cs b/tests/KubernetesClient.Tests/KubernetesMetricsTests.cs index 96561a509..927474c8a 100644 --- a/tests/KubernetesClient.Tests/KubernetesMetricsTests.cs +++ b/tests/KubernetesClient.Tests/KubernetesMetricsTests.cs @@ -2,7 +2,6 @@ using System.Linq; using System.Threading.Tasks; using Xunit; -using Xunit.Abstractions; namespace k8s.Tests { diff --git a/tests/KubernetesClient.Tests/LeaderElection/LeaderElectionTests.cs b/tests/KubernetesClient.Tests/LeaderElection/LeaderElectionTests.cs index a8b159a48..cde2692c0 100644 --- a/tests/KubernetesClient.Tests/LeaderElection/LeaderElectionTests.cs +++ b/tests/KubernetesClient.Tests/LeaderElection/LeaderElectionTests.cs @@ -7,7 +7,6 @@ using System.Threading; using System.Threading.Tasks; using Xunit; -using Xunit.Abstractions; namespace k8s.Tests.LeaderElection { diff --git a/tests/KubernetesClient.Tests/Logging/TestOutputLogger.cs b/tests/KubernetesClient.Tests/Logging/TestOutputLogger.cs index 39e0bb94a..53d6ed449 100644 --- a/tests/KubernetesClient.Tests/Logging/TestOutputLogger.cs +++ b/tests/KubernetesClient.Tests/Logging/TestOutputLogger.cs @@ -1,7 +1,7 @@ using Microsoft.Extensions.Logging; using System; using System.Reactive.Disposables; -using Xunit.Abstractions; +using Xunit; namespace k8s.Tests.Logging { diff --git a/tests/KubernetesClient.Tests/Logging/TestOutputLoggerProvider.cs b/tests/KubernetesClient.Tests/Logging/TestOutputLoggerProvider.cs index 48f0b83f8..fc6eb5f88 100644 --- a/tests/KubernetesClient.Tests/Logging/TestOutputLoggerProvider.cs +++ b/tests/KubernetesClient.Tests/Logging/TestOutputLoggerProvider.cs @@ -1,6 +1,6 @@ using Microsoft.Extensions.Logging; using System; -using Xunit.Abstractions; +using Xunit; namespace k8s.Tests.Logging { diff --git a/tests/KubernetesClient.Tests/Logging/TestOutputLoggingExtensions.cs b/tests/KubernetesClient.Tests/Logging/TestOutputLoggingExtensions.cs index 4f94343c9..78a8d8681 100644 --- a/tests/KubernetesClient.Tests/Logging/TestOutputLoggingExtensions.cs +++ b/tests/KubernetesClient.Tests/Logging/TestOutputLoggingExtensions.cs @@ -1,6 +1,6 @@ using Microsoft.Extensions.Logging; using System; -using Xunit.Abstractions; +using Xunit; namespace k8s.Tests.Logging { diff --git a/tests/KubernetesClient.Tests/Mock/MockKubeApiServer.cs b/tests/KubernetesClient.Tests/Mock/MockKubeApiServer.cs index 67a1bd72c..6a8dded98 100644 --- a/tests/KubernetesClient.Tests/Mock/MockKubeApiServer.cs +++ b/tests/KubernetesClient.Tests/Mock/MockKubeApiServer.cs @@ -10,7 +10,7 @@ using System.Linq; using System.Net; using System.Threading.Tasks; -using Xunit.Abstractions; +using Xunit; namespace k8s.Tests.Mock { diff --git a/tests/KubernetesClient.Tests/OperatingSystemDependentFactAttribute.cs b/tests/KubernetesClient.Tests/OperatingSystemDependentFactAttribute.cs index 983c37e9b..6e9034a8e 100644 --- a/tests/KubernetesClient.Tests/OperatingSystemDependentFactAttribute.cs +++ b/tests/KubernetesClient.Tests/OperatingSystemDependentFactAttribute.cs @@ -1,18 +1,15 @@ using System.Runtime.InteropServices; using Xunit; +using Xunit.v3; namespace k8s.Tests { - public class OperatingSystemDependentFactAttribute : FactAttribute + public class OperatingSystemDependentFactAttribute : FactAttribute, IFactAttribute { public OperatingSystems Include { get; set; } = OperatingSystems.Linux | OperatingSystems.Windows | OperatingSystems.OSX; public OperatingSystems Exclude { get; set; } - public override string Skip - { - get => IsOS(Include) && !IsOS(Exclude) ? null : "Not compatible with current OS"; - set { } - } + string IFactAttribute.Skip => IsOS(Include) && !IsOS(Exclude) ? null : "Not compatible with current OS"; private bool IsOS(OperatingSystems operatingSystems) { diff --git a/tests/KubernetesClient.Tests/PodExecTests.cs b/tests/KubernetesClient.Tests/PodExecTests.cs index d37e098e8..e6305c4df 100644 --- a/tests/KubernetesClient.Tests/PodExecTests.cs +++ b/tests/KubernetesClient.Tests/PodExecTests.cs @@ -14,7 +14,6 @@ using System.Threading; using System.Threading.Tasks; using Xunit; -using Xunit.Abstractions; namespace k8s.Tests { diff --git a/tests/KubernetesClient.Tests/SerializationTests.cs b/tests/KubernetesClient.Tests/SerializationTests.cs index b11cba313..4427f69d5 100644 --- a/tests/KubernetesClient.Tests/SerializationTests.cs +++ b/tests/KubernetesClient.Tests/SerializationTests.cs @@ -3,7 +3,6 @@ using System.Text.Json.Serialization; using System.Threading.Tasks; using Xunit; -using Xunit.Abstractions; namespace k8s.Tests { diff --git a/tests/KubernetesClient.Tests/V1StatusObjectViewTests.cs b/tests/KubernetesClient.Tests/V1StatusObjectViewTests.cs index bdd315ed2..375ea96f8 100644 --- a/tests/KubernetesClient.Tests/V1StatusObjectViewTests.cs +++ b/tests/KubernetesClient.Tests/V1StatusObjectViewTests.cs @@ -2,7 +2,6 @@ using k8s.Tests.Mock; using System.Text.Json; using Xunit; -using Xunit.Abstractions; namespace k8s.Tests { diff --git a/tests/KubernetesClient.Tests/WatchTests.cs b/tests/KubernetesClient.Tests/WatchTests.cs index b7bd62fe1..d193c5f7e 100644 --- a/tests/KubernetesClient.Tests/WatchTests.cs +++ b/tests/KubernetesClient.Tests/WatchTests.cs @@ -12,7 +12,6 @@ using System.Threading; using System.Threading.Tasks; using Xunit; -using Xunit.Abstractions; namespace k8s.Tests { diff --git a/tests/KubernetesClient.Tests/WebSocketTestBase.cs b/tests/KubernetesClient.Tests/WebSocketTestBase.cs index 6766cc585..b0d2ba7de 100644 --- a/tests/KubernetesClient.Tests/WebSocketTestBase.cs +++ b/tests/KubernetesClient.Tests/WebSocketTestBase.cs @@ -14,7 +14,6 @@ using System.Threading; using System.Threading.Tasks; using Xunit; -using Xunit.Abstractions; namespace k8s.Tests {