Skip to content
Discussion options

You must be logged in to vote

We decided to do argument validation first for consistency.

public byte[] SignData(byte[] data, byte[] context) wants to defer to SignData(ReadOnlySpan<byte> data, ReadOnlySpan<byte> context), but do null-checks. If Dispose is first, then it looks like

public byte[] SignData(byte[] data, byte[]? context = null)
{
    ThrowIfDisposed();
    ArgumentNullException.ThrowIfNull(data);
    return SignData(new ReadOnlySpan<byte>(data), new ReadOnlySpan<byte>(context));
}

public byte[] SignData(ReadOnlySpan<byte> data, ReadOnlySpan<byte> context)
{
    if (context.Length > 255) throw ...;

    ThrowIfDisposed();
    ...
}

So that path makes the array path go through two ThrowIfDisposed if we str…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@GeeLaw
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@GeeLaw
Comment options

Answer selected by GeeLaw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants