Commit Graph

62 Commits

Author SHA1 Message Date
Vladimir Glavnyy b7012484f3 Set C# Struct/Table visibility to public (#5381) (#5416) 2019-06-24 17:51:04 -07:00
Bryan Furia 92e9f33036 Don't check ForceDefaults when adding Offfset values (#5415) 2019-06-24 17:49:53 -07:00
Vladimir Glavnyy 0d2cebccfe Add FLATBUFFERS_COMPATIBILITY string (#5381)
* Add FLATBUFFERS_COMPATIBILITY string

- Add a new __reset method NET/JAVA which hides internal state

* Resolve PR notes

* Use operator new() to __init of Struct and Table

* Restrict visibility of C# Table/Struct to internal level
2019-06-17 19:16:21 +02:00
Wouter van Oortmerssen b652fcc3a7 Break internal Java/C# APIs
This is done on purpose, to avoid API version mismatches that
can cause bad decoding results, see:
https://github.com/google/flatbuffers/issues/5368

Change-Id: I2c857438377e080caad0e2d8bcc758c9b19bd6ec
2019-05-31 13:00:55 -07:00
Wouter van Oortmerssen c978b9ef1f Enforce matching version in Java and C#.
Change-Id: I7f1f12f2f97e5227e0dabc2965ce66a6d41c229c
2019-05-31 12:15:19 -07:00
mugisoba 51dd733ba4 [C#] add FlatBuffersBuilder.CreateSharedString (#5372) 2019-05-30 16:15:50 -07:00
Eric Erhardt 0cdacdfb35 Remove byte* property in ByteBufferAllocator (#5191)
* Remove byte* property in ByteBufferAllocator.

This allows consumers to read/write into native memory, but without
having to always pin the managed `byte[]` when working with managed
memory. This allows for users to not need to Dispose() ByteBuffers
when they are using the default ByteArrayAllocator class.

Instead, we use `Span<byte> GetSpan()` methods to get access to the
underlying memory buffer.

Fix #5181

* Add a set of benchmark tests.

* Add ReadOnly spans.

This allows consumers to use ReadOnlyMemory<byte> as the backing storage
for ByteBuffers, which is useful in read-only scenarios.

* Run tests using ENABLE_SPAN_T in appveyor.

* Fix FlatBuffers.Test.csproj to work on older MSBuild versions.

* Change the test script to test UNSAFE_BYTEBUFFER

* Address PR feedback.

Remove IDisposable from ByteBuffer.

* Respond to PR feedback.
2019-02-21 23:36:55 +01:00
Efe Burak 69d761d15e Added .net core project (#5187) 2019-02-21 19:47:19 +01:00
Simon.S.King 80d148b175 [net] Fix issue #5036 when write a double value into bytebuffer at big endian machine with unsafe mode. (#5076) 2018-12-03 09:50:26 -08:00
Wouter van Oortmerssen 705577de51 Revert "Convert net/FlatBuffers project to be compatible with netstandard (#4811)"
This reverts commit 72b05bc865.

Change-Id: I17510b7fa49b9861ce0a870b16f5c14a41082db5
2018-10-29 17:21:30 -07:00
Christopher Cifra ed03faaf07 [C#] Fix compile issue when compiling with older versions of C# (#4938)
* C# support for directly reading and writting to memory other than byte[].  For example, ByteBuffer can be initialized with a custom allocator which uses shared memory / memory mapped files.

Public access to the backing buffer uses Span<T> instead of ArraySegment<T>.

Writing to the buffer now supports Span<T> in addition to T[].

To maintain backwards compatibility ENABLE_SPAN_T must be defined.

* Remove usage of expression bodied method so that ByteBuffer can be compiled with older version of C#.
2018-09-20 15:07:03 -07:00
Christopher Cifra d0321df8cf C# support for directly reading and writting to memory other than byte[]. For example, ByteBuffer can be initialized with a custom allocator which uses shared memory / memory mapped files. (#4886)
Public access to the backing buffer uses Span<T> instead of ArraySegment<T>.

Writing to the buffer now supports Span<T> in addition to T[].

To maintain backwards compatibility ENABLE_SPAN_T must be defined.
2018-08-23 10:05:31 -07:00
Derek Bailey d8f49e18d7 Mono Fix for Unsafe Mode (#4887)
* Added preprocessor define for C++ if Template Aliases are supported by the compiler

* Revert "Revert "Performance Increase of Vector of Structures using .NET BlockCopy (#4830)""

This reverts commit 1f5eae5d6a.

* Put<T> method was inside #if UNSAFE_BYTEBUFFER which caused compilation failure when building in unsafe mode

* Revert "Added preprocessor define for C++ if Template Aliases are supported by the compiler"

This reverts commit a75af73521.
2018-08-20 16:31:44 -07:00
Wouter van Oortmerssen 1f5eae5d6a Revert "Performance Increase of Vector of Structures using .NET BlockCopy (#4830)"
This reverts commit 7b50004ec9.

Change-Id: I09d6869c16aa3c7fadc537fc9c76eaa3cf7ee7ea
2018-08-20 12:08:21 -07:00
Derek Bailey 7b50004ec9 Performance Increase of Vector of Structures using .NET BlockCopy (#4830)
* Added Get<vector_name>Array() method for accessing vectors of structures in C# using Buffer.Blockcopy().

* Added Get<vector_name>Array() method for accessing vectors of structures in C# using Buffer.Blockcopy().

Added Create<Name>VectorBlock() method to add a typed array using Buffer.BlockCopy() to speed up creation of vector of arrays

New Lua files for namespace test

* fixed c++ style issue
2018-07-26 13:44:40 -07:00
Damien Pontifex 72b05bc865 Convert net/FlatBuffers project to be compatible with netstandard (#4811) 2018-07-16 09:13:36 -07:00
iceboy cc354ea368 Delete ByteBuffer.exe (#4721) 2018-05-03 11:58:29 -07:00
Robert Schmidtke 08cf50c54a Java/C#/Python prefixed size support (#4445)
* initial changes to support size prefixed buffers in Java

* add slice equivalent to CSharp ByteBuffer

* resolve TODO for slicing in CSharp code generation

* add newly generated Java and CSharp test sources

* fix typo in comment

* add FinishSizePrefixed methods to CSharp FlatBufferBuilder as well

* add option to allow writing the prefix as well

* generate size-prefixed monster binary as well

* extend JavaTest to test the size prefixed binary as well

* use constants for size prefix length

* fuse common code for getRootAs and getSizePrefixedRootAs

* pulled file identifier out of if

* add FinishSizePrefixed, GetSizePrefixedRootAs support for Python

* Revert "extend JavaTest to test the size prefixed binary as well"

This reverts commit 68be4420dd.

* Revert "generate size-prefixed monster binary as well"

This reverts commit 2939516fdf.

* fix ByteBuffer.cs Slice() method; add proper CSharp and Java tests

* fix unused parameter

* increment version number

* pulled out generated methods into separate utility class

* pulled out generated methods into separate utility class for Python

* fix indentation

* remove unnecessary comment

* fix newline and copyright

* add ByteBufferUtil to csproj compilation

* hide ByteBuffer's internal data; track offset into parent's array

* test unsafe versions as well; compile and run in debug mode

* clarify help text for size prefix

* move ByteBuffer slicing behavior to subclass

* fix protection levels

* add size prefix support for text generation

* add ByteBufferSlice to csproj compilation

* revert size prefix handling for nested buffers

* use duplicate instead of slice for removing size prefix

* remove slice subclass and use duplicate for removing size prefix

* remove slice specific tests

* remove superfluous command line option
2018-03-12 11:30:46 -07:00
Sergey Avseyev 6eb031de9a Text files should not have executable bit set (#4480) 2017-11-06 10:20:22 -08:00
Wouter van Oortmerssen ac1015e3c4 Trimmed vtables of trailing zeroes.
This is something the format supports, but none of the builders
were doing. Can save 10-20% on FlatBuffer binary size!

Also fixed the Go tests.

Change-Id: I616c56ce9bbcfcaee23aa24f0532fcb60b6a8c75
Tested: on Linux.
2017-08-24 09:35:54 -07:00
FTT\kimsin 4a43c2bb2c Added IFlatbufferObject.cs file to project for .net.
Before edition, IFlatbufferObject.cs file wasn't in the project and building the project throwed error.
2016-09-19 16:16:15 +09:00
Alberto Fernández 02dfa64a89 Allow access to underlying ByteBuffer 2016-09-12 09:35:08 +02:00
Wouter van Oortmerssen 52ca75506a Switched C# accessors from classes to structs 2016-08-31 17:34:51 -07:00
Wouter van Oortmerssen 49ee30a207 Merge pull request #3978 from TGIshib/key
Find by key on C# and Java (2)
2016-08-26 12:03:28 -07:00
TGIshib 7c69c5dc3d Fix lookupByKey, improve compareStrings 2016-08-26 19:41:32 +03:00
Wouter van Oortmerssen 79d127c863 Merge pull request #2133 from evolutional/cs-bounds-check
C#: added #define BYTEBUFFER_NO_BOUNDS_CHECK
2016-08-24 09:26:06 -07:00
TGIshib 9f16090f90 Improve `LookupByKey` , update docs 2016-08-22 18:10:52 +03:00
TGIshib 8fdced4e11 Update 2016-08-14 14:58:51 +03:00
TGIshib 9031597f49 Merge remote-tracking branch 'refs/remotes/google/master' into key 2016-08-13 16:28:38 +03:00
Wouter van Oortmerssen 18d67ed83b Clarified in the docs how to get to the serialized bytes.
This was a frequent source of confusion, since in all implementations
the data doesn't start at offset 0 in the buffer.

Change-Id: I045966e65928e9acd9def84e215914ecb5510653
2016-08-10 17:53:40 -07:00
TGIshib dc7f5bc0d8 Remake 2016-08-03 13:29:50 +03:00
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
Oli Wilkinson 4802e8a285 C# added BYTEBUFFER_NO_BOUNDS_CHECK #define
Removes the bounds checking on the ByteBuffer Get/Put operations. Can be dangerous when used with UNSAFE_BYTEBUFFER but results in increased performance. Use at your own risk!
2015-12-14 21:06:29 -05: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