Skip to content

Conversation

PranavSenthilnathan
Copy link
Member

Fixes #118103

@PranavSenthilnathan PranavSenthilnathan added this to the Future milestone Jul 27, 2025
@PranavSenthilnathan PranavSenthilnathan self-assigned this Jul 27, 2025
@Copilot Copilot AI review requested due to automatic review settings July 27, 2025 21:59
Copy link
Contributor

@Copilot 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

This PR introduces target framework-aware helpers for System.Security.Cryptography.Pkcs tests to replace runtime platform detection with compile-time target framework checks. The change addresses issue #118103 by ensuring tests behave correctly based on the target framework rather than the runtime platform.

Key Changes:

  • Introduces TargetFrameworkHelpers class with platform-specific implementations
  • Replaces PlatformDetection.IsWindows calls with TargetFrameworkHelpers.TargetsWindows in test files
  • Configures conditional compilation based on target framework and platform identifiers

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
TargetFrameworkHelpers.Windows.cs Windows-specific implementation returning true for TargetsWindows
TargetFrameworkHelpers.AnyOS.cs Non-Windows implementation returning false for TargetsWindows
System.Security.Cryptography.Pkcs.Tests.csproj Conditional compilation configuration for helper classes
KeyTransRecipientInfoRsaPaddingModeTests.cs Updates platform check for RSA OAEP certificate support
KeyTransRecipientInfoRsaOaepCertTests.cs Updates platform check for RSA OAEP certificate support
KeyAgreeRecipientInfoTests.cs Updates platform check for Diffie-Hellman support
GeneralTests.cs Updates platform check for RSA OAEP certificate support
ContentEncryptionAlgorithmTests.cs Updates platform check for RC4 support

<Compile Include="Pkcs8PrivateKeyInfoTests.cs" />
<Compile Include="PrivateKeyHelpers.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' or '$(TargetPlatformIdentifier)' == 'windows'">
Copy link
Preview

Copilot AI Jul 27, 2025

Choose a reason for hiding this comment

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

The condition should use lowercase 'windows' for consistency with MSBuild conventions. Consider using '$(TargetPlatformIdentifier)' == 'Windows' with proper casing, or verify that the lowercase 'windows' is intentional and documented.

Suggested change
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' or '$(TargetPlatformIdentifier)' == 'windows'">
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' or '$(TargetPlatformIdentifier)' == 'Windows'">

Copilot uses AI. Check for mistakes.

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' or '$(TargetPlatformIdentifier)' == 'windows'">
<Compile Include="TargetFrameworkHelpers.Windows.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETFramework' and '$(TargetPlatformIdentifier)' != 'windows'">
Copy link
Preview

Copilot AI Jul 27, 2025

Choose a reason for hiding this comment

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

Same casing issue as above - the condition should use consistent casing for 'windows'. This condition is the logical inverse of line 79, so both should use the same casing convention.

Copilot uses AI. Check for mistakes.

Copy link
Contributor

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

{
public static bool SupportsRc2 => PlatformSupport.IsRC2Supported;
public static bool SupportsRc4 => PlatformDetection.IsWindows;
public static bool SupportsRc4 => TargetFrameworkHelpers.TargetsWindows;
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should take this change, at all.

A change which makes the VS runner see the same assets as the CLI runner, sure. But random extra hacking on the side, no. It will just leave behind a continual specter of "should this use TargetsWindows, or IsWindows?".

@PranavSenthilnathan
Copy link
Member Author

Any change should only be in the project file or config for test discoverer/runner instead of in our test code.

@github-actions github-actions bot locked and limited conversation to collaborators Aug 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EnvelopedCms test failures on net10.0 for unsupported algorithms
2 participants