aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/Google.Protobuf/Reflection/PartialClasses.cs
diff options
context:
space:
mode:
authorJon Skeet <jonskeet@google.com>2015-08-07 13:37:21 +0100
committerJon Skeet <jonskeet@google.com>2015-08-08 07:27:58 +0100
commit547d8e8221b8ea7ff7010cbc601f4e5742ff1e51 (patch)
treee0daca67c1ac8c80bd92253f29a6031d7f246a37 /csharp/src/Google.Protobuf/Reflection/PartialClasses.cs
parente58cdbd2146bc8e2e2f5bf4bc8a7576f82535ae6 (diff)
downloadprotobuf-547d8e8221b8ea7ff7010cbc601f4e5742ff1e51.tar.gz
protobuf-547d8e8221b8ea7ff7010cbc601f4e5742ff1e51.tar.bz2
protobuf-547d8e8221b8ea7ff7010cbc601f4e5742ff1e51.zip
Make FieldDescriptor.IsPacked work appropriately.
This is a bit of a grotty hack, as we need to sort of fake proto2 field presence, but with only a proto3 version of the descriptor messages (a bit like oneof detection). Should be okay, but will need to be careful of this if we ever implement proto2.
Diffstat (limited to 'csharp/src/Google.Protobuf/Reflection/PartialClasses.cs')
-rw-r--r--csharp/src/Google.Protobuf/Reflection/PartialClasses.cs12
1 files changed, 12 insertions, 0 deletions
diff --git a/csharp/src/Google.Protobuf/Reflection/PartialClasses.cs b/csharp/src/Google.Protobuf/Reflection/PartialClasses.cs
index c7ed4342..8c055d6d 100644
--- a/csharp/src/Google.Protobuf/Reflection/PartialClasses.cs
+++ b/csharp/src/Google.Protobuf/Reflection/PartialClasses.cs
@@ -44,4 +44,16 @@ namespace Google.Protobuf.Reflection
OneofIndex = -1;
}
}
+
+ internal partial class FieldOptions
+ {
+ // We can't tell the difference between "explicitly set to false" and "not set"
+ // in proto3, but we need to tell the difference for FieldDescriptor.IsPacked.
+ // This won't work if we ever need to support proto2, but at that point we'll be
+ // able to remove this hack and use field presence instead.
+ partial void OnConstruction()
+ {
+ Packed = true;
+ }
+ }
} \ No newline at end of file