# Have to compile this here rather than in "build" above because AppVeyor only
# supports building one project??
- "cd FlatBuffers.Test"
- - "copy ..\\monsterdata_test.mon Resources\\"
- - "copy ..\\monsterdata_test.json Resources\\"
- "dotnet new sln"
- "dotnet sln add FlatBuffers.Test.csproj"
- "nuget restore"
- - "msbuild.exe /property:Configuration=Release;OutputPath=tempcs /verbosity:minimal FlatBuffers.Test.csproj"
- - "tempcs\\FlatBuffers.Test.exe"
+ - "mkdir .tmp"
+ - "msbuild.exe /property:Configuration=Release;OutputPath=.tmp /verbosity:minimal FlatBuffers.Test.csproj"
+ - ".tmp\\FlatBuffers.Test.exe"
# Run tests with UNSAFE_BYTEBUFFER
- - "msbuild.exe /property:Configuration=Release;UnsafeByteBuffer=true;OutputPath=tempcsUnsafe /verbosity:minimal FlatBuffers.Test.csproj"
- - "tempcsUnsafe\\FlatBuffers.Test.exe"
+ - "msbuild.exe /property:Configuration=Release;UnsafeByteBuffer=true;OutputPath=.tmp /verbosity:minimal FlatBuffers.Test.csproj"
+ - ".tmp\\FlatBuffers.Test.exe"
# TODO: add more languages.
- "cd ..\\.."
--- /dev/null
+dotnet-install.sh
+.dotnet_tmp/
+.tmp/
+packages/
\ No newline at end of file
Assert.Throws<ArgumentException>(() => uut.Put(1024, data));
}
+ #pragma warning disable 0169
+ // These are purposely not used and the warning is suppress
private struct dummyStruct
{
int a;
float b;
}
+ #pragma warning restore 0169
[FlatBuffersTestMethod]
public void ByteBuffer_Put_Array_IncorrectType_Throws()
<RootNamespace>FlatBuffers.Test</RootNamespace>
<AssemblyName>FlatBuffers.Test</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <RuntimeIdentifier>win</RuntimeIdentifier>
<LangVersion>4</LangVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<DefineConstants>$(DefineConstants);UNSAFE_BYTEBUFFER</DefineConstants>
</PropertyGroup>
<ItemGroup>
+ <PackageReference Include="Newtonsoft.Json">
+ <Version>12.0.3</Version>
+ </PackageReference>
+ </ItemGroup>
+ <ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>packages\Newtonsoft.Json.12.0.3\lib\net35\Newtonsoft.Json.dll</HintPath>
</Reference>
// Dump to output directory so we can inspect later, if needed
#if ENABLE_SPAN_T
var data = fbb.DataBuffer.ToSizedArray();
- string filename = @"Resources/monsterdata_cstest" + (sizePrefix ? "_sp" : "") + ".mon";
+ string filename = @".tmp/monsterdata_cstest" + (sizePrefix ? "_sp" : "") + ".mon";
File.WriteAllBytes(filename, data);
#else
using (var ms = fbb.DataBuffer.ToMemoryStream(fbb.DataBuffer.Position, fbb.Offset))
{
var data = ms.ToArray();
- string filename = @"Resources/monsterdata_cstest" + (sizePrefix ? "_sp" : "") + ".mon";
+ string filename = @".tmp/monsterdata_cstest" + (sizePrefix ? "_sp" : "") + ".mon";
File.WriteAllBytes(filename, data);
}
#endif
[FlatBuffersTestMethod]
public void CanReadCppGeneratedWireFile()
{
- var data = File.ReadAllBytes(@"Resources/monsterdata_test.mon");
+ var data = File.ReadAllBytes(@"../monsterdata_test.mon");
var bb = new ByteBuffer(data);
TestBuffer(bb);
TestObjectAPI(Monster.GetRootAsMonster(bb));
[FlatBuffersTestMethod]
public void CanReadJsonFile()
{
- var jsonText = File.ReadAllText(@"Resources/monsterdata_test.json");
+ var jsonText = File.ReadAllText(@"../monsterdata_test.json");
var mon = MonsterT.DeserializeFromJson(jsonText);
var fbb = new FlatBufferBuilder(1);
fbb.Finish(Monster.Pack(fbb, mon).Value);
#!/bin/sh
-# Restore nuget packages
-mkdir dotnet_tmp
-curl -OL https://dot.net/v1/dotnet-install.sh
-chmod +x dotnet-install.sh
-./dotnet-install.sh --version latest --install-dir dotnet_tmp
-dotnet_tmp/dotnet new sln
-dotnet_tmp/dotnet sln add FlatBuffers.Test.csproj
-curl -OL https://dist.nuget.org/win-x86-commandline/v5.5.1/nuget.exe
-mono nuget.exe restore
-
-# Copy Test Files
-cp ../monsterdata_test.mon Resources/
-cp ../monsterdata_test.json Resources/
+PROJ_FILE=FlatBuffers.Test.csproj
-# Testing C# on Linux using Mono.
+TEMP_DOTNET_DIR=.dotnet_tmp
+TEMP_BIN=.tmp
+
+[ -d $TEMP_DOTNET_DIR ] || mkdir $TEMP_DOTNET_DIR
+
+[ -f dotnet-install.sh ] || curl -OL https://dot.net/v1/dotnet-install.sh
+
+./dotnet-install.sh --version latest --install-dir $TEMP_DOTNET_DIR
-msbuild -property:Configuration=Release,OutputPath=tempcs -verbosity:minimal FlatBuffers.Test.csproj
-mono tempcs/FlatBuffers.Test.exe
-rm -fr tempcs
-rm Resources/monsterdata_cstest.mon
-rm Resources/monsterdata_cstest_sp.mon
+DOTNET=$TEMP_DOTNET_DIR/dotnet
+
+$DOTNET new sln
+$DOTNET sln add $PROJ_FILE
+$DOTNET restore -r linux-x64 $PROJ_FILE
+
+# Testing C# on Linux using Mono.
+msbuild -property:Configuration=Release,OutputPath=$TEMP_BIN -verbosity:minimal $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:minimal $PROJ_FILE
+mono $TEMP_BIN/FlatBuffers.Test.exe
+rm -fr $TEMP_BIN
-msbuild -property:Configuration=Release,UnsafeByteBuffer=true,OutputPath=tempcsUnsafe -verbosity:minimal FlatBuffers.Test.csproj
-mono tempcsUnsafe/FlatBuffers.Test.exe
-rm -fr tempcsUnsafe
-rm Resources/monsterdata_cstest.mon
-rm Resources/monsterdata_cstest_sp.mon
-
-# Remove Temp Files
-rm -fr dotnet_tmp
-rm -fr packages
-rm dotnet-install.sh
-rm nuget.exe
rm FlatBuffers.Test.sln
-rm Resources/monsterdata_test.mon
-rm Resources/monsterdata_test.json
-
+rm -rf obj
--- /dev/null
+# .NET Tests
+
+## Running on Linux
+
+### Prerequisites
+To run the tests on a Linux a few prerequisites are needed:
+
+1) mono
+2) msbuild
+
+### Running
+
+To run the tests:
+
+```
+./NetTest.sh
+```
+
+This will download the .NET installer and core SDK if those are not already
+installed. Then it will build the tests using `msbuild` and run the resulting
+test binary with `mono`.
+
+After running the tests, the downloaded .NET installer and SDK are *not* removed
+as they can be reused in subsequent invocations. The files are ignored by git by
+default, and can remain in the working directory.
+
+### Cleaning
+
+If you want to clean up the downloaded .NET installer and SDK, run:
+
+```
+./clean.sh
+```
+
+This will wipe away the downloaded files and directories. Those will be
+automatically re-downloaded when running `NetTest.sh`.
+
+
--- /dev/null
+#!/bin/sh
+
+# Remove files and directory that are needed to build and run the .NET tests.
+# The script NetTest.sh installs these as needed.
+
+[ -d .dotnet_tmp ] && rm -rf .dotnet_tmp
+[ -d packages ] && rm -rf packages
+[ -d .tmp ] && rm -rf .tmp
+[ -f nuget.exe ] && rm nuget.exe
+[ -f dotnet-intall.sh ] && rm dotnet-install.sh