From c4bac67464cfb52f998a2f942a85adedfad04895 Mon Sep 17 00:00:00 2001 From: Allen Date: Wed, 25 Jan 2023 08:55:05 -0800 Subject: [PATCH] Make the MergeFrom method of type ReadOnlySequence public (#11124) (Edited by jskeet) For public release notes: Add a public `IMessage.MergeFrom(ReadOnlySequence)` extension method, exposing existing internal functionality. (Parsing a completely new message from `ReadOnlySequence` was already publicly available, just not merging.) ---- Public the `MergeFrom` method of type `ReadOnlySequence`. We found that the `MergeFrom` method of type `ReadOnlySequence` is internal. **We need it !!!** Closes #11124 COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/11124 from VAllens:patch-1 0ddea03042823bf8ce6834f1498f6a70e319e98c PiperOrigin-RevId: 504575534 --- csharp/src/Google.Protobuf/MessageExtensions.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/csharp/src/Google.Protobuf/MessageExtensions.cs b/csharp/src/Google.Protobuf/MessageExtensions.cs index 22d3a2fb80dd..714505a2c1c0 100644 --- a/csharp/src/Google.Protobuf/MessageExtensions.cs +++ b/csharp/src/Google.Protobuf/MessageExtensions.cs @@ -88,6 +88,15 @@ public static void MergeFrom(this IMessage message, Stream input) => public static void MergeFrom(this IMessage message, ReadOnlySpan span) => MergeFrom(message, span, false, null); + /// + /// Merges data from the given sequence into an existing message. + /// + /// The message to merge the data into. + /// Sequence from the specified data to merge, which must be protobuf-encoded binary data. + [SecuritySafeCritical] + public static void MergeFrom(this IMessage message, ReadOnlySequence sequence) => + MergeFrom(message, sequence, false, null); + /// /// Merges length-delimited data from the given stream into an existing message. ///