Commit Graph

30 Commits

Author SHA1 Message Date
Wouter van Oortmerssen 8c0d56d55a Removed BOM marker from some files.
Also removed some trailing whitespace.

Change-Id: I40bf4f776ca4d467b7ee6f2c9a7500c13700f9d5
2016-05-23 12:24:44 -07:00
Wojciech Jaszczak c837d29eab Remove unnecessary condition in AssertOffsetAndLength.
Condition is already checked and covered in the following condition, the second one was excess.

Signed-off-by: Wojciech Jaszczak <jaszczakw@gmail.com>
2016-04-08 19:56:02 +02:00
Oli Wilkinson fff4590faf Implemented ForceDefaults option on C# FlatBufferBuilder.
Tested on: Windows, Unit Tests
2016-01-20 17:25:58 +00:00
Mark Klara 69a31b807a Revamping the FlatBuffers docs.
Adding an API reference for the supported languages.

General docs cleanup, including a new `tutorial` section that
supports all of the supported languages.

Added samples for each supported language to mirror the new
tutorial page.

Cleaned up all the links by making them `@ref` style links,
instead of referencing the names of the generated `.html` files.

Removed all generated files that were unnecessarily committed.

Also fixed the C# tests (two were failing due to a missing file).

Bug: b/25801305

Tested: Tested all samples on Ubuntu, Mac, and Android. Docs were
generated using doxygen and viewed on Chrome.

