Commit e2f5da65 authored by Jan Tattermusch's avatar Jan Tattermusch Committed by Jie Luo

C#: add System.Memory dependency for net45 too (#6317)

* introduce GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY

* allow building net45 target on unix systems too

* add Span<> support on net45 as well
parent 94cbf009
......@@ -18,13 +18,9 @@
<PackageReference Include="NUnitLite" Version="3.6.1" />
</ItemGroup>
<!--
- Override target frameworks on non-Windows to just .NET Core
- Doing this conditionally in the initial PropertyGroup confuses
- Visual Studio.
-->
<PropertyGroup Condition="'$(OS)' != 'Windows_NT'">
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
</PropertyGroup>
<!-- Needed for the net45 build to work on Unix. See https://github.com/dotnet/designs/pull/33 -->
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0-preview.2" PrivateAssets="All" />
</ItemGroup>
</Project>
......@@ -18,14 +18,10 @@
<PackageReference Include="NUnit3TestAdapter" Version="3.9.0" />
</ItemGroup>
<!--
- Override target frameworks on non-Windows to just .NET Core
- Doing this conditionally in the initial PropertyGroup confuses
- Visual Studio.
-->
<PropertyGroup Condition="'$(OS)' != 'Windows_NT'">
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
</PropertyGroup>
<!-- Needed for the net45 build to work on Unix. See https://github.com/dotnet/designs/pull/33 -->
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0-preview.2" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="testprotos.pb" />
......
......@@ -110,7 +110,7 @@ namespace Google.Protobuf
get { return Length == 0; }
}
#if NETSTANDARD2_0
#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY
/// <summary>
/// Provides read-only access to the data of this <see cref="ByteString"/>.
/// No data is copied so this is the most efficient way of accessing.
......@@ -218,7 +218,7 @@ namespace Google.Protobuf
return new ByteString(portion);
}
#if NETSTANDARD2_0
#if GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY
/// <summary>
/// Constructs a <see cref="ByteString" /> from a read only span. The contents
/// are copied, so further modifications to the span will not
......
......@@ -22,16 +22,16 @@
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>
<!--
- Override target frameworks on non-Windows to just .NET Core
- Doing this conditionally in the initial PropertyGroup confuses
- Visual Studio.
-->
<PropertyGroup Condition="'$(OS)' != 'Windows_NT'">
<TargetFrameworks>netstandard1.0;netstandard2.0</TargetFrameworks>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net45' or '$(TargetFramework)' == 'netstandard2.0' ">
<DefineConstants>$(DefineConstants);GOOGLE_PROTOBUF_SUPPORT_SYSTEM_MEMORY</DefineConstants>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<!-- Needed for the net45 build to work on Unix. See https://github.com/dotnet/designs/pull/33 -->
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0-preview.2" PrivateAssets="All" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' or '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="System.Memory" Version="4.5.2"/>
</ItemGroup>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment