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