Change-Id: I2acaba6e332a15ae2deff5f26a4a25da7bd2c954
2016-01-19 14:31:17 -08:00
Wouter van Oortmerssen 2ce5d6c2b6 Merge pull request #2090 from evolutional/cs-perf-string
C# - Performance optimizations
2015-12-14 15:16:46 -08:00
Oli Wilkinson be11d2b6ef C# performance optimization to Pad/Prep methods 2015-12-12 11:39:57 -05:00
Oli Wilkinson b8187e5b82 Performance tweak to FlatBufferBuilder.CreateString method to remove the unnecessary byte buffer allocation
(See https://github.com/google/flatbuffers/issues/55#issuecomment-164031718 for stats)
2015-12-11 14:57:59 -05:00
Wouter van Oortmerssen 96cd275603 Merge pull request #288 from mfcollins3/csharp-byte-buffer
Add Get Bytes Method Generator for C#
2015-12-07 17:35:57 -08:00
Wouter van Oortmerssen 42b48bd55f Merge pull request #776 from belldon/bytebuffer_pos_fix
Extend C# ByteBuffer Put method fix to unsafe methods
2015-12-07 16:19:05 -08:00
belldon 8db90f5073 Extend C# ByteBuffer Put method fix to unsafe methods
Fixes issue #243.  Extends the initial C# ByteBuffer fix
(e4c3bf3d2c) to Put methods
used when UNSAFE_BYTEBUFFER is defined.
2015-12-07 16:43:55 -05:00
belldon d5a113e5bf Update C# FlatBufferBuilder to reuse vtable array
This commit updates the FlatBufferBuilder class to reuse the vtable
array instead of creating a new array with every StartObject() call.
2015-12-07 16:42:21 -05:00
Michael Collins e083e466b8 Add Get Bytes Method Generator for C#
I updated idl_gen_general.cpp to add support for generating a Get Bytes
method for a vector to the generated C# source code. Given a byte vector
field named Foo, a method named GetFooBytes() will be generated in the
C# source code that will return an ArraySegment<byte> value referencing
the vector data in the underlying ByteBuffer.

I added a method to Table.cs named __vector_as_arraysegment that is used
by the code generated by the change to the C# generator.
__vector_as_arraysegment will take the offset of the vector and will
return the ArraySegment<byte> value corresponding to the bytes that
store the vector data.

I updated FlatBuffersExampleTests.cs to add tests to validate my
implementation of Table.__vector_as_arraysegment. I added tests to
demonstrate that the bytes for the monster's name can be extracted from
the underlying byte array. I also added tests to show that
Table.__vector_as_arraysegment returns a null value if the vector is not
present in the FlatBuffer.

I used the updated flatc.exe program to regenerate the C# source files
for the MyGame example. The new Monster class includes the GetXXXBytes
methods to return the byte arrays containing data for vectors.
2015-12-04 11:44:43 -07:00
Shuhei Taunma b98f526b8a (C#) Add ByteBuffer property to Table 2015-11-10 14:32:31 +09:00
Maor Itzkovitch b062af4c8c rebased fork 2015-08-07 18:59:59 +03:00
Maor Itzkovitch 3a74c33ba5 removed console print from code 2015-08-07 10:57:37 +03:00
Maor Itzkovitch e4c3bf3d2c fixed C# bytebuffer put methods 2015-08-07 10:51:15 +03:00
Maor Itzkovitch e24afd838a extended scalar mutator support 2015-08-01 19:08:22 +03:00
RevenantX 588564d74f Base type safety in C#. Clear FlatBufferBuilder in C#. 2015-07-29 00:33:45 +03:00
Mormegil 221193eaa2 Union accessors in C# should use generic type for the table
When accessing a union field, we should return the same object type
as was given to the method, i.e. the parameter should have a generic
type for any Table-derived type. This way, we do not need to make
superfluous casts (which also reduce type safety) like

var myUnionType = (MyUnionType)buff.GetUnionField(new MyUnionType());

when we can do just
var myUnionType = buff.GetUnionField(new MyUnionType());

Change-Id: Idac1b638e46cc50b1f2dc19f10741481202b1515
2015-05-08 16:21:54 -07:00
Mormegil 0ee1b99c5d [BREAKING CHANGE] Field accessors should use property getters in C#
In C#, plain field accessors should not be nonparametric methods
but should be standard property getters.

The accessor methods with parameters were renamed to `GetXxx`
because a method cannot be named identically to a property.

Also, `ByteBuffer.Position`, `FlatBufferBuilder.Offset` and
`FlatBufferBuilder.DataBuffer` are now properties instead
of nonparametric accessor methods, for more idiomatic C# style.

This is a breaking change, all client C# code accessing these
fields needs to be changed (i.e. remove those `()` or add the
`Get` prefix).

Issue: #77
Change-Id: Iaabe9ada076e5ea2c69911cf6170fdda2df3487e
2015-05-06 11:55:07 -07:00
Wouter van Oortmerssen f7818d83d7 Changed C# ByteBuffer to use bit shifts instead of BitConverter
BitConverter was excessively slow since it allocates a byte array
at each access.

Bug: 18702381
Change-Id: I47be9c38e1d04287ba4c10bc369848f3e13a2a2f
Tested: on Windows.
2015-03-13 16:59:29 -07:00
Wouter van Oortmerssen 7ef2fc2517 Regenerated test code + fixed typo in C# FlatBufferBuilder
Change-Id: Ifa6d9459c53ae60b9bf936d9468ec971ee282f14
Tested: on Linux and Windows.
2015-03-13 13:05:28 -07:00
loverszhaokai 432f3f26a4 Added Copyright headers
Change-Id: I106de8985cea572590d49c896b72c54f33e73bd2
2015-03-11 17:27:38 -07:00
Grégoire Astruc 71e97b7123 Fixed C# Table.cs to work with Mono.
Cast to short for mono compatibility.

Change-Id: I568059a21369b895fa52002fa231f7594f0f736c
2015-02-23 15:57:35 -08:00
Wouter van Oortmerssen 4fb5a764df Support for booleans in the Java/C# API
Change-Id: I72e92183a7b5f4145ea51fcec29257dc9553a461
2015-01-26 13:08:44 -08:00
Wouter van Oortmerssen e568f17096 Fixed C# SizedByteArray copying leading bytes of ByteBuffer.
Tested: on Windows.

Change-Id: I946dacf799eae835ec041ea759622f74b0384937
2015-01-16 15:36:25 -08:00
Jon Simantov 4390254e6a C#: Allow ByteBuffer to use faster unsafe mode
If your C# runtime environment supports unsafe mode, you can use
the #define UNSAFE_BYTEBUFFER setting and build the FlatBuffers assembly
in unsafe mode for greatly increased performance.

Tested: Tested FlatBuffersTest on Windows using VS2010 with both safe
and unsafe versions. Added ByteBufferTest to test the byte reversing
functions.

Change-Id: I21334468b339334f9abf4317e6291b648b97f57b
2015-01-06 12:39:17 -08:00
Wouter van Oortmerssen 517c964fe2 Support for required fields.
Change-Id: I560c7ca11b3d665eecafb528f3737b7e139ca9b0
Tested: on Linux and Windows.
2014-09-22 15:53:19 -07:00
Wouter van Oortmerssen 557c88c039 Refactored the Java and C# code generators into one.
Also made the C# implementation support unsigned types, and
made it more like the Java version.

Bug: 17359988
Change-Id: If5305c08cd5c97f35426639516ce05e53bbec36c
Tested: on Linux and Windows.
2014-09-18 12:29:31 -07:00
evolutional 9a1f7be6fd Initial commit of .NET port of FlatBuffers
Include C# codegen in flatc and .NET FlatBuffer access via the
FlatBufferBuilder class

Tested: on Windows.

Change-Id: If5228a8df60a10e0751b245c6c64530264ea2d8a
2014-09-15 16:13:27 -07:00