SignedXml: document that instances are single-use - #13042
Merged
Conversation
Add remarks noting that a SignedXml instance is intended for one signing or verification operation. Reusing an instance is not supported because some methods (CheckSignature, GetPublicKey) advance internal state as they run, and a future version of .NET may throw an exception on reuse. Remarks added at the class level and on ComputeSignature, ComputeSignature(KeyedHashAlgorithm), CheckSignature (parameterless), and CheckSignatureReturningKey.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the API reference documentation for System.Security.Cryptography.Xml.SignedXml to clarify that SignedXml instances are intended for a single signing or verification operation, and that reuse is unsupported.
Changes:
- Added a new class-level remarks section describing
SignedXmlas single-use and advising creating a new instance per operation. - Documented
InvalidOperationExceptionbehavior related to instance reuse across relevantSignedXmlmethods by adding<exception>entries.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
… first call threw The class-level remark said the single-use guard was triggered `after either of those methods completes`. The runtime implementation actually arms the guard right after argument preflight but before the operation runs, so a ComputeSignature or CheckSignature call that throws mid-flight (for example, a CryptographicException from signature description creation) still marks the instance as used. Rewording to make that clear. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4d035a6b-7d13-4df1-88db-d89f9ed7aaf5
…xception entries Sibling <exception> elements in this file describe the throw condition only (for example `The SigningKey property is null`); they do not embed a .NET version. Match that convention by trimming `Starting in .NET 12` from the 10 InvalidOperationException entries added for the single-use guard, and leave the version marker in the one class-level <remarks> section that explains the single-use model. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4d035a6b-7d13-4df1-88db-d89f9ed7aaf5
gewarren
approved these changes
Aug 28, 2026
Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
gewarren
approved these changes
Aug 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add remarks noting that a SignedXml instance is intended for one signing or verification operation. Reusing an instance is not supported because some methods (CheckSignature, GetPublicKey) advance internal state as they run, and a future version of .NET may throw an exception on reuse.
Remarks added at the class level and on ComputeSignature, ComputeSignature(KeyedHashAlgorithm), CheckSignature (parameterless), and CheckSignatureReturningKey.
Summary
Describe your changes here.
Do not merge before dotnet/runtime#132836 gets merged
Internal previews
Build report