From 818f6bcfd81c8c2b81eb352ab6b01e9b09ee84f1 Mon Sep 17 00:00:00 2001
From: Patrick Evers
Date: Mon, 12 Jan 2026 10:38:23 +0100
Subject: [PATCH 1/8] Updates target framework to .NET 10
Upgrades the project to target .NET 10.
This change includes updating the target framework in the project files, global.json, Dockerfile, and project templates. It also updates package versions to be compatible with .NET 10 and uses central package management. The update ensures the project uses the latest .NET runtime and features.
---
Directory.Packages.props | 29 +++++++
K8sOperator.sln | 6 +-
examples/SimpleOperator/SimpleOperator.csproj | 2 +-
global.json | 2 +-
src/Directory.Build.props | 2 +-
src/Directory.Packages.props | 17 -----
.../ClusterRoleBindingBuilderExtensions.cs | 4 +-
.../Builders/DeploymentBuilderExtensions.cs | 7 +-
src/K8sOperator.NET/EventWatcher.cs | 44 +++++------
src/K8sOperator.NET/K8sOperator.NET.csproj | 1 -
src/K8sOperator.NET/KubernetesClient.cs | 15 ++--
test/Directory.Build.props | 4 +-
test/Directory.Packages.props | 19 -----
.../ControllerDatasourceTests.cs | 25 +++---
.../K8sOperator.NET.Tests.csproj | 8 +-
.../Mocks/MockKubeApiServer.cs | 76 ++++++++-----------
16 files changed, 112 insertions(+), 149 deletions(-)
create mode 100644 Directory.Packages.props
delete mode 100644 src/Directory.Packages.props
delete mode 100644 test/Directory.Packages.props
diff --git a/Directory.Packages.props b/Directory.Packages.props
new file mode 100644
index 0000000..ba05eef
--- /dev/null
+++ b/Directory.Packages.props
@@ -0,0 +1,29 @@
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/K8sOperator.sln b/K8sOperator.sln
index f8c1709..4b8b1fc 100644
--- a/K8sOperator.sln
+++ b/K8sOperator.sln
@@ -1,14 +1,13 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 17
-VisualStudioVersion = 17.0.31903.59
+# Visual Studio Version 18
+VisualStudioVersion = 18.1.11312.151 d18.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{898CC489-C84A-49BD-9D77-3CEA1F6A7180}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "props", "props", "{029923F0-FD53-4B75-BA07-F102BBE9C429}"
ProjectSection(SolutionItems) = preProject
src\Directory.Build.props = src\Directory.Build.props
- src\Directory.Packages.props = src\Directory.Packages.props
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{9320CC2F-6BB6-4B29-B625-EB427EE87891}"
@@ -16,7 +15,6 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "props", "props", "{0CCCC7F3-A522-4535-8D5A-1E53815936D3}"
ProjectSection(SolutionItems) = preProject
test\Directory.Build.props = test\Directory.Build.props
- test\Directory.Packages.props = test\Directory.Packages.props
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "assets", "assets", "{4D1F501E-294C-4B22-9792-1BBB2B553C69}"
diff --git a/examples/SimpleOperator/SimpleOperator.csproj b/examples/SimpleOperator/SimpleOperator.csproj
index 294659d..df57e67 100644
--- a/examples/SimpleOperator/SimpleOperator.csproj
+++ b/examples/SimpleOperator/SimpleOperator.csproj
@@ -1,7 +1,7 @@
- net8.0
+ net10.0
enable
enable
pmdevers
diff --git a/global.json b/global.json
index 90996b8..588227b 100644
--- a/global.json
+++ b/global.json
@@ -1,6 +1,6 @@
{
"sdk": {
- "version": "8.0.100",
+ "version": "10.0.100",
"rollForward": "latestFeature"
}
}
\ No newline at end of file
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 9f9f584..fb860a7 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -1,7 +1,7 @@
- net8.0
+ net10.0
true
enable
enable
diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props
deleted file mode 100644
index d3d0c2d..0000000
--- a/src/Directory.Packages.props
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/K8sOperator.NET.Generators/Builders/ClusterRoleBindingBuilderExtensions.cs b/src/K8sOperator.NET.Generators/Builders/ClusterRoleBindingBuilderExtensions.cs
index 3d34998..aecd608 100644
--- a/src/K8sOperator.NET.Generators/Builders/ClusterRoleBindingBuilderExtensions.cs
+++ b/src/K8sOperator.NET.Generators/Builders/ClusterRoleBindingBuilderExtensions.cs
@@ -22,7 +22,7 @@ public static TBuilder WithRoleRef(this TBuilder builder, string apiGr
{
builder.Add(x =>
{
- x.RoleRef = new V1RoleRef(apiGroup, kind, name);
+ x.RoleRef = new V1RoleRef() { ApiGroup = apiGroup, Kind = kind, Name = name };
});
return builder;
@@ -44,7 +44,7 @@ public static TBuilder WithSubject(this TBuilder builder, string kind,
builder.Add(x =>
{
x.Subjects ??= [];
- x.Subjects.Add(new Rbacv1Subject(kind, name, apiGroup, ns));
+ x.Subjects.Add(new Rbacv1Subject() { Kind = kind, Name = name, ApiGroup = apiGroup, NamespaceProperty = ns });
});
return builder;
diff --git a/src/K8sOperator.NET.Generators/Builders/DeploymentBuilderExtensions.cs b/src/K8sOperator.NET.Generators/Builders/DeploymentBuilderExtensions.cs
index b6ac9b6..f29de55 100644
--- a/src/K8sOperator.NET.Generators/Builders/DeploymentBuilderExtensions.cs
+++ b/src/K8sOperator.NET.Generators/Builders/DeploymentBuilderExtensions.cs
@@ -1,5 +1,4 @@
-using k8s.Authentication;
-using k8s.Models;
+using k8s.Models;
namespace K8sOperator.NET.Generators.Builders;
@@ -164,13 +163,13 @@ public static TBuilder WithImage(this TBuilder builder, string image)
/// An action to configure resource requests.
/// The configured builder.
public static TBuilder WithResources(this TBuilder builder,
- Action>? claims = null,
+ Action>? claims = null,
Action>? limits = null,
Action>? requests = null
)
where TBuilder : IKubernetesObjectBuilder
{
- var c = new List();
+ var c = new List();
claims?.Invoke(c);
var l = new Dictionary();
limits?.Invoke(l);
diff --git a/src/K8sOperator.NET/EventWatcher.cs b/src/K8sOperator.NET/EventWatcher.cs
index 409f39b..d8a8fc0 100644
--- a/src/K8sOperator.NET/EventWatcher.cs
+++ b/src/K8sOperator.NET/EventWatcher.cs
@@ -1,4 +1,4 @@
-using k8s;
+using k8s;
using k8s.Autorest;
using k8s.Models;
using K8sOperator.NET.Extensions;
@@ -32,12 +32,12 @@ public interface IEventWatcher
}
internal class EventWatcher(IKubernetesClient client, Controller controller, List