From 068641cf6df4076933ed25fbe9570aec1cb9e122 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Tue, 17 Dec 2024 12:31:14 +1100 Subject: [PATCH 1/5] . --- .../ConsumeOnlyMemory.csproj} | 2 +- .../ConsumeOnlyTasks.csproj} | 2 +- src/Polyfill.sln | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) rename src/{ConsumeMemoryWithNoTask/ConsumeMemoryWithNoTask.csproj => ConsumeOnlyMemory/ConsumeOnlyMemory.csproj} (69%) rename src/{ConsumeTasksWithNoMemory/ConsumeTasksWithNoMemory.csproj => ConsumeOnlyTasks/ConsumeOnlyTasks.csproj} (62%) diff --git a/src/ConsumeMemoryWithNoTask/ConsumeMemoryWithNoTask.csproj b/src/ConsumeOnlyMemory/ConsumeOnlyMemory.csproj similarity index 69% rename from src/ConsumeMemoryWithNoTask/ConsumeMemoryWithNoTask.csproj rename to src/ConsumeOnlyMemory/ConsumeOnlyMemory.csproj index 0f4355ee..d7733a83 100644 --- a/src/ConsumeMemoryWithNoTask/ConsumeMemoryWithNoTask.csproj +++ b/src/ConsumeOnlyMemory/ConsumeOnlyMemory.csproj @@ -2,7 +2,7 @@ $(NoWarn);PolyfillTargetsForNuget true - netstandard2.0 + 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 diff --git a/src/ConsumeTasksWithNoMemory/ConsumeTasksWithNoMemory.csproj b/src/ConsumeOnlyTasks/ConsumeOnlyTasks.csproj similarity index 62% rename from src/ConsumeTasksWithNoMemory/ConsumeTasksWithNoMemory.csproj rename to src/ConsumeOnlyTasks/ConsumeOnlyTasks.csproj index 18b4b721..80903913 100644 --- a/src/ConsumeTasksWithNoMemory/ConsumeTasksWithNoMemory.csproj +++ b/src/ConsumeOnlyTasks/ConsumeOnlyTasks.csproj @@ -2,7 +2,7 @@ $(NoWarn);PolyfillTargetsForNuget true - netstandard2.0 + 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 diff --git a/src/Polyfill.sln b/src/Polyfill.sln index 3bf2d7f0..c52f0311 100644 --- a/src/Polyfill.sln +++ b/src/Polyfill.sln @@ -37,11 +37,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NoRefsTests", "NoRefsTests\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsumeNoRefs", "ConsumeNoRefs\ConsumeNoRefs.csproj", "{B4DC96CA-C700-499F-A9A2-0C767DCF8C30}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsumeTasksWithNoMemory", "ConsumeTasksWithNoMemory\ConsumeTasksWithNoMemory.csproj", "{96EF1E04-5862-4D9E-B800-A6402F1ADF7A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsumeOnlyTasks", "ConsumeOnlyTasks\ConsumeOnlyTasks.csproj", "{96EF1E04-5862-4D9E-B800-A6402F1ADF7A}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TargetFrameworkUsage", "TargetFrameworkUsage\TargetFrameworkUsage.csproj", "{41CB5A0C-E0F5-4C5C-B2FC-9A289E8CFDF8}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsumeMemoryWithNoTask", "ConsumeMemoryWithNoTask\ConsumeMemoryWithNoTask.csproj", "{1BDDA7F0-0D45-418C-B3DB-BBA39C29FD77}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsumeOnlyMemory", "ConsumeOnlyMemory\ConsumeOnlyMemory.csproj", "{1BDDA7F0-0D45-418C-B3DB-BBA39C29FD77}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsumeCs12", "ConsumeCs12\ConsumeCs12.csproj", "{4ACF4760-B3C5-4D07-9D92-2B8225BA8881}" EndProject From 3301c86e0b4f02b638f7a071c02e24419bfc8684 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Tue, 17 Dec 2024 12:37:23 +1100 Subject: [PATCH 2/5] Update Polyfill_Memory_SpanSplitEnumerator.cs --- src/Polyfill/Polyfill_Memory_SpanSplitEnumerator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Polyfill/Polyfill_Memory_SpanSplitEnumerator.cs b/src/Polyfill/Polyfill_Memory_SpanSplitEnumerator.cs index 704e903d..68f8380b 100644 --- a/src/Polyfill/Polyfill_Memory_SpanSplitEnumerator.cs +++ b/src/Polyfill/Polyfill_Memory_SpanSplitEnumerator.cs @@ -1,7 +1,7 @@ // #pragma warning disable -#if FeatureMemory && !NET9_0_OR_GREATER +#if FeatureMemory && !NET9_0_OR_GREATER && FeatureValueTuple namespace Polyfills; From 6a75cba9cd66e2f002d703b77cbab29aef78b842 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Tue, 17 Dec 2024 12:38:03 +1100 Subject: [PATCH 3/5] Update Directory.Build.props --- src/Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index a26adf45..25acfe05 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,7 +1,7 @@ - 7.7.0 + 7.7.1 1.0.0 Polyfill true From fb31207683d2c5b3fc7981eb8c302c096e49cdf1 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Tue, 17 Dec 2024 12:45:09 +1100 Subject: [PATCH 4/5] . --- .../ConsumeOnlyValueTuple.csproj | 12 ++++++++++++ src/Polyfill.sln | 6 ++++++ 2 files changed, 18 insertions(+) create mode 100644 src/ConsumeOnlyValueTuple/ConsumeOnlyValueTuple.csproj diff --git a/src/ConsumeOnlyValueTuple/ConsumeOnlyValueTuple.csproj b/src/ConsumeOnlyValueTuple/ConsumeOnlyValueTuple.csproj new file mode 100644 index 00000000..0b2d234f --- /dev/null +++ b/src/ConsumeOnlyValueTuple/ConsumeOnlyValueTuple.csproj @@ -0,0 +1,12 @@ + + + $(NoWarn);PolyfillTargetsForNuget + true + 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 + + + + + + + \ No newline at end of file diff --git a/src/Polyfill.sln b/src/Polyfill.sln index c52f0311..7cef8460 100644 --- a/src/Polyfill.sln +++ b/src/Polyfill.sln @@ -55,6 +55,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsumeCsDefault", "Consume EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiBuilderTests", "ApiBuilderTests\ApiBuilderTests.csproj", "{CC0C08FE-14E1-4A3D-8547-EFC8097D48C4}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsumeOnlyValueTuple", "ConsumeOnlyValueTuple\ConsumeOnlyValueTuple.csproj", "{2FE1429A-68B0-4C71-B1ED-D371C72DAD0E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -131,6 +133,10 @@ Global {CC0C08FE-14E1-4A3D-8547-EFC8097D48C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CC0C08FE-14E1-4A3D-8547-EFC8097D48C4}.Debug|Any CPU.Build.0 = Debug|Any CPU {CC0C08FE-14E1-4A3D-8547-EFC8097D48C4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2FE1429A-68B0-4C71-B1ED-D371C72DAD0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2FE1429A-68B0-4C71-B1ED-D371C72DAD0E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2FE1429A-68B0-4C71-B1ED-D371C72DAD0E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2FE1429A-68B0-4C71-B1ED-D371C72DAD0E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 9cbcfc52009d047535ec78a6e9ca9646dbd950fc Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Tue, 17 Dec 2024 17:02:52 +1100 Subject: [PATCH 5/5] . --- src/Polyfill/Polyfill_Memory_EndsWith.cs | 17 ++++++++++++----- src/Polyfill/Polyfill_Memory_SpanSplit.cs | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Polyfill/Polyfill_Memory_EndsWith.cs b/src/Polyfill/Polyfill_Memory_EndsWith.cs index 24380870..f60be216 100644 --- a/src/Polyfill/Polyfill_Memory_EndsWith.cs +++ b/src/Polyfill/Polyfill_Memory_EndsWith.cs @@ -2,15 +2,14 @@ #if FeatureMemory -using System.ComponentModel; -using System.Runtime.CompilerServices; - #pragma warning disable namespace Polyfills; using System; using System.Text; +using System.ComponentModel; +using System.Runtime.CompilerServices; static partial class Polyfill { @@ -25,8 +24,16 @@ static partial class Polyfill //Link: https://learn.microsoft.com/en-us/dotnet/api/system.memoryextensions.endswith#system-memoryextensions-endswith-1(system-readonlyspan((-0))-0) [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool EndsWith(this ReadOnlySpan target, T value) - where T : IEquatable? => - target.Length != 0 && (target[^1]?.Equals(value) ?? (object?)value is null); + where T : IEquatable? + { + if (target.Length == 0) + { + return false; + } + + var last = target[target.Length-1]; + return last?.Equals(value) ?? (object?)value is null; + } #endif diff --git a/src/Polyfill/Polyfill_Memory_SpanSplit.cs b/src/Polyfill/Polyfill_Memory_SpanSplit.cs index cee06e9b..baead155 100644 --- a/src/Polyfill/Polyfill_Memory_SpanSplit.cs +++ b/src/Polyfill/Polyfill_Memory_SpanSplit.cs @@ -1,7 +1,7 @@ // #pragma warning disable -#if FeatureMemory +#if FeatureMemory && FeatureValueTuple namespace Polyfills; using System;