Commit Graph

291 Commits

Author SHA1 Message Date
Jon Skeet
c34ed5c9bf Merge pull request #846 from jskeet/tostring
Support ToString in RepeatedField and MapField.
2015-10-07 17:08:25 +01:00
Jon Skeet
9ed6d4da37 Support ToString in RepeatedField and MapField.
This changes how we approach JSON formatting in general - instead of looking  at the field a value came from, we just look at the type of the value. It's possible this *could* be slightly inefficient, but if we start caring about JSON performance deeply, we'll probably want to rewrite all of this anyway. It's definitely simpler this way.

When we support dynamic messages, we'll need to modify JsonFormatter to handle enum values, as they won't come be "real" .NET enums at that point. It shouldn't be hard to do though.
2015-10-01 13:07:47 +01:00
Jon Skeet
18e0a2e5ec Generated code from previous commit. 2015-10-01 10:38:01 +01:00
Jon Skeet
6bbbdfa24c Fix typo in oneof case enum comment 2015-09-30 06:59:38 +01:00
Jon Skeet
e2c823027e Generated code changes for previous commit. 2015-09-29 14:34:31 +01:00
Jon Skeet
b0888a42ad Generated code for previous commit 2015-09-29 13:37:30 +01:00
Jon Skeet
2212f56bcd Added documentation to generated code.
There are now summaries for:
- The Types nested class (which holds nested types)
- The file descriptor class for each proto
- The enum generated for each oneof

(Also fixed two typos.)

