summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorConan Chen <ConanChenTookMyName@users.noreply.github.com>2020-09-28 14:56:59 -0400
committerGitHub <noreply@github.com>2020-09-28 11:56:59 -0700
commit0bdf2fa156f5133b09ddac7beb326b942d524b38 (patch)
tree2e35a1c380c302bdc7422acd03f1f5cbf7267f17 /net
parent2eedc769d55cfd538208bff8b3ad5f66bd9239d9 (diff)
downloadflatbuffers-0bdf2fa156f5133b09ddac7beb326b942d524b38.tar.gz
flatbuffers-0bdf2fa156f5133b09ddac7beb326b942d524b38.tar.bz2
flatbuffers-0bdf2fa156f5133b09ddac7beb326b942d524b38.zip
[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#
Diffstat (limited to 'net')
-rw-r--r--net/FlatBuffers/ByteBuffer.cs13
-rw-r--r--net/FlatBuffers/FlatBuffers.Core.csproj19
-rw-r--r--net/FlatBuffers/FlatBuffers.csproj67
-rw-r--r--net/FlatBuffers/FlatBuffers.net35.csproj57
4 files changed, 82 insertions, 74 deletions
diff --git a/net/FlatBuffers/ByteBuffer.cs b/net/FlatBuffers/ByteBuffer.cs
index 4ed00627..6e0fe35b 100644
--- a/net/FlatBuffers/ByteBuffer.cs
+++ b/net/FlatBuffers/ByteBuffer.cs
@@ -14,24 +14,25 @@
* limitations under the License.
*/
-// There are 3 #defines that have an impact on performance / features of this ByteBuffer implementation
+// There are three conditional compilation symbols that have an impact on performance/features of this ByteBuffer implementation.
//
-// UNSAFE_BYTEBUFFER
+// UNSAFE_BYTEBUFFER
// This will use unsafe code to manipulate the underlying byte array. This
// can yield a reasonable performance increase.
//
// BYTEBUFFER_NO_BOUNDS_CHECK
// This will disable the bounds check asserts to the byte array. This can
-// yield a small performance gain in normal code..
+// yield a small performance gain in normal code.
//
// ENABLE_SPAN_T
-// This will enable reading and writing blocks of memory with a Span<T> instead if just
+// This will enable reading and writing blocks of memory with a Span<T> instead of just
// T[]. You can also enable writing directly to shared memory or other types of memory
// by providing a custom implementation of ByteBufferAllocator.
-// ENABLE_SPAN_T also requires UNSAFE_BYTEBUFFER to be defined
+// ENABLE_SPAN_T also requires UNSAFE_BYTEBUFFER to be defined, or .NET
+// Standard 2.1.
//
// Using UNSAFE_BYTEBUFFER and BYTEBUFFER_NO_BOUNDS_CHECK together can yield a
-// performance gain of ~15% for some operations, however doing so is potentially
+// performance gain of ~15% for some operations, however doing so is potentially
// dangerous. Do so at your own risk!
//
diff --git a/net/FlatBuffers/FlatBuffers.Core.csproj b/net/FlatBuffers/FlatBuffers.Core.csproj
deleted file mode 100644
index 040e7716..00000000
--- a/net/FlatBuffers/FlatBuffers.Core.csproj
+++ /dev/null
@@ -1,19 +0,0 @@
-<Project Sdk="Microsoft.NET.Sdk">
-
- <PropertyGroup>
- <TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
- </PropertyGroup>
-
- <ItemGroup>
- <Compile Remove="Properties\**" />
- </ItemGroup>
-
- <ItemGroup>
- <EmbeddedResource Remove="Properties\**" />
- </ItemGroup>
-
- <ItemGroup>
- <None Remove="Properties\**" />
- </ItemGroup>
-
-</Project>
diff --git a/net/FlatBuffers/FlatBuffers.csproj b/net/FlatBuffers/FlatBuffers.csproj
index a0290947..54cba5aa 100644
--- a/net/FlatBuffers/FlatBuffers.csproj
+++ b/net/FlatBuffers/FlatBuffers.csproj
@@ -1,54 +1,23 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+<Project Sdk="Microsoft.NET.Sdk">
+
<PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProjectGuid>{28C00774-1E73-4A75-AD8F-844CD21A064D}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>FlatBuffers</RootNamespace>
- <AssemblyName>FlatBuffers</AssemblyName>
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
+ <TargetFrameworks>netstandard2.1;netstandard2.0;net46</TargetFrameworks>
+ <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
+
+ <PropertyGroup Condition="'$(UNSAFE_BYTEBUFFER)' == 'true'">
+ <DefineConstants>$(DefineConstants);UNSAFE_BYTEBUFFER</DefineConstants>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\Release\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
+ <PropertyGroup Condition="'$(BYTEBUFFER_NO_BOUNDS_CHECK)' == 'true'">
+ <DefineConstants>$(DefineConstants);BYTEBUFFER_NO_BOUNDS_CHECK</DefineConstants>
</PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- <Reference Include="System.Core" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="ByteBuffer.cs" />
- <Compile Include="FlatBufferBuilder.cs" />
- <Compile Include="FlatBufferConstants.cs" />
- <Compile Include="IFlatbufferObject.cs" />
- <Compile Include="Offset.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="Struct.cs" />
- <Compile Include="Table.cs" />
+ <PropertyGroup Condition="'$(ENABLE_SPAN_T)' == 'true'">
+ <DefineConstants>$(DefineConstants);ENABLE_SPAN_T</DefineConstants>
+ </PropertyGroup>
+
+ <ItemGroup Condition="('$(ENABLE_SPAN_T)' == 'true') And (('$(TargetFramework)' == 'netstandard2.0') Or ('$(TargetFramework)' == 'net46'))">
+ <PackageReference Include="System.Memory" Version="4.5.4" />
</ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project> \ No newline at end of file
+
+</Project>
diff --git a/net/FlatBuffers/FlatBuffers.net35.csproj b/net/FlatBuffers/FlatBuffers.net35.csproj
new file mode 100644
index 00000000..574580e3
--- /dev/null
+++ b/net/FlatBuffers/FlatBuffers.net35.csproj
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{28C00774-1E73-4A75-AD8F-844CD21A064D}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>FlatBuffers</RootNamespace>
+ <AssemblyName>FlatBuffers</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\net35</OutputPath>
+ <IntermediateOutputPath>obj\Debug\net35</IntermediateOutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\net35</OutputPath>
+ <IntermediateOutputPath>obj\Release\net35</IntermediateOutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="ByteBuffer.cs" />
+ <Compile Include="ByteBufferUtil.cs" />
+ <Compile Include="FlatBufferBuilder.cs" />
+ <Compile Include="FlatBufferConstants.cs" />
+ <Compile Include="IFlatbufferObject.cs" />
+ <Compile Include="Offset.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Struct.cs" />
+ <Compile Include="Table.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project> \ No newline at end of file