Commit Graph

418 Commits

Author SHA1 Message Date
Jon Skeet
a4dc5968b1 Add JSON parsing to conformance tests. 2015-12-16 08:58:58 +00:00
Jon Skeet
adee6fe332 Generated code changes from previous commit. 2015-12-15 09:24:04 +00:00
Jon Skeet
aabc6c411a Make ToString() valid without a type registry
This addresses issue #1008, by creating a JsonFormatter which is private and only different
to JsonFormatter.Default in terms of reference equality.

Other plausible designs:

- The same, but expose the diagnostic-only formatter
- Add something to settings to say "I don't have a type registry at all"
- Change the behaviour of JsonFormatter.Default (bad idea IMO, as we really *don't* want the result of this used as regular JSON to be parsed)

Note that just trying to find a separate fix to issue #933 and using that to override Any.ToString() differently wouldn't work for messages that *contain* an Any.

Generated code changes follow in the next commit.
2015-12-15 09:23:38 +00:00
Jon Skeet
3de2fced6b Handle JSON parsing for Any.
This required a rework of the tokenizer to allow for a "replaying" tokenizer, basically in case the @type value comes after the data itself. This rework is nice in some ways (all the pushback and object depth logic in one place) but is a little fragile in terms of token push-back when using the replay tokenizer. It'll be fine for the scenario we need it for, but we should be careful...
2015-12-02 07:54:34 +00:00
Jon Skeet
567579b505 JSON formatting for Any. 2015-12-02 07:26:55 +00:00
Jon Skeet
a2667aafd8 Generated code changes for previous commit (basically InternalBuildGeneratedFileFrom => FromGeneratedCode) 2015-11-22 16:30:36 +00:00
Jon Skeet
72ec33676f Tidy up reflection in advance of attempting to implement DynamicMessage.
There are corner cases where MessageDescriptor.{ClrType,Parser} will return null, and these are now documented. However, normally they *should* be implemented, even for descriptors of for dynamic messages. Ditto FieldDescriptor.Accessor.
We'll still need a fair amount of work to implement dynamic messages, but this change means that the public API will be remain intact.

Additionally, this change starts making use of C# 6 features in the files that it touches. This is far from exhaustive, and later PRs will have more.

Generated code changes coming in the next commit.
2015-11-22 16:25:44 +00:00
Jon Skeet
f7e43c6f80 Added the type registry in advance of implementing Any support.
Biting off just this bit first as I don't need the changes from a previous PR for this part.
2015-11-21 03:34:58 +00:00
Jan Tattermusch
956a770adc Merge pull request #988 from gabikliot/CSharp-SampleUsage-Big-Fix
Fixed a bug in CSharp SampleUsage.
2015-11-19 20:02:18 -08:00
Gabriel Kliot
bdec990703 Removed redundant comment. 2015-11-19 08:05:05 -08:00
Jon Skeet
360feda5f7 Finished an implementation comment 2015-11-19 09:40:49 +00:00
Jon Skeet
eadd4caa09 Generated code from previous commit. 2015-11-19 09:38:49 +00:00
Jon Skeet
2a15051a1e Introduce a Parser property into MessageDescriptor, and populate it from generated types.
Generated code coming in next commit - in a subsequent PR I want to do a bit of renaming and redocumenting around this, in anticipation of DynamicMessage.
2015-11-19 08:50:28 +00:00
Gabriel Kliot
09d03dfc7e Fixed a bug in CSharp SampleUsage. 2015-11-18 23:09:05 -08:00
Jon Skeet
284bb452e4 Generated code changes and manual changes for previous commit. 2015-11-09 09:22:45 +00:00
Jon Skeet
cff900e8f9 Generated code for previous commit. 2015-11-06 18:38:31 +00:00
Jan Tattermusch
ffe25c76ea Merge pull request #941 from jskeet/recursion-limit
Add recursion limit handling to JSON parsing.
2015-11-05 18:41:05 -08:00
Jon Skeet
6fa17e7597 Reimplement JSON recursion by detecting the depth in the tokenizer.
Added a TODO around a possible change to the tokenizer API, changing PushBack(token) into just Rewind() or something similar.
2015-11-05 19:44:26 +00:00
Jon Skeet
3a72a1eeaf Merge pull request #940 from jskeet/json-names
Move the creation of the "fields by JSON name" dictionary to the descriptor
2015-11-05 17:09:37 +00:00
Jon Skeet
0fb39c4afe Created a new exception for JSON failures.
This is only thrown directly by JsonTokenizer, but surfaces from JsonParser as well. I've added doc comments to hopefully make everything clear.

The exception is actually thrown by the reader within JsonTokenizer, in anticipation of keeping track of the location within the document, but that change is not within this PR.
2015-11-05 10:40:22 +00:00
Jon Skeet
3d257a9dc1 Add recursion limit handling to JSON parsing.
Fixes issue #932.
2015-11-04 11:30:22 +00:00
Jon Skeet
6a94273549 Move the creation of the "fields by JSON name" dictionary to the descriptor. 2015-11-04 09:09:14 +00:00
Jon Skeet
fb2488225f Implement JSON parsing in C#.
This includes all the well-known types except Any.
Some aspects are likely to require further work when the details of the JSON parsing expectations are hammered out in more detail. Some of these have "ignored" tests already.

Note that the choice *not* to use Json.NET was made for two reasons:
- Going from 0 dependencies to 1 dependency is a big hit, and there's not much benefit here
- Json.NET parses more leniently than we'd want; accommodating that would be nearly as much work as writing the tokenizer
This only really affects the JsonTokenizer, which could be replaced by Json.NET. The JsonParser code would be about the same length with Json.NET... but I wouldn't be as confident in it.
2015-11-03 19:05:11 +00:00
Jon Skeet
885406abcf Make BytesString.Unsafe internal (which it should have been all along) 2015-11-02 09:59:06 +00:00
Jon Skeet
f5a0a7feeb Fix clearing wrapper type fields with reflection.
The nullable value type fields already worked, but the use of the CLR property concealed the difference between string and StringWrapper fields.
2015-10-30 09:37:01 +00:00
Jon Skeet
55313c9c5d Generated code for previous commit (oneof case contributing to hash code and equality). 2015-10-24 06:46:02 +01:00
Jon Skeet
964627ece0 Include the oneof-case in equality and hash code generated code.
The included C# test will fail until the regenerated code is used, which is in the next commit.
2015-10-24 06:45:20 +01:00
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
Jon Skeet
e94bdd9303 Allow partially-trusted callers again.
Fixes issue #552. (And yay, it looks like our build profile supports this...)
2015-08-03 11:24:17 +01:00
Jon Skeet
bf1cc9217a Merge pull request #675 from jtattermusch/signing
Add ReleaseSigned configuration for C#
2015-08-03 11:16:31 +01:00
Jon Skeet
e7caf15577 Initial pass at formatting Struct as JSON.
This seems remarkably little code, but it appears to work. I can add tests for invalid structs at some point, once the general approach is approved.
2015-08-03 09:32:36 +01:00
Jon Skeet
801b169bce Addressed issues raised in code review. Will merge when green. 2015-08-03 09:26:05 +01:00
Jon Skeet
16e272e0c4 Format JSON for Duration and Timestamp.
This is taking an approach of putting all the logic in JsonFormatter. That's helpful in terms of concealing the details of whether or not to wrap the value in quotes, but it does lack flexibility. I don't *think* we want to allow user-defined formatting of messages, so that much shouldn't be a problem.
2015-08-03 09:26:04 +01:00
Jan Tattermusch
d331d2f60f make changes and fixes in signing 2015-08-02 01:24:27 -07:00
Jan Tattermusch
0df900f0dc added protoc.exe and well known protobuf files to the nuspec file 2015-08-02 01:20:42 -07:00
Jan Tattermusch
538ef54f1e build signed assemblies 2015-08-02 01:20:40 -07:00
Jon Skeet
6cf5f660e5 Simplify the JSON tests for readability
Use ' instead of " in the expected JSON, then replace it before asserting.
2015-07-31 10:46:24 +01:00
Jon Skeet
4fed0b515f Fix JSON formatting to always emit fields in field order, including oneofs 2015-07-31 10:34:20 +01:00
Jon Skeet
fd02e45b2a Fix trivial bug in field orderings.
(Shows the benefit of unit testing even code "too simple to fail"...)
2015-07-31 10:34:04 +01:00
Jon Skeet
9629797331 Well-known type operations for Timestamp and Duration (but not JSON formatting).
While I've provided operators, I haven't yet provided the method equivalents. It's not clear to me that
they're actually a good idea, while we're really targeting C# developers who definitely *can* use the user-defined operators.
2015-07-31 08:14:11 +01:00
Jon Skeet
f994cfe808 Handle field names of "descriptor" and "types". 2015-07-31 07:00:25 +01:00
Jon Skeet
d18cc08456 Generated code for previous commit. 2015-07-30 13:50:02 +01:00
Jon Skeet
3980cf9df1 Prohibit null values for string/bytes fields in generated code. 2015-07-30 13:36:46 +01:00
Jon Skeet
68380f0f66 Rename ThrowHelper to Preconditions and make it public - we'll want to use it from the generated code soon.
Additionally, change it to return the value passed, and make it generic with a class constraint.
A separate method doesn't have the class constraint, for more unusual scenarios.
2015-07-30 13:36:45 +01:00
Jon Skeet
dea15a7ca4 Generated code from previous commit. 2015-07-30 13:16:00 +01:00
Jon Skeet
f03271665f More freezing tidy-up; generated code in next commit. 2015-07-30 13:15:45 +01:00
Jon Skeet
3b2fe97b6f Minor bits of left-over frozenness. 2015-07-30 13:07:50 +01:00
Jon Skeet
7a0effb9e9 Merge pull request #654 from jtattermusch/csharp_hide_freeze
Remove the C# Freeze API
2015-07-30 09:47:38 +01:00
Jan Tattermusch
7ec023acf4 regenerate code 2015-07-29 20:26:20 -07:00
Jan Tattermusch
3783d9a8ad remove the freeze API 2015-07-29 20:26:20 -07:00
Jan Tattermusch
fa29148137 add IsClientStreaming and IsServerStreaming to MethodDescriptor 2015-07-29 18:48:54 -07:00
Jon Skeet
d82ebe48e1 Update the readme file to indicate supported platforms 2015-07-28 10:23:11 +01:00
Jon Skeet
9ccc83990d Humbug - previous commit didn't include project file changes :( 2015-07-28 09:01:13 +01:00
Jon Skeet
0802d56fcd Tweaks to Profile259 support
- Fix nupec paths
- Remove an obsolete part of the JSON build
- Add documentation and tests to reflection extension methods, and improve implementations
2015-07-28 08:16:50 +01:00
Jon Skeet
0dbd5ec80d First attempt at using profile 259 for Google.Protobuf.
This requires .NET 4.5, and there are a few compatibility changes required around reflection.
Creating a PR from this to see how our CI systems handle it. Will want to add more documentation,
validation and probably tests before merging.

This is in aid of issue #590.
2015-07-27 07:47:50 +01:00
Jan Tattermusch
3b8c83eff1 expose original binary data for filedescriptor 2015-07-24 20:27:35 -07:00
Jon Skeet
c1c6b2d0d5 Implemented Jan's suggestion of FieldCollection, replacing FieldAccessorCollection.
I think Jan was actually suggesting keeping both, but that feels redundant to me. The test diff is misleading here IMO, because I wouldn't expect real code using reflection to use several accessors one after another like this, unless it was within a loop. Evidence to the contrary would be welcome :)

This change also incidentally goes part way to fixing the issue of the JSON formatter not writing out the fields in field number order - with this change, it does except for oneofs, which we can fix in a follow-up change.

I haven't actually added a test with a message with fields deliberately out of order - I'm happy to do so though. It feels like it would make sense to be in google/src/protobuf, but it's not entirely clear what the rules of engagement are for adding new messages there. (unittest_proto3.proto?)
2015-07-22 20:13:38 +01:00
Jon Skeet
5e0cfc9a47 Added newlines 2015-07-22 20:13:37 +01:00
Jon Skeet
20bf6a563a First pass at making field access simpler.
This is definitely not ready to ship - I'm "troubled" by the disconnect between a list of fields in declaration order, and a mapping of field accessors by field number/name. Discussion required, but I find that easier when we've got code to look at :)
2015-07-22 20:13:37 +01:00
Jon Skeet
e2368c9022 Fix attribute mistake and regenerate code. 2015-07-22 13:47:16 +01:00
Jon Skeet
47bf49b9fa Generated code for previous commit. 2015-07-22 11:39:38 +01:00
Jon Skeet
4668c3dc39 Remove the usage of attributes for field/method discovery.
Instead, introduce GeneratedCodeInfo which passes in what we need, and adjust the codegen to take account of this.
2015-07-22 11:38:22 +01:00
Jon Skeet
8d115298c7 Fix comment typo 2015-07-21 12:59:42 +01:00
Jon Skeet
96cffaa8e3 Generated code changes following previous commit. 2015-07-21 12:59:41 +01:00
Jon Skeet
53c399a1d6 Revamp to reflection.
Changes in brief:
1. Descriptor is now the entry point for all reflection.
2. IReflectedMessage has gone; there's now a Descriptor property in IMessage, which is explicitly implemented (due to the static property).
3. FieldAccessorTable has gone away
4. IFieldAccessor and OneofFieldAccessor still exist; we *could* put the functionality straight into FieldDescriptor and OneofDescriptor... I'm unsure about that.
5. There's a temporary property MessageDescriptor.FieldAccessorsByFieldNumber to make the test changes small - we probably want this to go away
6. Discovery for delegates is now via attributes applied to properties and the Clear method of a oneof

