From c512530eda81b506a2bdfae937e413bd9d68bf0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Tue, 19 Dec 2023 23:43:55 +0100 Subject: [PATCH] Target .NET Standard 2.1, .NET 6, .NET 8 only (#8184) * Target .NET Standard 2.1, .NET 6, .NET 8 only * Remove mono usage * Fix bat name ref * Up deps * Up deps * Reinstate build-windows * Fix name --------- Co-authored-by: Derek Bailey --- .github/workflows/build.yml | 40 +--- .github/workflows/release.yml | 3 +- docs/source/CsharpUsage.md | 23 +- net/FlatBuffers/ByteBuffer.cs | 52 ++--- net/FlatBuffers/FlatBufferBuilder.cs | 30 +-- net/FlatBuffers/FlatBuffers.net35.csproj | 57 ----- net/FlatBuffers/Google.FlatBuffers.csproj | 8 +- net/FlatBuffers/Table.cs | 2 +- .../FlatBuffers.Core.Test.csproj | 203 ------------------ .../FlatBuffers.Test/FlatBuffers.Test.csproj | 100 ++++----- tests/FlatBuffers.Test/NetTest.bat | 4 +- tests/FlatBuffers.Test/NetTest.sh | 26 +-- tests/FlatBuffers.Test/monsterdata_cstest.mon | Bin 0 -> 304 bytes .../monsterdata_cstest_sp.mon | Bin 0 -> 304 bytes tests/FlatBuffers.Test/packages.config | 4 +- 15 files changed, 106 insertions(+), 446 deletions(-) delete mode 100644 net/FlatBuffers/FlatBuffers.net35.csproj delete mode 100644 tests/FlatBuffers.Test/FlatBuffers.Core.Test.csproj create mode 100644 tests/FlatBuffers.Test/monsterdata_cstest.mon create mode 100644 tests/FlatBuffers.Test/monsterdata_cstest_sp.mon diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c1cfda746c9..ed5c7eb586e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -106,7 +106,7 @@ jobs: exclude: # Clang++15 10.3.0 stdlibc++ doesn't fully support std 23 - cxx: clang++-15 - std: 23 + std: 23 steps: - uses: actions/checkout@v3 @@ -186,34 +186,6 @@ jobs: shell: bash run: echo "hashes=$(sha256sum Windows.flatc.binary.zip | base64 -w0)" >> $GITHUB_OUTPUT - build-windows-2017: - name: Build Windows 2017 - runs-on: windows-2019 - steps: - - uses: actions/checkout@v3 - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1.1 - - name: cmake - run: cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON . - - name: build tool version 15 (VS 2017) - run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64 /p:VisualStudioVersion=15.0 - - name: test - run: Release\flattests.exe - - build-windows-2015: - name: Build Windows 2015 - runs-on: windows-2019 - steps: - - uses: actions/checkout@v3 - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1.1 - - name: cmake - run: cmake -G "Visual Studio 14 2015" -A x64 -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON . - - name: build tool version 14 (VS 2015) - run: msbuild.exe FlatBuffers.sln /p:Configuration=Release /p:Platform=x64 /p:VisualStudioVersion=14.0 - - name: test - run: Release\flattests.exe - build-dotnet-windows: name: Build .NET Windows runs-on: windows-2022-64core @@ -230,17 +202,17 @@ jobs: - name: Setup .NET Core SDK uses: actions/setup-dotnet@v3 with: - dotnet-version: '3.1.x' + dotnet-version: '8.0.x' - name: Build run: | cd tests\FlatBuffers.Test - dotnet new sln --force --name FlatBuffers.Core.Test - dotnet sln FlatBuffers.Core.Test.sln add FlatBuffers.Core.Test.csproj - dotnet build -c Release ${{matrix.configuration}} -o out FlatBuffers.Core.Test.sln + dotnet new sln --force --name FlatBuffers.Test + dotnet sln FlatBuffers.Test.sln add FlatBuffers.Test.csproj + dotnet build -c Release ${{matrix.configuration}} -o out FlatBuffers.Test.sln - name: Run run: | cd tests\FlatBuffers.Test - out\FlatBuffers.Core.Test.exe + out\FlatBuffers.Test.exe build-mac-intel: permissions: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f0f9cd71d80..1554d824f7e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -60,8 +60,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-dotnet@v3 with: - dotnet-version: '6.0.x' - + dotnet-version: '8.0.x' - name: Build run: | dotnet build Google.FlatBuffers.csproj -c Release diff --git a/docs/source/CsharpUsage.md b/docs/source/CsharpUsage.md index b0acc77d868..84fa697a281 100644 --- a/docs/source/CsharpUsage.md +++ b/docs/source/CsharpUsage.md @@ -24,17 +24,14 @@ FlatBuffers). ## Building the FlatBuffers C# library The `FlatBuffers.csproj` project contains multitargeting for .NET Standard 2.1, -.NET Standard 2.0, and .NET Framework 4.6 (Unity 2017). Support for .NET -Framework 3.5 (Unity 5) is provided by the `FlatBuffers.net35.csproj` project. -In most cases (including Unity 2018 and newer), .NET Standard 2.0 is -recommended. +.NET 6 and .NET 8. You can build for a specific framework target when using the cross-platform [.NET Core SDK](https://dotnet.microsoft.com/download) by adding the `-f` command line option: ~~~{.sh} - dotnet build -f netstandard2.0 "FlatBuffers.csproj" + dotnet build -f netstandard2.1 "FlatBuffers.csproj" ~~~ The `FlatBuffers.csproj` project also provides support for defining various @@ -142,10 +139,10 @@ To use it: `ByKey` only works if the vector has been sorted, it will likely not find elements if it hasn't been sorted. -## Buffer verification +## Buffer verification As mentioned in [C++ Usage](@ref flatbuffers_guide_use_cpp) buffer -accessor functions do not verify buffer offsets at run-time. +accessor functions do not verify buffer offsets at run-time. If it is necessary, you can optionally use a buffer verifier before you access the data. This verifier will check all offsets, all sizes of fields, and null termination of strings to ensure that when a buffer @@ -158,17 +155,17 @@ e.g. `Monster.VerifyMonster`. This can be called as shown: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if `ok` is true, the buffer is safe to read. -For a more detailed control of verification `MonsterVerify.Verify` -for `Monster` type can be used: +For a more detailed control of verification `MonsterVerify.Verify` +for `Monster` type can be used: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cs} # Sequence of calls FlatBuffers.Verifier verifier = new FlatBuffers.Verifier(buf); var ok = verifier.VerifyBuffer("MONS", false, MonsterVerify.Verify); - - # Or single line call + + # Or single line call var ok = new FlatBuffers.Verifier(bb).setStringCheck(true).\ VerifyBuffer("MONS", false, MonsterVerify.Verify); - + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if `ok` is true, the buffer is safe to read. @@ -181,7 +178,7 @@ Verifier supports options that can be set using appropriate fluent methods: * SetMaxTables - total amount of tables the verifier may encounter. Default: 64 * SetAlignmentCheck - check content alignment. Default: True * SetStringCheck - check if strings contain termination '0' character. Default: true - + ## Text parsing diff --git a/net/FlatBuffers/ByteBuffer.cs b/net/FlatBuffers/ByteBuffer.cs index 4c0d000a07f..98772ee889a 100644 --- a/net/FlatBuffers/ByteBuffer.cs +++ b/net/FlatBuffers/ByteBuffer.cs @@ -43,11 +43,11 @@ using System.Runtime.InteropServices; using System.Text; -#if ENABLE_SPAN_T && (UNSAFE_BYTEBUFFER || NETSTANDARD2_1) +#if ENABLE_SPAN_T && UNSAFE_BYTEBUFFER using System.Buffers.Binary; #endif -#if ENABLE_SPAN_T && !UNSAFE_BYTEBUFFER && !NETSTANDARD2_1 +#if ENABLE_SPAN_T && !UNSAFE_BYTEBUFFER #warning ENABLE_SPAN_T requires UNSAFE_BYTEBUFFER to also be defined #endif @@ -55,7 +55,7 @@ namespace Google.FlatBuffers { public abstract class ByteBufferAllocator { -#if ENABLE_SPAN_T && (UNSAFE_BYTEBUFFER || NETSTANDARD2_1) +#if ENABLE_SPAN_T && UNSAFE_BYTEBUFFER public abstract Span Span { get; } public abstract ReadOnlySpan ReadOnlySpan { get; } public abstract Memory Memory { get; } @@ -103,7 +103,7 @@ public override void GrowFront(int newSize) InitBuffer(); } -#if ENABLE_SPAN_T && (UNSAFE_BYTEBUFFER || NETSTANDARD2_1) +#if ENABLE_SPAN_T && UNSAFE_BYTEBUFFER public override Span Span => _buffer; public override ReadOnlySpan ReadOnlySpan => _buffer; public override Memory Memory => _buffer; @@ -237,7 +237,7 @@ public static int ArraySize(ArraySegment x) return SizeOf() * x.Count; } -#if ENABLE_SPAN_T && (UNSAFE_BYTEBUFFER || NETSTANDARD2_1) +#if ENABLE_SPAN_T && UNSAFE_BYTEBUFFER public static int ArraySize(Span x) { return SizeOf() * x.Length; @@ -246,7 +246,7 @@ public static int ArraySize(Span x) // Get a portion of the buffer casted into an array of type T, given // the buffer position and length. -#if ENABLE_SPAN_T && (UNSAFE_BYTEBUFFER || NETSTANDARD2_1) +#if ENABLE_SPAN_T && UNSAFE_BYTEBUFFER public T[] ToArray(int pos, int len) where T : struct { @@ -274,7 +274,7 @@ public byte[] ToFullArray() return ToArray(0, Length); } -#if ENABLE_SPAN_T && (UNSAFE_BYTEBUFFER || NETSTANDARD2_1) +#if ENABLE_SPAN_T && UNSAFE_BYTEBUFFER public ReadOnlyMemory ToReadOnlyMemory(int pos, int len) { return _buffer.ReadOnlyMemory.Slice(pos, len); @@ -337,7 +337,7 @@ static public ulong ReverseBytes(ulong input) ((input & 0xFF00000000000000UL) >> 56)); } -#if !UNSAFE_BYTEBUFFER && (!ENABLE_SPAN_T || !NETSTANDARD2_1) +#if !UNSAFE_BYTEBUFFER && !ENABLE_SPAN_T // Helper functions for the safe (but slower) version. protected void WriteLittleEndian(int offset, int count, ulong data) { @@ -377,7 +377,7 @@ protected ulong ReadLittleEndian(int offset, int count) } return r; } -#elif ENABLE_SPAN_T && NETSTANDARD2_1 +#elif ENABLE_SPAN_T protected void WriteLittleEndian(int offset, int count, ulong data) { if (BitConverter.IsLittleEndian) @@ -427,7 +427,7 @@ private void AssertOffsetAndLength(int offset, int length) #endif } -#if ENABLE_SPAN_T && (UNSAFE_BYTEBUFFER || NETSTANDARD2_1) +#if ENABLE_SPAN_T && UNSAFE_BYTEBUFFER public void PutSbyte(int offset, sbyte value) { @@ -487,7 +487,7 @@ public unsafe void PutStringUTF8(int offset, string value) } } } -#elif ENABLE_SPAN_T && NETSTANDARD2_1 +#elif ENABLE_SPAN_T public void PutStringUTF8(int offset, string value) { AssertOffsetAndLength(offset, value.Length); @@ -652,7 +652,7 @@ public void PutFloat(int offset, float value) // that contains it. ConversionUnion union; union.intValue = 0; - union.floatValue = value; + union.floatValue = value; WriteLittleEndian(offset, sizeof(float), (ulong)union.intValue); } @@ -664,7 +664,7 @@ public void PutDouble(int offset, double value) #endif // UNSAFE_BYTEBUFFER -#if ENABLE_SPAN_T && (UNSAFE_BYTEBUFFER || NETSTANDARD2_1) +#if ENABLE_SPAN_T && UNSAFE_BYTEBUFFER public sbyte GetSbyte(int index) { AssertOffsetAndLength(index, sizeof(sbyte)); @@ -698,7 +698,7 @@ public unsafe string GetStringUTF8(int startPos, int len) return Encoding.UTF8.GetString(buffer, len); } } -#elif ENABLE_SPAN_T && NETSTANDARD2_1 +#elif ENABLE_SPAN_T public string GetStringUTF8(int startPos, int len) { return Encoding.UTF8.GetString(_buffer.Span.Slice(startPos, len)); @@ -765,7 +765,7 @@ public unsafe ulong GetUlong(int offset) #if ENABLE_SPAN_T // && UNSAFE_BYTEBUFFER ReadOnlySpan span = _buffer.ReadOnlySpan.Slice(offset); return BinaryPrimitives.ReadUInt64LittleEndian(span); -#else +#else fixed (byte* ptr = _buffer.Buffer) { return BitConverter.IsLittleEndian @@ -885,16 +885,16 @@ public int Put(int offset, T[] x) } /// - /// Copies an array segment of type T into this buffer, ending at the - /// given offset into this buffer. The starting offset is calculated + /// Copies an array segment of type T into this buffer, ending at the + /// given offset into this buffer. The starting offset is calculated /// based on the count of the array segment and is the value returned. /// /// The type of the input data (must be a struct) /// - /// The offset into this buffer where the copy + /// The offset into this buffer where the copy /// will end /// The array segment to copy data from - /// The 'start' location of this buffer now, after the copy + /// The 'start' location of this buffer now, after the copy /// completed public int Put(int offset, ArraySegment x) where T : struct @@ -921,7 +921,7 @@ public int Put(int offset, ArraySegment x) offset -= numBytes; AssertOffsetAndLength(offset, numBytes); // if we are LE, just do a block copy -#if ENABLE_SPAN_T && (UNSAFE_BYTEBUFFER || NETSTANDARD2_1) +#if ENABLE_SPAN_T && UNSAFE_BYTEBUFFER MemoryMarshal.Cast(x).CopyTo(_buffer.Span.Slice(offset, numBytes)); #else var srcOffset = ByteBuffer.SizeOf() * x.Offset; @@ -942,17 +942,17 @@ public int Put(int offset, ArraySegment x) } /// - /// Copies an array segment of type T into this buffer, ending at the - /// given offset into this buffer. The starting offset is calculated + /// Copies an array segment of type T into this buffer, ending at the + /// given offset into this buffer. The starting offset is calculated /// based on the count of the array segment and is the value returned. /// /// The type of the input data (must be a struct) /// - /// The offset into this buffer where the copy + /// The offset into this buffer where the copy /// will end /// The pointer to copy data from /// The number of bytes to copy - /// The 'start' location of this buffer now, after the copy + /// The 'start' location of this buffer now, after the copy /// completed public int Put(int offset, IntPtr ptr, int sizeInBytes) where T : struct @@ -980,7 +980,7 @@ public int Put(int offset, IntPtr ptr, int sizeInBytes) // if we are LE, just do a block copy #if ENABLE_SPAN_T && UNSAFE_BYTEBUFFER unsafe - { + { var span = new Span(ptr.ToPointer(), sizeInBytes); span.CopyTo(_buffer.Span.Slice(offset, sizeInBytes)); } @@ -1001,7 +1001,7 @@ public int Put(int offset, IntPtr ptr, int sizeInBytes) return offset; } -#if ENABLE_SPAN_T && (UNSAFE_BYTEBUFFER || NETSTANDARD2_1) +#if ENABLE_SPAN_T && UNSAFE_BYTEBUFFER public int Put(int offset, Span x) where T : struct { diff --git a/net/FlatBuffers/FlatBufferBuilder.cs b/net/FlatBuffers/FlatBufferBuilder.cs index 4df4f8c6737..afe16835236 100644 --- a/net/FlatBuffers/FlatBufferBuilder.cs +++ b/net/FlatBuffers/FlatBufferBuilder.cs @@ -235,7 +235,7 @@ public void Put(IntPtr ptr, int sizeInBytes) _space = _bb.Put(_space, ptr, sizeInBytes); } -#if ENABLE_SPAN_T && (UNSAFE_BYTEBUFFER || NETSTANDARD2_1) +#if ENABLE_SPAN_T && UNSAFE_BYTEBUFFER /// /// Puts a span of type T into this builder at the /// current offset @@ -399,7 +399,7 @@ public void Add(IntPtr ptr, int sizeInBytes) Put(ptr, sizeInBytes); } -#if ENABLE_SPAN_T && (UNSAFE_BYTEBUFFER || NETSTANDARD2_1) +#if ENABLE_SPAN_T && UNSAFE_BYTEBUFFER /// /// Add a span of type T to the buffer (aligns the data and grows if necessary). /// @@ -533,10 +533,10 @@ public void Slot(int voffset) /// /// The index into the vtable /// The nullable boolean value to put into the buffer. If it doesn't have a value - /// it will skip writing to the buffer. + /// it will skip writing to the buffer. public void AddBool(int o, bool? x) { if (x.HasValue) { AddBool(x.Value); Slot(o); } } - + /// /// Adds a SByte to the Table at index `o` in its vtable using the value `x` and default `d` /// @@ -551,7 +551,7 @@ public void Slot(int voffset) /// /// The index into the vtable /// The nullable sbyte value to put into the buffer. If it doesn't have a value - /// it will skip writing to the buffer. + /// it will skip writing to the buffer. public void AddSbyte(int o, sbyte? x) { if (x.HasValue) { AddSbyte(x.Value); Slot(o); } } /// @@ -568,7 +568,7 @@ public void Slot(int voffset) /// /// The index into the vtable /// The nullable byte value to put into the buffer. If it doesn't have a value - /// it will skip writing to the buffer. + /// it will skip writing to the buffer. public void AddByte(int o, byte? x) { if (x.HasValue) { AddByte(x.Value); Slot(o); } } /// @@ -585,7 +585,7 @@ public void Slot(int voffset) /// /// The index into the vtable /// The nullable int16 value to put into the buffer. If it doesn't have a value - /// it will skip writing to the buffer. + /// it will skip writing to the buffer. public void AddShort(int o, short? x) { if (x.HasValue) { AddShort(x.Value); Slot(o); } } /// @@ -602,7 +602,7 @@ public void Slot(int voffset) /// /// The index into the vtable /// The nullable uint16 value to put into the buffer. If it doesn't have a value - /// it will skip writing to the buffer. + /// it will skip writing to the buffer. public void AddUshort(int o, ushort? x) { if (x.HasValue) { AddUshort(x.Value); Slot(o); } } /// @@ -619,7 +619,7 @@ public void Slot(int voffset) /// /// The index into the vtable /// The nullable int32 value to put into the buffer. If it doesn't have a value - /// it will skip writing to the buffer. + /// it will skip writing to the buffer. public void AddInt(int o, int? x) { if (x.HasValue) { AddInt(x.Value); Slot(o); } } /// @@ -636,7 +636,7 @@ public void Slot(int voffset) /// /// The index into the vtable /// The nullable uint32 value to put into the buffer. If it doesn't have a value - /// it will skip writing to the buffer. + /// it will skip writing to the buffer. public void AddUint(int o, uint? x) { if (x.HasValue) { AddUint(x.Value); Slot(o); } } /// @@ -653,7 +653,7 @@ public void Slot(int voffset) /// /// The index into the vtable /// The nullable int64 value to put into the buffer. If it doesn't have a value - /// it will skip writing to the buffer. + /// it will skip writing to the buffer. public void AddLong(int o, long? x) { if (x.HasValue) { AddLong(x.Value); Slot(o); } } /// @@ -670,7 +670,7 @@ public void Slot(int voffset) /// /// The index into the vtable /// The nullable int64 value to put into the buffer. If it doesn't have a value - /// it will skip writing to the buffer. + /// it will skip writing to the buffer. public void AddUlong(int o, ulong? x) { if (x.HasValue) { AddUlong(x.Value); Slot(o); } } /// @@ -687,7 +687,7 @@ public void Slot(int voffset) /// /// The index into the vtable /// The nullable single value to put into the buffer. If it doesn't have a value - /// it will skip writing to the buffer. + /// it will skip writing to the buffer. public void AddFloat(int o, float? x) { if (x.HasValue) { AddFloat(x.Value); Slot(o); } } /// @@ -704,7 +704,7 @@ public void Slot(int voffset) /// /// The index into the vtable /// The nullable double value to put into the buffer. If it doesn't have a value - /// it will skip writing to the buffer. + /// it will skip writing to the buffer. public void AddDouble(int o, double? x) { if (x.HasValue) { AddDouble(x.Value); Slot(o); } } /// @@ -739,7 +739,7 @@ public StringOffset CreateString(string s) } -#if ENABLE_SPAN_T && (UNSAFE_BYTEBUFFER || NETSTANDARD2_1) +#if ENABLE_SPAN_T && UNSAFE_BYTEBUFFER /// /// Creates a string in the buffer from a Span containing /// a UTF8 string. diff --git a/net/FlatBuffers/FlatBuffers.net35.csproj b/net/FlatBuffers/FlatBuffers.net35.csproj deleted file mode 100644 index 9c64d006e3e..00000000000 --- a/net/FlatBuffers/FlatBuffers.net35.csproj +++ /dev/null @@ -1,57 +0,0 @@ - - - - - Debug - AnyCPU - {28C00774-1E73-4A75-AD8F-844CD21A064D} - Library - Properties - FlatBuffers - FlatBuffers - v3.5 - 512 - - - true - full - false - bin\Debug\net35 - obj\Debug\net35 - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\net35 - obj\Release\net35 - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/net/FlatBuffers/Google.FlatBuffers.csproj b/net/FlatBuffers/Google.FlatBuffers.csproj index 7d4fab0f8ca..1978cc11db0 100644 --- a/net/FlatBuffers/Google.FlatBuffers.csproj +++ b/net/FlatBuffers/Google.FlatBuffers.csproj @@ -1,7 +1,7 @@  - netstandard2.1;netstandard2.0;net46 + netstandard2.1;net6.0;net8.0 A cross-platform memory efficient serialization library 23.5.26 Google LLC @@ -30,12 +30,8 @@ $(DefineConstants);ENABLE_SPAN_T - - - - - + diff --git a/net/FlatBuffers/Table.cs b/net/FlatBuffers/Table.cs index 2aaa86e99b3..f3860bfea09 100644 --- a/net/FlatBuffers/Table.cs +++ b/net/FlatBuffers/Table.cs @@ -90,7 +90,7 @@ public int __vector(int offset) return offset + bb.GetInt(offset) + sizeof(int); // data starts after the length } -#if ENABLE_SPAN_T && (UNSAFE_BYTEBUFFER || NETSTANDARD2_1) +#if ENABLE_SPAN_T && UNSAFE_BYTEBUFFER // Get the data of a vector whoses offset is stored at "offset" in this object as an // Spant<byte>. If the vector is not present in the ByteBuffer, // then an empty span will be returned. diff --git a/tests/FlatBuffers.Test/FlatBuffers.Core.Test.csproj b/tests/FlatBuffers.Test/FlatBuffers.Core.Test.csproj deleted file mode 100644 index 75f70fef35b..00000000000 --- a/tests/FlatBuffers.Test/FlatBuffers.Core.Test.csproj +++ /dev/null @@ -1,203 +0,0 @@ - - - - Exe - netcoreapp3.1 - - - - - - - - true - $(DefineConstants);UNSAFE_BYTEBUFFER - - - - true - $(DefineConstants);ENABLE_SPAN_T - - - - true - - - - true - - - - - FlatBuffers\ByteBuffer.cs - - - FlatBuffers\ByteBufferUtil.cs - - - FlatBuffers\IFlatbufferObject.cs - - - FlatBuffers\Offset.cs - - - FlatBuffers\FlatBufferBuilder.cs - - - FlatBuffers\FlatBufferConstants.cs - - - FlatBuffers\FlatBufferVerify.cs - - - FlatBuffers\Struct.cs - - - FlatBuffers\Table.cs - - - MyGame\Example2\Monster.cs - - - MyGame\Example\Any.cs - - - MyGame\Example\AnyAmbiguousAliases.cs - - - MyGame\Example\AnyUniqueAliases.cs - - - MyGame\Example\Color.cs - - - MyGame\Example\Race.cs - - - MyGame\Example\Monster.cs - - - MyGame\Example\Referrable.cs - - - MyGame\Example\Stat.cs - - - MyGame\Example\Test.cs - - - MyGame\Example\TestSimpleTableWithEnum.cs - - - MyGame\Example\TypeAliases.cs - - - MyGame\Example\Vec3.cs - - - MyGame\Example\Ability.cs - - - MyGame\Example\ArrayTable.cs - - - MyGame\Example\ArrayStruct.cs - - - MyGame\Example\NestedStruct.cs - - - MyGame\Example\LongEnum.cs - - - MyGame\Example\TestEnum.cs - - - MyGame\InParentNamespace.cs - - - NamespaceA\NamespaceB\EnumInNestedNS.cs - - - NamespaceA\NamespaceB\StructInNestedNS.cs - - - NamespaceA\NamespaceB\TableInNestedNS.cs - - - NamespaceA\NamespaceB\UnionInNestedNS.cs - - - NamespaceA\TableInFirstNS.cs - - - union_vector\Attacker.cs - - - union_vector\BookReader.cs - - - union_vector\Character.cs - - - union_vector\Movie.cs - - - union_vector\Rapunzel.cs - - - optional_scalars\OptionalByte.cs - - - optional_scalars\ScalarStuff.cs - - - KeywordTest\ABC.cs - - - KeywordTest\public.cs - - - KeywordTest\KeywordsInTable.cs - - - KeywordTest\KeywordsInUnion.cs - - - nested_namespace_test\nested_namespace_test1_generated.cs - - - nested_namespace_test\nested_namespace_test2_generated.cs - - - nested_namespace_test\nested_namespace_test3_generated.cs - - - union_value_collsion\union_value_collision_generated.cs - - - - - - - - - - - - - - Resources\monsterdata_test.mon - PreserveNewest - - - Resources\monsterdata_test.json - PreserveNewest - - - - - - - - diff --git a/tests/FlatBuffers.Test/FlatBuffers.Test.csproj b/tests/FlatBuffers.Test/FlatBuffers.Test.csproj index de129e14da1..1bacb166b75 100644 --- a/tests/FlatBuffers.Test/FlatBuffers.Test.csproj +++ b/tests/FlatBuffers.Test/FlatBuffers.Test.csproj @@ -1,52 +1,32 @@ - - + + - Debug - AnyCPU - {9DB0B5E7-757E-4BD1-A5F6-279390331254} Exe - Properties - FlatBuffers.Test - FlatBuffers.Test - v3.5 - win - 4 - 512 + net6.0;net8.0 - - true - full - false - bin\Debug\ - TRACE;DEBUG - prompt - 4 + + + + + + true + $(DefineConstants);UNSAFE_BYTEBUFFER - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + + true + $(DefineConstants);ENABLE_SPAN_T - - + + + true - + + true - $(DefineConstants);UNSAFE_BYTEBUFFER - - - - - - - - + FlatBuffers\ByteBuffer.cs @@ -123,12 +103,12 @@ MyGame\Example\ArrayStruct.cs - - MyGame\Example\LongEnum.cs - MyGame\Example\NestedStruct.cs + + MyGame\Example\LongEnum.cs + MyGame\Example\TestEnum.cs @@ -192,19 +172,19 @@ nested_namespace_test\nested_namespace_test3_generated.cs - - - - - - - - - - - - + + union_value_collsion\union_value_collision_generated.cs + + + + + + + + + + Resources\monsterdata_test.mon @@ -215,15 +195,9 @@ PreserveNewest + - + - - + diff --git a/tests/FlatBuffers.Test/NetTest.bat b/tests/FlatBuffers.Test/NetTest.bat index 3b88b53ec5a..a7097a509e1 100644 --- a/tests/FlatBuffers.Test/NetTest.bat +++ b/tests/FlatBuffers.Test/NetTest.bat @@ -4,8 +4,8 @@ set TEMP_BIN=.tmp -@REM Run the .NET Core tests -set CORE_FILE=FlatBuffers.Core.Test +@REM Run the .NET tests +set CORE_FILE=FlatBuffers.Test set CORE_PROJ_FILE=%CORE_FILE%.csproj set CORE_SLN_FILE=%CORE_FILE%.sln dotnet new sln --force --name %CORE_FILE% diff --git a/tests/FlatBuffers.Test/NetTest.sh b/tests/FlatBuffers.Test/NetTest.sh index 0c90767509f..f2f678674d5 100755 --- a/tests/FlatBuffers.Test/NetTest.sh +++ b/tests/FlatBuffers.Test/NetTest.sh @@ -1,7 +1,6 @@ #!/bin/sh PROJ_FILE=FlatBuffers.Test.csproj -CORE_PROJ_FILE=FlatBuffers.Core.Test.csproj TEMP_DOTNET_DIR=.dotnet_tmp TEMP_BIN=.tmp @@ -18,37 +17,20 @@ $DOTNET new sln $DOTNET sln add $PROJ_FILE $DOTNET restore -r linux-x64 $PROJ_FILE -# Testing C# on Linux using Mono. +# Testing with default options. msbuild -property:Configuration=Release,OutputPath=$TEMP_BIN -verbosity:quiet $PROJ_FILE -mono $TEMP_BIN/FlatBuffers.Test.exe -rm -fr $TEMP_BIN - -# Repeat with unsafe versions -msbuild -property:Configuration=Release,UnsafeByteBuffer=true,OutputPath=$TEMP_BIN -verbosity:quiet $PROJ_FILE -mono $TEMP_BIN/FlatBuffers.Test.exe -rm -fr $TEMP_BIN - -rm FlatBuffers.Test.sln -rm -rf obj - -$DOTNET new sln -$DOTNET sln add $CORE_PROJ_FILE -$DOTNET restore -r linux-x64 $CORE_PROJ_FILE - -# Testing C# on Linux using .Net Core. -msbuild -property:Configuration=Release,OutputPath=$TEMP_BIN -verbosity:quiet $CORE_PROJ_FILE $TEMP_BIN/FlatBuffers.Core.Test.exe rm -fr $TEMP_BIN # Repeat with unsafe versions -msbuild -property:Configuration=Release,UnsafeByteBuffer=true,OutputPath=$TEMP_BIN -verbosity:quiet $CORE_PROJ_FILE +msbuild -property:Configuration=Release,UnsafeByteBuffer=true,OutputPath=$TEMP_BIN -verbosity:quiet $PROJ_FILE $TEMP_BIN/FlatBuffers.Core.Test.exe rm -fr $TEMP_BIN # Repeat with SpanT versions -msbuild -property:Configuration=Release,EnableSpanT=true,OutputPath=$TEMP_BIN -verbosity:quiet $CORE_PROJ_FILE +msbuild -property:Configuration=Release,EnableSpanT=true,OutputPath=$TEMP_BIN -verbosity:quiet $PROJ_FILE $TEMP_BIN/FlatBuffers.Core.Test.exe rm -fr $TEMP_BIN -rm FlatBuffers.Core.Test.sln +rm FlatBuffers.Test.sln rm -rf obj diff --git a/tests/FlatBuffers.Test/monsterdata_cstest.mon b/tests/FlatBuffers.Test/monsterdata_cstest.mon new file mode 100644 index 0000000000000000000000000000000000000000..d18dc034792915e1cc93a2b1379cb35ca7d2e399 GIT binary patch literal 304 zcmYk1yAAl>HEuW- z*K?Frj;#Y8biTgMYmSj=|+Ka~y@+klG8UJ0tr5 literal 0 HcmV?d00001 diff --git a/tests/FlatBuffers.Test/monsterdata_cstest_sp.mon b/tests/FlatBuffers.Test/monsterdata_cstest_sp.mon new file mode 100644 index 0000000000000000000000000000000000000000..da3c80353f5ef2231c8ce999ec40ea1d9ea2c5fb GIT binary patch literal 304 zcmYk1F-yZx6opUHRH|m^kWDEaLUG8T&IN-=a4@#e!LEh8LC^$}40h|!@CWz<9o^!0 zlL}tmIp=#9-n;K5o|H(+SI?VRkGg^vn&X$~LXoBl6~I>Kit(?WB$&a4b z_~8yqS?I4Osjsn4*!n0%*GHZ)`HX3wUDw$(Q&ziz-~{FQBkLKru4!-o@eO>6@_k;F xP3vlSgd!9pJNM1KbMl9@UZ@Ff6~M!9?e3S?xAz@sZ@k~trP~iPv$`rOdcV>}BqRU; literal 0 HcmV?d00001 diff --git a/tests/FlatBuffers.Test/packages.config b/tests/FlatBuffers.Test/packages.config index 1d41d8e683d..be414a394be 100644 --- a/tests/FlatBuffers.Test/packages.config +++ b/tests/FlatBuffers.Test/packages.config @@ -1,4 +1,4 @@  - - \ No newline at end of file + +