Generated code in next commit.
2015-09-29 13:37:15 +01:00
Jan Tattermusch
97a1c1e08d Merge pull request #785 from jskeet/csharp-directories
Generate C# directory hierarchy with new option
2015-09-23 14:31:31 -07:00
Jon Skeet
e50461d809 Pack/Unpack implementation for Any.
We still need the JSON representation, which relies on something like a DescriptorPool to fetch message types from based on the type URL. That will come a bit later.
(The DescriptorPool comment in this commit is just a note which will prove useful if we use DescriptorPool itself.)
2015-09-04 12:43:26 +01:00
Jon Skeet
9489817df2 Regenerated code. Most changes are whitespace, removing trailing spaces.
Other changes are due to the well-known types changing without us regenerating.
2015-09-01 15:47:48 +01:00
Jon Skeet
5eb1fac983 Generate a directory hierarchy based on namespace (C#)
This introduces a new C# option, base_namespace.
If the option is not specified, the behaviour is as before: no directories are generated.
If the option *is* specified, all C# namespaces must be relative to the base namespace, and the directories are generated relative to that namespace.

Example:
- Any.proto declares csharp_namespace = "Google.Protobuf.WellKnownTypes"
- We build with --csharp_out=Google.Protobuf --csharp_opt=base_namespace=Google.Protobuf
- The Any.cs file is generated in Google.Protobuf/WellKnownTypes (where it currently lives)

We need a change to descriptor.proto before this will all work (it wasn't in the right C# namespace) but that needs the other descriptors to be regenerated too. See next commit...
2015-09-01 15:05:03 +01:00
Jan Tattermusch
8fca6f83c6 Update README.md for C# 2015-08-26 15:26:34 -07:00
Jon Skeet
b1b98e4b79 Merge pull request #738 from jtattermusch/include_descriptor_proto
Include descriptor.proto in nuget package
2015-08-26 06:44:26 +01:00
Jan Tattermusch
295047518c include descriptor.proto in nuget package 2015-08-25 18:43:01 -07:00
Jon Skeet
31d119af22 Remove extraneous TODO 2015-08-25 17:51:17 +01:00
Jon Skeet
ca89a1a118 Change where we rename Descriptor.cs to DescriptorProtoFile.cs.
We now do this in protoc instead of the generation simpler.

Benefits:
- Generation script is simpler
- Detection is simpler as we now only need to care about one filename
- The embedded descriptor knows itself as "google/protobuf/descriptor.proto" avoiding dependency issues

This PR also makes the "invalid dependency" exception clearer in terms of expected and actual dependencies.
2015-08-25 14:32:28 +01:00
Jan Tattermusch
fa2fe35dec fix type initialization problem with FileDescriptor 2015-08-14 13:38:34 -07:00
Jan Tattermusch
143688f68b add a failing descriptor test 2015-08-14 13:23:44 -07:00
Jan Tattermusch
a55a4449ef remove duplicate test case 2015-08-14 13:16:04 -07:00
Jon Skeet
a39ababb7c Allow public access to descriptor.proto as a dependency.
With this in place, generating APIs on github.com/google/googleapis works - previously annotations.proto failed.
Currently there's no access to the annotations (stored as extensions) but we could potentially expose those at a later date.
2015-08-13 12:01:41 +01:00
Jon Skeet
f2732c7af1 More TODOs done.
- Removed a TODO without change in DescriptorPool.LookupSymbol - the TODOs were around performance, and this is only used during descriptor initialization
- Make the CodedInputStream limits read-only, adding a static factory method for the rare cases when this is useful
- Extracted IDeepCloneable into its own file.
2015-08-10 19:18:18 +01:00
Jon Skeet
29fe8d223e Merge pull request #701 from jskeet/map-views
Implement Keys and Values as views in MapField
2015-08-10 12:44:49 +01:00
Jon Skeet
4deea8c231 Fix parameter name in exception. 2015-08-10 09:03:43 +01:00
Jon Skeet
5be01ee65b Implement ICollection.CopyTo (using Array) for MapField views. 2015-08-10 08:47:07 +01:00
Jon Skeet
3f45d7c11e Implement Keys and Values as views 2015-08-08 08:59:53 +01:00
Jon Skeet
547d8e8221 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.
2015-08-08 07:27:58 +01:00
Jon Skeet
c671095e91 Address review comments. 2015-08-08 07:26:26 +01:00
Jon Skeet
889b88a29f Remove reference to generic types within XML comment.
Visual Studio is happy with it, but Mono isn't :(
2015-08-08 07:25:29 +01:00
Jon Skeet
6f300442bc Tidying up - fix a bunch of TODOs and remove outdated ones. 2015-08-08 07:25:28 +01:00
Jon Skeet
6e16037c99 Address review comments. 2015-08-08 07:24:28 +01:00
Jon Skeet
5bdc57292f Generated code for previous commit. 2015-08-06 11:40:43 +01:00
Jon Skeet
e7f88ff129 Skip groups properly.
Now the generated code doesn't need to check for end group tags, as it will skip whole groups at a time.
Currently it will ignore extraneous end group tags, which may or may not be a good thing.
Renamed ConsumeLastField to SkipLastField as it felt more natural.
Removed WireFormat.IsEndGroupTag as it's no longer useful.

This mostly fixes issue 688.

(Generated code changes coming in next commit.)
2015-08-06 11:40:32 +01:00
Jon Skeet
38032688a7 Make InvalidProtocolBufferException.InvalidTag internal.
We don't need to expose the InvalidProtocolBufferException factory method now that the generated code doesn't throw the exception.
2015-08-05 17:48:53 +01:00
Jon Skeet
1a57ad8b41 Generated code changes for previous commit. 2015-08-05 11:23:52 +01:00
Jon Skeet
ff334a60eb Change ReadTag and PeekTag to just use 0 as a return value for "end of stream", rather than using an awkward out parameter.
This simplifies quite a lot of code.

Generated code in next commit.
2015-08-05 11:23:38 +01:00
Jon Skeet
c13a612dc4 Update AssemblyInfo for conformance - mostly to fix version numbers. 2015-08-05 07:09:43 +01:00
Jon Skeet
15bf55e225 Validate that after reading a message, we've consumed as many bytes as we expected to.
We should now have no conformance failures.
2015-08-05 07:09:43 +01:00
Jon Skeet
fe355b26ec Generated code changes for previous commit. 2015-08-05 07:09:42 +01:00
Jon Skeet
9df2defa29 Consume unknown fields when parsing.
This is expected to be the cause of the conformance test failures.
Generated code in next commit.
2015-08-05 07:09:41 +01:00
Jon Skeet
044c36ebef First pass at C# conformance tests.
Completely untested so far - easier to get started in VS and then transfer to Linux for tweaking...
2015-08-05 07:09:39 +01:00
Jon Skeet
d77d70d227 Merge pull request #691 from jskeet/xml-documentation
Document everything, and turn on errors if we fail to document anything in the future
2015-08-05 07:09:17 +01:00
Jon Skeet
30e8157550 Fix one cref that Mono was unhappy with 2015-08-05 06:39:43 +01:00
Jon Skeet
811fc89f0e Document everything, and turn on errors if we fail to document anything in the future. 2015-08-04 15:58:39 +01:00
Jon Skeet
99a81d297c Fix build warnings around unused variables 2015-08-04 07:10:36 +01:00
Jon Skeet
b59bfcb309 Merge pull request #681 from jskeet/json-fieldmask
JSON formatting for FieldMask
2015-08-03 17:32:28 +01:00
Jon Skeet
8136ad5c3c Merge pull request #677 from jskeet/move-protos
Remove a redundant layer of directory hierarchy.
2015-08-03 15:19:50 +01:00
Jon Skeet
415f72e079 Merge pull request #680 from jskeet/aptca
Allow partially-trusted callers again.
2015-08-03 14:05:52 +01:00
Jon Skeet
0e30de3d6b JSON formatting for FieldMask 2015-08-03 14:03:11 +01:00
Jon Skeet
0e0e0c97e7 Expose Coded*Stream constructors directly. 2015-08-03 11:30:15 +01:00
Jon Skeet
0f370b468b Remove a redundant layer of directory hierarchy. 2015-08-03 11:29:59 +01:00