v0.2.0
[0.2.0] - 2026-06-12: response and trailer metadata on the builder, trailer assertions
Minor release. Lets a faked call carry response headers and trailers, and adds trailer assertions (text and binary) to the RpcException chain. Purely additive.
Added
GrpcCallBuilder.Success<T>(T response, Metadata? responseHeaders, Metadata? trailers)andGrpcCallBuilder.Faulted<T>(StatusCode statusCode, string? detail, Metadata trailers)build calls that carry response metadata, so a wrapper that reads response headers or trailers can be tested against a fake. A null headers or trailers argument is treated as empty metadata.WithTrailer(string key, string value)andWithTrailer(string key, ReadOnlySpan<byte> value)on theThrowsGrpcException()chain assert the exception'sTrailerscontain a text or binary (-bin) entry. Keys are matched case-insensitively (gRPC lowercases metadata keys). The text overload readsMetadata.Entry.Valueand the binary overload readsMetadata.Entry.ValueBytes, each guarded byEntry.IsBinary, so the value of a binary entry is never read as a string. On failure the message renders the trailers, with binary entries shown as(binary, N bytes).
Fixed
GrpcCallBuilder.Success<T>now returns the same trailersMetadatainstance on every call to the trailers accessor, matching a real client; it previously returned a fresh emptyMetadataeach time, so an identity check or mutation did not behave as it would against a real call.
Changed
- README adds an "Await the call against a generated client" note: a generated client's
XAsyncreturnsAsyncUnaryCall<T>whose fault lives inResponseAsync, so a delegate that returns the call without awaiting it never surfaces the fault and the assertion reports no exception. Assert viaasync () => await client.XAsync(...)orclient.XAsync(...).ResponseAsyncwhen testing a raw generated client; wrapper tests, which returnTask, are unaffected. - Bumped
PackageValidationBaselineVersionfrom0.1.1to0.1.2on both packages so ApiCompat strict-mode validates0.2.0against the most recently published baseline. The new overloads are recorded as additive differences inCompatibilitySuppressions.xml.