[API Proposal]: void-returning Encode callback for AsnWriter #112675
Labels
api-approved
API was approved in API review, it can be implemented
area-System.Formats.Asn1
in-pr
There is an active PR which will close this issue when it is merged
Milestone
Background and motivation
In #75759 we approved two APIs that use a callback mechanism for encoding when using
AsnWriter
. Both of the added methods return aTReturn
.When wiring this in through the Libraries, there are several places that look like this:
runtime/src/libraries/Common/src/System/Security/Cryptography/DSAKeyFormatHelper.cs
Lines 277 to 281 in e75eb9c
They modify some state that gets passed in, but don't need to return anything, which results in a
return (object?)null
.We should overload
Encode
to accept anAction
callback and returnvoid
.API Proposal
API Usage
From the example above, that would become a nicer-looking:
Alternative Designs
There is, yet another, overload we could add - which is one that accepts no state and returns nothing. I don't know how useful that is. That would imply that global state is being modified, or something captured.
That would look like:
But I see little utility in it. It can be added for symmetry if that is important.
Risks
No response
The text was updated successfully, but these errors were encountered: