Skip to content

SignedXml: document that instances are single-use - #13042

Merged
gewarren merged 4 commits into
dotnet:mainfrom
krwq:signedxml-instance-reuse-safety
Sep 1, 2026
Merged

SignedXml: document that instances are single-use#13042
gewarren merged 4 commits into
dotnet:mainfrom
krwq:signedxml-instance-reuse-safety

Conversation

@krwq

@krwq krwq commented Aug 28, 2026

Copy link
Copy Markdown
Member

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

File Preview link
xml/System.Security.Cryptography.Xml/SignedXml.xml Learn preview

Build report

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.
Copilot AI lite review requested due to automatic review settings August 28, 2026 11:49
@krwq
krwq requested a review from a team as a code owner August 28, 2026 11:49
@krwq
krwq removed the request for review from a team August 28, 2026 11:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 SignedXml as single-use and advising creating a new instance per operation.
  • Documented InvalidOperationException behavior related to instance reuse across relevant SignedXml methods by adding <exception> entries.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread xml/System.Security.Cryptography.Xml/SignedXml.xml Outdated
Comment thread xml/System.Security.Cryptography.Xml/SignedXml.xml Outdated
krwq and others added 2 commits August 28, 2026 14:08
… 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
Comment thread xml/System.Security.Cryptography.Xml/SignedXml.xml Outdated
Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
@gewarren
gewarren merged commit d3123dc into dotnet:main Sep 1, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants