aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/Google.Protobuf/UnknownFieldSet.cs
diff options
context:
space:
mode:
Diffstat (limited to 'csharp/src/Google.Protobuf/UnknownFieldSet.cs')
-rw-r--r--csharp/src/Google.Protobuf/UnknownFieldSet.cs8
1 files changed, 7 insertions, 1 deletions
diff --git a/csharp/src/Google.Protobuf/UnknownFieldSet.cs b/csharp/src/Google.Protobuf/UnknownFieldSet.cs
index b43f4774..6404c3c0 100644
--- a/csharp/src/Google.Protobuf/UnknownFieldSet.cs
+++ b/csharp/src/Google.Protobuf/UnknownFieldSet.cs
@@ -230,7 +230,8 @@ namespace Google.Protobuf
/// <summary>
/// Create a new UnknownFieldSet if unknownFields is null.
/// Parse a single field from <paramref name="input"/> and merge it
- /// into unknownFields.
+ /// into unknownFields. If <paramref name="input"/> is configured to discard unknown fields,
+ /// <paramref name="unknownFields"/> will be returned as-is and the field will be skipped.
/// </summary>
/// <param name="unknownFields">The UnknownFieldSet which need to be merged</param>
/// <param name="input">The coded input stream containing the field</param>
@@ -238,6 +239,11 @@ namespace Google.Protobuf
public static UnknownFieldSet MergeFieldFrom(UnknownFieldSet unknownFields,
CodedInputStream input)
{
+ if (input.DiscardUnknownFields)
+ {
+ input.SkipLastField();
+ return unknownFields;
+ }
if (unknownFields == null)
{
unknownFields = new UnknownFieldSet();