Skip to content

CngProperty constructor with ReadOnlySpan<byte> overload#125956

Open
krwq wants to merge 3 commits intodotnet:mainfrom
krwq:cngprop-span-ctor-overload
Open

CngProperty constructor with ReadOnlySpan<byte> overload#125956
krwq wants to merge 3 commits intodotnet:mainfrom
krwq:cngprop-span-ctor-overload

Conversation

@krwq
Copy link
Member

@krwq krwq commented Mar 23, 2026

Fixes: #69061

This is written by copilot based on #93805 + review and feedback to agent

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

Adds a public CngProperty constructor overload that accepts ReadOnlySpan<byte> to avoid forcing callers to materialize a byte[] before constructing the property, aligning with the API proposal in #69061.

Changes:

  • Exposed a new public CngProperty(string, ReadOnlySpan<byte>, CngPropertyOptions) constructor and documented it.
  • Updated the reference assembly to include the new constructor signature.
  • Added tests validating behavioral equivalence between the byte[] and ReadOnlySpan<byte> constructor paths (including empty/default span cases and CNG roundtrips).

Reviewed changes

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

File Description
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/CngProperty.cs Makes the span-based constructor public, adds XML docs, and defensively copies the span via ToArray().
src/libraries/System.Security.Cryptography/ref/System.Security.Cryptography.cs Adds the new constructor to the ref surface area.
src/libraries/System.Security.Cryptography.Cng/tests/PropertyTests.cs Adds coverage ensuring span ctor matches array ctor semantics for equality, GetValue(), and key property set/get behavior.

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.

[API Proposal]: CngProperty constructor with ReadOnlySpan<byte> overload

4 participants