Skip to content

Fix nullable annotations on MLKemAlgorithm and add ToString #116635

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 16, 2025

Conversation

vcsjones
Copy link
Member

  • MLKemAlgorithm can add some annotations to help the compiler understand nullability. Let's do that.
  • Let's override ToString - this helps with output and clarity in xunit theories and other places where an instance is expected to stringify clearly (Perhaps a console log or assert)

@Copilot Copilot AI review requested due to automatic review settings June 13, 2025 15:28
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 enhances the nullability annotations on MLKemAlgorithm.Equals methods and adds a ToString override for clearer string representations, accompanied by a new corresponding test.

  • Annotate Equals(MLKemAlgorithm?) and Equals(object?) parameters with [NotNullWhen(true)] for better nullability inference.
  • Override ToString() to return the algorithm’s Name.
  • Add Algorithms_ToString xUnit theory to verify ToString() matches Name.

Reviewed Changes

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

File Description
src/libraries/Common/src/System/Security/Cryptography/MLKemAlgorithm.cs Add [NotNullWhen(true)] annotations and ToString override
src/libraries/Common/tests/System/Security/Cryptography/MLKemAlgorithmTests.cs Add test to verify ToString output

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.

@PranavSenthilnathan
Copy link
Member

/ba-g #116647, #116558, and #106319. This PR shouldn't affect ios/tvos/browser.

@vcsjones vcsjones merged commit 68e5dd7 into dotnet:main Jun 16, 2025
82 of 86 checks passed
@vcsjones vcsjones deleted the ml-kem-alg-nullable branch June 16, 2025 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants