diff --git a/src/Grpc.Core.Api/Metadata.cs b/src/Grpc.Core.Api/Metadata.cs index 12a1ba1a6..c191ef10d 100644 --- a/src/Grpc.Core.Api/Metadata.cs +++ b/src/Grpc.Core.Api/Metadata.cs @@ -128,16 +128,20 @@ public IEnumerable GetAll(string key) } /// - /// Adds a new ASCII-valued metadata entry. See Metadata.Entry constructor for params. + /// Adds a new ASCII-valued metadata entry. /// + /// Metadata key. Gets converted to lowercase. Must not use -bin suffix indicating a binary-valued metadata entry. Can only contain lowercase alphanumeric characters, underscores, hyphens, and dots. + /// Value string. Only ASCII characters are allowed. public void Add(string key, string value) { Add(new Entry(key, value)); } /// - /// Adds a new binary-valued metadata entry. See Metadata.Entry constructor for params. + /// Adds a new binary-valued metadata entry. /// + /// Metadata key. Gets converted to lowercase. Needs to have -bin suffix indicating a binary-valued metadata entry. The binary header suffix can be added to the key with . Can only contain lowercase alphanumeric characters, underscores, hyphens, and dots. + /// Value bytes. public void Add(string key, byte[] valueBytes) { Add(new Entry(key, valueBytes)); @@ -290,13 +294,13 @@ private Entry(string key, string? value, byte[]? valueBytes) /// /// Initializes a new instance of the struct with a binary value. /// - /// Metadata key. Gets converted to lowercase. Needs to have suffix indicating a binary valued metadata entry. Can only contain lowercase alphanumeric characters, underscores, hyphens and dots. + /// Metadata key. Gets converted to lowercase. Needs to have -bin suffix indicating a binary-valued metadata entry. The binary header suffix can be added to the key with . Can only contain lowercase alphanumeric characters, underscores, hyphens, and dots. /// Value bytes. public Entry(string key, byte[] valueBytes) { this.key = NormalizeKey(key); GrpcPreconditions.CheckArgument(HasBinaryHeaderSuffix(this.key), - "Key for binary valued metadata entry needs to have suffix indicating binary value."); + $"Key for binary valued metadata entry needs to have '{BinaryHeaderSuffix}' suffix indicating binary value."); this.value = null; GrpcPreconditions.CheckNotNull(valueBytes, "valueBytes"); this.valueBytes = new byte[valueBytes.Length]; @@ -306,7 +310,7 @@ public Entry(string key, byte[] valueBytes) /// /// Initializes a new instance of the struct with an ASCII value. /// - /// Metadata key. Gets converted to lowercase. Must not use suffix indicating a binary valued metadata entry. Can only contain lowercase alphanumeric characters, underscores, hyphens and dots. + /// Metadata key. Gets converted to lowercase. Must not use '-bin' suffix indicating a binary-valued metadata entry. Can only contain lowercase alphanumeric characters, underscores, hyphens, and dots. /// Value string. Only ASCII characters are allowed. public Entry(string key, string value) {