I'm happy with 1-3.
4 I'm unsure about - feedback welcome.
5 will go away
6 I'm unsure about, both in design and implementation. Should we have a ProtobufMessageAttribute too? Should we find all the relevant attributes in MessageDescriptor and pass them down, to avoid an O(N^2) scenario?

Generated code changes coming in the next commit.
2015-07-21 12:59:40 +01:00
Jan Tattermusch
43b17376f7 update addressbook example 2015-07-20 16:00:26 -07:00
Jan Tattermusch
352690efc7 regenerate Addressbook.cs 2015-07-20 15:53:19 -07:00
Jon Skeet
c9fd53a3b7 First part of JSON formatting for well-known types. I think we need a reflection API rethink before doing the rest. 2015-07-20 11:48:24 +01:00
Jan Tattermusch
9b28d4b12c Fix typo in buildall.sh 2015-07-17 12:19:20 -07:00
Jon Skeet
59eeebee87 First pass at the big rename from ProtocolBuffers to Google.Protobuf.
We'll see what I've missed when CI fails...
2015-07-17 08:26:04 +01:00
Jon Skeet
34878cb14e Fixes from PR review. 2015-07-17 06:41:46 +01:00
Jon Skeet
3da90e9f54 Make the map test actually test the code... 2015-07-16 21:34:10 +01:00
Jon Skeet
8a0312b201 First pass at wrapper types.
- We do still generate the message types, as otherwise reflection breaks, even though it doesn't actually use those types.
- JSON handling hasn't been implemented yet
2015-07-16 17:03:06 +01:00
Jon Skeet
8d47ec4f3e Fixes to ByteString's equality handling. 2015-07-16 09:36:31 +01:00
Jon Skeet
b2ac868493 First part of implementing wrapper types. Not ready yet! 2015-07-16 09:36:30 +01:00
Jon Skeet
78b452b7ac Remove the struct-based iterator for RepeatedField.
We don't use it in the runtime or generated code anywhere now, so the extra small performance boost isn't as critical, and it has some undesirable consequences.

