Skip to content

Commit 2a464c5

Browse files
authored
Range is only avaliable in net46 when FeatureValueTuple (#259)
1 parent e78cb61 commit 2a464c5

File tree

8 files changed

+37
-12
lines changed

8 files changed

+37
-12
lines changed

src/ConsumeMemoryWithNoTask/ConsumeMemoryWithNoTask.csproj renamed to src/ConsumeOnlyMemory/ConsumeOnlyMemory.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<NoWarn>$(NoWarn);PolyfillTargetsForNuget</NoWarn>
44
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
5-
<TargetFrameworks>netstandard2.0</TargetFrameworks>
5+
<TargetFrameworks>net461;net462;net47;net471;net472;net48;net481;net6.0-windows;netstandard2.0;netstandard2.1;netcoreapp2.0;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
66
</PropertyGroup>
77
<ItemGroup>
88
<PackageReference Include="System.Memory" Condition="$(TargetFramework) != '.NETStandard' or $(TargetFrameworkIdentifier) == '.NETFramework' or $(TargetFramework.StartsWith('netcoreapp'))" />

src/ConsumeTasksWithNoMemory/ConsumeTasksWithNoMemory.csproj renamed to src/ConsumeOnlyTasks/ConsumeOnlyTasks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<NoWarn>$(NoWarn);PolyfillTargetsForNuget</NoWarn>
44
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
5-
<TargetFrameworks>netstandard2.0</TargetFrameworks>
5+
<TargetFrameworks>net461;net462;net47;net471;net472;net48;net481;net6.0-windows;netstandard2.0;netstandard2.1;netcoreapp2.0;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
66
</PropertyGroup>
77
<ItemGroup>
88
<PackageReference Include="System.Threading.Tasks.Extensions" />
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<NoWarn>$(NoWarn);PolyfillTargetsForNuget</NoWarn>
4+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
5+
<TargetFrameworks>net461;net462;net47;net471;net472;net48;net481;net6.0-windows;netstandard2.0;netstandard2.1;netcoreapp2.0;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
6+
</PropertyGroup>
7+
<ItemGroup>
8+
<PackageReference Include="System.ValueTuple" Condition="$(TargetFramework.StartsWith('net46'))" />
9+
</ItemGroup>
10+
<Import Project="$(SolutionDir)\Polyfill\Polyfill.targets" />
11+
<Import Project="$(SolutionDir)\TestIncludes.targets" />
12+
</Project>

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project>
33
<PropertyGroup>
4-
<Version>7.7.0</Version>
4+
<Version>7.7.1</Version>
55
<AssemblyVersion>1.0.0</AssemblyVersion>
66
<PackageTags>Polyfill</PackageTags>
77
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>

src/Polyfill.sln

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NoRefsTests", "NoRefsTests\
3737
EndProject
3838
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsumeNoRefs", "ConsumeNoRefs\ConsumeNoRefs.csproj", "{B4DC96CA-C700-499F-A9A2-0C767DCF8C30}"
3939
EndProject
40-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsumeTasksWithNoMemory", "ConsumeTasksWithNoMemory\ConsumeTasksWithNoMemory.csproj", "{96EF1E04-5862-4D9E-B800-A6402F1ADF7A}"
40+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsumeOnlyTasks", "ConsumeOnlyTasks\ConsumeOnlyTasks.csproj", "{96EF1E04-5862-4D9E-B800-A6402F1ADF7A}"
4141
EndProject
4242
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TargetFrameworkUsage", "TargetFrameworkUsage\TargetFrameworkUsage.csproj", "{41CB5A0C-E0F5-4C5C-B2FC-9A289E8CFDF8}"
4343
EndProject
44-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsumeMemoryWithNoTask", "ConsumeMemoryWithNoTask\ConsumeMemoryWithNoTask.csproj", "{1BDDA7F0-0D45-418C-B3DB-BBA39C29FD77}"
44+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsumeOnlyMemory", "ConsumeOnlyMemory\ConsumeOnlyMemory.csproj", "{1BDDA7F0-0D45-418C-B3DB-BBA39C29FD77}"
4545
EndProject
4646
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsumeCs12", "ConsumeCs12\ConsumeCs12.csproj", "{4ACF4760-B3C5-4D07-9D92-2B8225BA8881}"
4747
EndProject
@@ -55,6 +55,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsumeCsDefault", "Consume
5555
EndProject
5656
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiBuilderTests", "ApiBuilderTests\ApiBuilderTests.csproj", "{CC0C08FE-14E1-4A3D-8547-EFC8097D48C4}"
5757
EndProject
58+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsumeOnlyValueTuple", "ConsumeOnlyValueTuple\ConsumeOnlyValueTuple.csproj", "{2FE1429A-68B0-4C71-B1ED-D371C72DAD0E}"
59+
EndProject
5860
Global
5961
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6062
Debug|Any CPU = Debug|Any CPU
@@ -131,6 +133,10 @@ Global
131133
{CC0C08FE-14E1-4A3D-8547-EFC8097D48C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
132134
{CC0C08FE-14E1-4A3D-8547-EFC8097D48C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
133135
{CC0C08FE-14E1-4A3D-8547-EFC8097D48C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
136+
{2FE1429A-68B0-4C71-B1ED-D371C72DAD0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
137+
{2FE1429A-68B0-4C71-B1ED-D371C72DAD0E}.Debug|Any CPU.Build.0 = Debug|Any CPU
138+
{2FE1429A-68B0-4C71-B1ED-D371C72DAD0E}.Release|Any CPU.ActiveCfg = Release|Any CPU
139+
{2FE1429A-68B0-4C71-B1ED-D371C72DAD0E}.Release|Any CPU.Build.0 = Release|Any CPU
134140
EndGlobalSection
135141
GlobalSection(SolutionProperties) = preSolution
136142
HideSolutionNode = FALSE

src/Polyfill/Polyfill_Memory_EndsWith.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
#if FeatureMemory
44

5-
using System.ComponentModel;
6-
using System.Runtime.CompilerServices;
7-
85
#pragma warning disable
96

107
namespace Polyfills;
118

129
using System;
1310
using System.Text;
11+
using System.ComponentModel;
12+
using System.Runtime.CompilerServices;
1413

1514
static partial class Polyfill
1615
{
@@ -25,8 +24,16 @@ static partial class Polyfill
2524
//Link: https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.endswith#system-memoryextensions-endswith-1(system-readonlyspan((-0))-0)
2625
[MethodImpl(MethodImplOptions.AggressiveInlining)]
2726
public static bool EndsWith<T>(this ReadOnlySpan<T> target, T value)
28-
where T : IEquatable<T>? =>
29-
target.Length != 0 && (target[^1]?.Equals(value) ?? (object?)value is null);
27+
where T : IEquatable<T>?
28+
{
29+
if (target.Length == 0)
30+
{
31+
return false;
32+
}
33+
34+
var last = target[target.Length-1];
35+
return last?.Equals(value) ?? (object?)value is null;
36+
}
3037

3138
#endif
3239

src/Polyfill/Polyfill_Memory_SpanSplit.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// <auto-generated />
22
#pragma warning disable
33

4-
#if FeatureMemory
4+
#if FeatureMemory && FeatureValueTuple
55

66
namespace Polyfills;
77
using System;

src/Polyfill/Polyfill_Memory_SpanSplitEnumerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// <auto-generated />
22
#pragma warning disable
33

4-
#if FeatureMemory && !NET9_0_OR_GREATER
4+
#if FeatureMemory && !NET9_0_OR_GREATER && FeatureValueTuple
55

66
namespace Polyfills;
77

0 commit comments

Comments
 (0)