Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"image": "mcr.microsoft.com/dotnet/sdk:8.0"
"name": "csharp",
"build": {
"dockerfile": "Dockerfile",
"context": "."
}
}
2 changes: 2 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<PackageVersion Include="Nito.AsyncEx.Coordination" Version="5.1.2" />
<PackageVersion Include="OpenTelemetry.Exporter.Console" Version="1.20.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.20.0" />
<PackageVersion Include="PolySharp" Version="1.15.0" />
<PackageVersion Include="Portable.BouncyCastle" Version="1.9.0" />
<PackageVersion Include="SharpZipLib" Version="1.4.2" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="10.3.0" />
Expand All @@ -28,6 +29,7 @@
<PackageVersion Include="Vecc.YamlDotNet.Analyzers.StaticGenerator" Version="18.1.0" />
<PackageVersion Include="Wiremock.Net" Version="2.19.0" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.v3" Version="4.0.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="4.0.1" />
<PackageVersion Include="Xunit.StaFact" Version="4.0.24" />
<PackageVersion Include="YamlDotNet" Version="18.1.0" />
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
6 changes: 5 additions & 1 deletion src/LibKubernetesGenerator/GeneratorExecutionContextExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions src/LibKubernetesGenerator/LibKubernetesGenerator.target
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<PackageScribanIncludeSource>true</PackageScribanIncludeSource>
<PolySharpIncludeRuntimeSupportedAttributes>true</PolySharpIncludeRuntimeSupportedAttributes>
</PropertyGroup>

<ItemGroup>
Expand All @@ -20,6 +21,7 @@

<!-- Scriban No Dependency -->
<PackageReference Include="Scriban" IncludeAssets="Build" />
<PackageReference Include="PolySharp" PrivateAssets="all" />

<!-- CaseExtensions No Dependency -->
<PackageReference Include="CaseExtensions" GeneratePathProperty="true" PrivateAssets="all" />
Expand Down
1 change: 0 additions & 1 deletion tests/Kubectl.Tests/Kubectl.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<PackageReference Include="xunit.runner.visualstudio">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Xunit.StaFact" />
<PackageReference Include="Moq" />
</ItemGroup>

Expand Down
5 changes: 3 additions & 2 deletions tests/KubernetesClient.Tests/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Xunit;
using Xunit.Sdk;
using Xunit.v3;

[assembly: CollectionBehavior(DisableTestParallelization = true)]
[assembly: Parallelization(Mode = ParallelMode.None)]
1 change: 0 additions & 1 deletion tests/KubernetesClient.Tests/AuthTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
using System.Text;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;

namespace k8s.Tests
{
Expand Down
4 changes: 2 additions & 2 deletions tests/KubernetesClient.Tests/KubernetesClient.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<IsPackable>false</IsPackable>
<IsTestingPlatformApplication>false</IsTestingPlatformApplication>
<RootNamespace>k8s.Tests</RootNamespace>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MartinCostello.Logging.XUnit" />
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Microsoft.Extensions.Logging" />
<PackageReference Include="System.IO.Abstractions.TestingHelpers" />
Expand All @@ -23,7 +23,7 @@
<PackageReference Include="NJsonSchema" />
<PackageReference Include="NSwag.Core" />
<PackageReference Include="System.Text.Json" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
1 change: 0 additions & 1 deletion tests/KubernetesClient.Tests/KubernetesMetricsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Linq;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;

namespace k8s.Tests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Threading;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;

namespace k8s.Tests.LeaderElection
{
Expand Down
2 changes: 1 addition & 1 deletion tests/KubernetesClient.Tests/Logging/TestOutputLogger.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Microsoft.Extensions.Logging;
using System;
using System.Reactive.Disposables;
using Xunit.Abstractions;
using Xunit;

namespace k8s.Tests.Logging
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.Extensions.Logging;
using System;
using Xunit.Abstractions;
using Xunit;

namespace k8s.Tests.Logging
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.Extensions.Logging;
using System;
using Xunit.Abstractions;
using Xunit;

namespace k8s.Tests.Logging
{
Expand Down
2 changes: 1 addition & 1 deletion tests/KubernetesClient.Tests/Mock/MockKubeApiServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using Xunit.Abstractions;
using Xunit;

namespace k8s.Tests.Mock
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
{
Expand Down
1 change: 0 additions & 1 deletion tests/KubernetesClient.Tests/PodExecTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using System.Threading;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;

namespace k8s.Tests
{
Expand Down
1 change: 0 additions & 1 deletion tests/KubernetesClient.Tests/SerializationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;

namespace k8s.Tests
{
Expand Down
1 change: 0 additions & 1 deletion tests/KubernetesClient.Tests/V1StatusObjectViewTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using k8s.Tests.Mock;
using System.Text.Json;
using Xunit;
using Xunit.Abstractions;

namespace k8s.Tests
{
Expand Down
1 change: 0 additions & 1 deletion tests/KubernetesClient.Tests/WatchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using System.Threading;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;

namespace k8s.Tests
{
Expand Down
1 change: 0 additions & 1 deletion tests/KubernetesClient.Tests/WebSocketTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using System.Threading;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;

namespace k8s.Tests
{
Expand Down
Loading