Skip to content

Remove dead Windows 7 conditions and inline CheckKeyConsistency in PfxFormatTests#125142

Open
Copilot wants to merge 2 commits intomainfrom
copilot/remove-nonsense-conditions
Open

Remove dead Windows 7 conditions and inline CheckKeyConsistency in PfxFormatTests#125142
Copilot wants to merge 2 commits intomainfrom
copilot/remove-nonsense-conditions

Conversation

Copy link
Contributor

Copilot AI commented Mar 3, 2026

Description

Two places in PfxFormatTests.cs had an always-false condition OperatingSystem.IsWindows() && !PlatformDetection.IsWindows guarding followup = null. Since these can never be true, the followup variable was always CheckKeyConsistency and never modified.

  • Removed both dead if blocks and their associated Windows 7 comment blocks
  • Eliminated the intermediate Action<X509Certificate2> followup variable
  • Passed CheckKeyConsistency directly to ReadMultiPfx calls

Before:

Action<X509Certificate2> followup = CheckKeyConsistency;

// For unknown reasons, CheckKeyConsistency on this test fails
// on Windows 7 with an Access Denied in all variations for
// Collections, and in invertCertOrder: true for Single.
//
// Obviously this hit some sort of weird corner case in the Win7
// loader, but it's not important to the test.

if (OperatingSystem.IsWindows() &&
    !PlatformDetection.IsWindows)
{
    followup = null;
}

ReadMultiPfx(pfxBytes, pw, first, expectedOrder, followup);

After:

ReadMultiPfx(pfxBytes, pw, first, expectedOrder, CheckKeyConsistency);

Copilot AI and others added 2 commits March 3, 2026 17:39
…tTests

Co-authored-by: vcsjones <361677+vcsjones@users.noreply.github.com>
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @bartonjs, @vcsjones, @dotnet/area-system-security
See info in area-owners.md if you want to be subscribed.

@vcsjones vcsjones added the test-enhancement Improvements of test source code label Mar 3, 2026
@vcsjones
Copy link
Member

vcsjones commented Mar 3, 2026

This was just incomplete cleanup done in #122907.

@vcsjones vcsjones marked this pull request as ready for review March 3, 2026 18:21
Copilot AI review requested due to automatic review settings March 3, 2026 18:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Cleans up dead/unreachable Windows 7-specific code paths in PfxFormatTests by removing an always-false condition and simplifying the callback wiring used by ReadMultiPfx.

Changes:

  • Removed the dead OperatingSystem.IsWindows() && !PlatformDetection.IsWindows branches (and associated Windows 7 comments).
  • Eliminated the intermediate followup delegate variable.
  • Passed CheckKeyConsistency directly into ReadMultiPfx calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.Security test-enhancement Improvements of test source code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants