New ReadOnlySpan constructor for SecureString #44873
Labels
api-suggestion
Early API idea and discussion, it is NOT ready for implementation
untriaged
New issue has not been triaged by the area owner
Background and Motivation
In PowerShell project we sometimes create a
SecureString
from a string, e.g. in SecureStringCommands, by using the following pattern:Unfortunately, it appears that every call to
AppendChar
results in an allocation, which I suppose we could avoid with the following unsafe code:However the constructor
SecureString(char* value, int length)
creates aReadOnlySpan
to initialize from, so why not expose a constructor that takes aReadOnlySpan
?Proposed API
Usage Examples
Alternative Designs
Risks
The text was updated successfully, but these errors were encountered: