Skip to content

Clean up obsolete net7 test conditionals while preserving Classic compatibility#1720

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/clean-up-dead-code
Draft

Clean up obsolete net7 test conditionals while preserving Classic compatibility#1720
Copilot wants to merge 3 commits intomasterfrom
copilot/clean-up-dead-code

Conversation

Copy link
Contributor

Copilot AI commented Feb 16, 2026

The codebase contained framework-conditional branches that no longer affect currently targeted test frameworks, but some shared runtime files are also compiled by KubernetesClient.Classic (netstandard2.0;net48) and must keep their guards.

This PR now focuses on safe dead-code cleanup without breaking Classic.

  • Framework-conditional cleanup in tests

    • Removed obsolete #if NET7_0_OR_GREATER wrappers in:
      • tests/KubernetesClient.Tests/KubernetesJsonTests.cs
      • tests/KubernetesClient.Tests/KubernetesYamlTests.cs
    • Assertions now reflect current test target frameworks without unnecessary preprocessor branching.
  • Classic compatibility correction (follow-up feedback)

    • Restored required framework guards in shared runtime files:
      • src/KubernetesClient/KubernetesJson.cs
      • src/KubernetesClient/Models/V1Status.ObjectView.cs
      • src/KubernetesClient/Watcher.cs
    • This keeps KubernetesClient.Classic buildable while retaining the test-side cleanup.
  • Validation

    • Built KubernetesClient.Classic successfully.
    • Ran targeted Classic tests (SimpleTests) successfully.
    • Re-ran focused KubernetesClient.Tests JSON/YAML datetime tests successfully.

> [!WARNING]
>
>

Original prompt

Could you please help to clean up dead code that no longer target in build?
e.g. net6 specific code


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 16, 2026
Co-authored-by: tg123 <170430+tg123@users.noreply.github.com>
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Copilot
Once this PR has been reviewed and has the lgtm label, please ask for approval from tg123. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Feb 16, 2026
Copilot AI changed the title [WIP] Remove dead code for net6 compatibility Remove obsolete net6/net7 conditional branches from active net8+ build targets Feb 16, 2026
Copilot AI requested a review from tg123 February 16, 2026 23:21
@tg123
Copy link
Member

tg123 commented Feb 17, 2026

@copilot will Classic work?

Co-authored-by: tg123 <170430+tg123@users.noreply.github.com>
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 17, 2026
Copy link
Contributor Author

Copilot AI commented Feb 17, 2026

@copilot will Classic work?

Yes — Classic still works after the latest fix. I restored the required framework guards in the shared files compiled by KubernetesClient.Classic and validated with dotnet build src/KubernetesClient.Classic/KubernetesClient.Classic.csproj plus dotnet test tests/KubernetesClient.Classic.Tests/KubernetesClient.Classic.Tests.csproj --framework net8.0 --filter "FullyQualifiedName~SimpleTests" (pass). Commit: 9e6b357.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • crl.comodoca.com
    • Triggering command: /home/REDACTED/work/csharp/.codeql-scratch/dbs/csharp/working/.dotnet/dotnet /home/REDACTED/work/csharp/.codeql-scratch/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /home/REDACTED/work/csharp/csharp/src/KubernetesClient.Classic/KubernetesClient.Classic.csproj --packages /home/REDACTED/work/csharp/.codeql-scratch/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/home/REDACTED/work/csharp/.codeql-scratch/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/home/REDACTED/work/csharp/.codeql-scratch/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
  • ocsp.comodoca.com
    • Triggering command: /home/REDACTED/work/csharp/.codeql-scratch/dbs/csharp/working/.dotnet/dotnet /home/REDACTED/work/csharp/.codeql-scratch/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /home/REDACTED/work/csharp/csharp/src/KubernetesClient.Classic/KubernetesClient.Classic.csproj --packages /home/REDACTED/work/csharp/.codeql-scratch/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/home/REDACTED/work/csharp/.codeql-scratch/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/home/REDACTED/work/csharp/.codeql-scratch/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Remove obsolete net6/net7 conditional branches from active net8+ build targets Clean up obsolete net7 test conditionals while preserving Classic compatibility Feb 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants