Commit Graph

77 Commits

Author SHA1 Message Date
Derek Bailey 8cccdfba53
Revert "[C#] Fix truncated ArraySegment<byte> if elementSize != 1 (#6462)" (#6488)
This reverts commit cbbbaa61b3.
2021-02-23 11:30:07 -08:00
Björn Harrtell cbbbaa61b3
[C#] Fix truncated ArraySegment<byte> if elementSize != 1 (#6462)
* WIP: Fix returned truncated ArraySegment<byte> if elementSize is not byte

* Fix

* Regenerated test code
2021-02-23 09:34:20 -08:00
Derek Bailey ea92a668d8
[C#] Optional Scalars (#6217)
* [C#] Optional Scalars

* Moved scalar optional check to avoid null enum conversion
2020-10-30 13:18:59 -07:00
mustiikhalil c7586e85aa
Empties the sharedString map on reset on go and csharp (#6187)
Fixes go tests
2020-10-26 12:38:24 -07:00
Conan Chen 0bdf2fa156
[C#] Fix and improve project files (#6142)
* [C#] Fix and improve project files

* "net35" target included for Unity 5
* "net46" target included for Unity 2017
* "netstandard2.0" target included for Unity 2018 and general use
* "netstandard2.1" target included for Span<T> support

Included project properties for defining UNSAFE_BYTEBUFFER, BYTEBUFFER_NO_BOUNDS_CHECK, and ENABLE_SPAN_T conditional compilation symbols.

* Add documentation on building for C#
2020-09-28 11:56:59 -07:00
春条 52e3628794
SpanT is available in .Net Standard 2.0. (#6137) 2020-09-25 10:39:28 -07:00
春条 e0bbaa6f9c
[C#]Change to ENABLE_SPAN_T that doesn't require UNSAFE_BYTEBUFFER. (#6073)
* ENABLE_SPAN_T doesn't require UNSAFE_BYTEBUFFER.

Change to ENABLE_SPAN_T that doesn't require UNSAFE_BYTEBUFFER.

* Selectable framework.

Changed target framework to allow selection of 2.0 or 2.1 (or higher)

* Added target framework version check.

* Add core test project.

* Added run on .Net Core.
2020-09-23 13:16:00 -07:00
Derek Bailey ab139d6bea
Revert "[C#] Fix and improve project files (#6116)" (#6130)
This reverts commit 750281630b.
2020-09-23 13:14:51 -07:00
Conan Chen 750281630b
[C#] Fix and improve project files (#6116)
* [C#] Fix and improve project files

* "net35" target included for Unity 5
* "net46" target included for Unity 2017
* "netstandard2.0" target included for Unity 2018 and general use
* "netstandard2.1" target included for Span<T> support

Included project properties for defining UNSAFE_BYTEBUFFER, BYTEBUFFER_NO_BOUNDS_CHECK, and ENABLE_SPAN_T conditional compiler constants.

* Add documentation on building for C#
2020-09-21 09:32:59 -07:00
mustiikhalil f1025b2847
[Feature] Checks for Nullable strings (#6050)
* Allows null strings in createString method c#

* Adds nullable strings to JS and swift

* Changes js checks

* Fixes typo
2020-07-27 09:57:50 -07:00
Derek Bailey 85ee4df7a2
[C#] Thread safe reads of Double and Float values from a ByteBuffer (#5900)
* Fixed refractoring issue in reflection/generate_code.sh. Also, mv deletes the original file, so I don't need to clean it up manually in that case.

* Thread safe reads of Double and Floats from ByteBuffer
2020-05-07 14:33:29 -07:00
Wouter van Oortmerssen 6df40a2471 pre-tag version bump for 1.12
Change-Id: I84a9365e9d8a1afe333b1df85058401ffe0a6b7c
2020-03-12 15:33:39 -07:00
Wouter van Oortmerssen 3a70e0b308 Fixed struct initialization error on older versions of C#
"'this' object cannot be used before all of its fields are assigned to"

Change-Id: Icccdcc0d0be0fe0b87abe0eb28fe1cc91116fcfb
2019-12-23 17:35:54 -08:00
Kulikov Alexey e365c502ff Java: Added access object for vector of struct and vector of tables. (#5233)
* Java: Added access object for vector of struct and vector of tables.

* Java: Workarounds removed when accessing the union vector.
2019-09-23 09:22:43 -07:00
Kevin Fort 2706381eef Add element size parameter to __vector_as_arraysegment [c#] (#5512)
* Add element size parameter to __vector_as_arraysegment

Add element size parameter to __vector_as_arraysegment fixing issue where VectorAsBytes returns incorrect size span for multibyte element types.

* Update codegen

Update codegen and Table to return typed span.

* update test files

update test files
2019-09-10 17:07:46 -07:00
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