Add .NET 5.0 support

While we're at it, clean up the conditional compliation constants and dependencies:
- Define `SPAN_NATIVE` on all platforms _except_ `net45` and `netstandard2.0` (so it's defined automatically on new .NET versions)
- Only add `System.Memory` dependency on `net45` and `netstandard2.0`.
- Fix `NATIVE_SPAN` typo
- Remove obsolete `NETCORE` preprocessor variable.
This commit is contained in:
Frederik Carlier
2021-04-21 12:03:00 +02:00
parent 658caee3ad
commit 4f74157938
5 changed files with 13 additions and 24 deletions

View File

@@ -2,12 +2,12 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>Claunia.PropertyList.Benchmark</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.10.14" />
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
</ItemGroup>
<ItemGroup>

View File

@@ -110,8 +110,6 @@ namespace plistcil.test
// The value being used comes seen in a real property list:
// <key>TimeZoneOffsetFromUTC</key>
// <real>7200.000000</real>
#if !NETCORE
[Fact]
[UseCulture("en-US")]
public static void ParseNumberEnTest()
@@ -156,7 +154,6 @@ namespace plistcil.test
Assert.True(number.isReal());
Assert.Equal(7200d, number.ToDouble());
}
#endif
public static IEnumerable<object[]> StringConstructorTestData()
{

View File

@@ -1,19 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
</ItemGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp1.0'">
<DefineConstants>NETCOREAPP1_0;NETCORE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\plist-cil\plist-cil.csproj" />
</ItemGroup>

View File

@@ -355,10 +355,10 @@ namespace Claunia.PropertyList
internal void Write(Span<byte> bytes)
{
#if SPAN_NATIVE
#if NATIVE_SPAN
outStream.Write(bytes);
count += bytes.Length;
#else
#else
Write(bytes.ToArray());
#endif
}

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net45;netcoreapp2.0;netstandard2.0;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net45;netstandard2.0;netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
<VersionPrefix>2.1</VersionPrefix>
<Authors>Natalia Portillo</Authors>
<Company>Claunia.com</Company>
@@ -37,11 +37,7 @@ Use invariant culture to format NSDate.</PackageReleaseNotes>
<DefineConstants>TRACE;DEBUG</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith('netcoreapp')) Or $(TargetFramework.StartsWith('netstandard'))">
<DefineConstants>$(DefineConstants);NETCORE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1' Or '$(TargetFramework)' == 'netcoreapp2.2' Or $(TargetFramework.StartsWith('netcoreapp.3.'))">
<PropertyGroup Condition=" '$(TargetFramework)' != 'net45' AND '$(TargetFramework)' != 'netstandard2.0'">
<DefineConstants>$(DefineConstants);NATIVE_SPAN</DefineConstants>
</PropertyGroup>
@@ -49,8 +45,8 @@ Use invariant culture to format NSDate.</PackageReleaseNotes>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp2.1'">
<PackageReference Include="System.Memory" Version="4.5.0" />
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' OR '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="System.Memory" Version="4.5.4" />
</ItemGroup>
<ItemGroup>