The tests have needed to change as iterator block enumerators don't throw when we might expect them to.
2015-07-16 09:26:10 +01:00
Jan Tattermusch
b4a24aa5fa added comment for ByteString.CopyFrom 2015-07-15 23:29:45 -07:00
Jan Tattermusch
ab5fffcc9e C# cleanup - assorted nits 2015-07-15 23:29:45 -07:00
Jon Skeet
541b442b99 Don't create nested types (or field accessors) for map types.
I'm sure I've implemented this before, but somehow it's been lost in a maze of twisty little branches, all alike.
2015-07-15 22:04:45 +01:00
Jon Skeet
62a4aa56d4 Generated code for well-known types 2015-07-14 14:26:49 +01:00
Jon Skeet
739d13d5d1 Generate the well-known types in C#
This involves:
- Specifying a namespace in each proto (including ones we'd previously missed)
- Updating the generation script
- Changing codegen to implement IReflectedMessage.Fields explicitly (a good thing anyway)
- Changing reflection tests to take account of the explicit interface implementation

Non-generated code in this commit; generated code to follow
2015-07-14 14:26:31 +01:00
Jon Skeet
1660c5631e Changing reflection namespace (part 4)
Update code already within Google.Protobuf.Reflection which was importing Google.Protobuf.DescriptorProtos
2015-07-14 11:38:06 +01:00
Jon Skeet
9c888fa3a2 Changing reflection namespace (part 3)
Change the C# namespace in descriptor.proto to Google.Protobuf.Reflection.
This then means changing where the generated code lives, which means updating the project file...

It also involves regenerating the C++ - which has updated the well-known types as well,
for no terribly obvious reason...
2015-07-14 11:13:52 +01:00
Jon Skeet
76940942cf Changing reflection namespace (part 2)
Generated code changes from previous commit
2015-07-14 10:25:40 +01:00
Jon Skeet
9f37de960f Changing reflection namespace (part 1)
- Move types into Google.Protobuf.Reflection
- Change codegen to reflect that in generated types

Generated code changes coming in part 2
2015-07-14 10:24:52 +01:00
Jon Skeet
9440a2abe3 Merge pull request #582 from jskeet/csharp-json
JSON formatting in C#
2015-07-14 09:50:57 +01:00
Jon Skeet
0f34daad07 Changes suggested during review.
- Remove the indexers in FieldAccessorTable
- Add a TODO for field ordering in oneof
2015-07-14 09:41:28 +01:00
Jan Tattermusch
6c8c5b402b Update Google.Protobuf.nuspec 2015-07-12 11:51:08 -07:00
Jan Tattermusch
46feed023d enable building nuget package 2015-07-10 15:23:28 -07:00
Jon Skeet
6ea9bc7aa3 Fixes to JsonFormatter
- Handle oneof properly
- Omit unknown enum values
2015-07-10 14:05:52 +01:00
Jon Skeet
68fc689e52 Generated code changes for previous submit 2015-07-10 14:05:17 +01:00
Jon Skeet
ef3464dff6 Oneof reflection support. (Generated code changes in next commit.) 2015-07-10 14:04:53 +01:00
Jon Skeet
5b9288e47d Use the new JsonFormatter to implement ToString on generated messages. 2015-07-10 11:42:56 +01:00
Jon Skeet
f8c151f21e Initial implementation of JSON formatting
- No parsing
- Reflection based, so not hugely efficient
- No line breaks or indentation
2015-07-10 11:42:56 +01:00
Jon Skeet
0da4a89c97 Knock-on effects of moving GetSampleMessage. 2015-07-09 08:26:07 +01:00
Jon Skeet
14f2222a50 Lots more tests for FieldCodec, MapField, RepeatedField
... and some implementation changes to go with them.
2015-07-09 08:26:07 +01:00
Jon Skeet
af259b77bf Fix descriptor reflection in various ways
- The protos are no longer publicly exposed at all
- Oneof detection now works (as we default to -1, not 0)
- OneofDescriptor exposes the fields in the oneof
- Removed unnecessary code for replacing protos - remnant of extensions
- There's now just the non-generic form of IDescriptor
2015-07-09 08:26:06 +01:00
Jon Skeet
5350822b0a Regenerated code due to previous commit.
Note that now we need a proto3 version of addressbook.proto. This may affect other platforms, and could do with an overhaul to follow proto3 conventions anyway (e.g. repeated field names). Will need to think about that carefully before merging into master. Raised issue #565 for this.
2015-07-09 08:26:05 +01:00
Jon Skeet
462d569ec0 Changes to generated code due to previous commit. 2015-07-09 08:24:50 +01:00
Jon Skeet
78ea98f56f Implement reflection properly for fields.
- FieldAccessorTable is now non-generic
- We don't have a static field per message type in the umbrella class. (Message descriptors are accessed via the file descriptor.)
- Removed the "descriptor assigner" complication from the descriptor fixup; without extensions, we don't need it
- MapField implements IDictionary (more tests would be good...)
- RepeatedField implements IList (more tests would be good)
- Use expression trees to build accessors. (Will need to test this on various platforms... probably need a fallback strategy just using reflection directly.)
- Added FieldDescriptor.IsMap
- Added tests for reflection with generated messages

Changes to generated code coming in next commit.
2015-07-09 08:24:49 +01:00
Jon Skeet
3cce11ce1c Minor fix-ups as suggested in PR #560.
- Added new line at the end of SampleEnum
- Moved GeneratedMessageTest.GetSampleMessage to a new class, SampleMessages, and renamed it to CreateFullTestAllTypes.
2015-07-09 08:12:44 +01:00