From 06a9ef64d864b09f416c609e00ab8780dd3e3fe5 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 3 Feb 2025 21:48:16 +1100 Subject: [PATCH] work around Bcl Memory ref (#297) --- src/ConsumeBclMemory/ConsumeBclMemory.csproj | 14 ++++++++++++++ src/ConsumeConsumeBclMemory/Consume.cs | 10 ++++++++++ .../ConsumeConsumeBclMemory.csproj | 10 ++++++++++ src/Directory.Packages.props | 1 + src/Polyfill.sln | 12 ++++++++++++ src/Polyfill/IndexRange/Index.cs | 2 +- src/Polyfill/IndexRange/Range.cs | 2 +- src/Polyfill/Polyfill.targets | 3 +++ 8 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 src/ConsumeBclMemory/ConsumeBclMemory.csproj create mode 100644 src/ConsumeConsumeBclMemory/Consume.cs create mode 100644 src/ConsumeConsumeBclMemory/ConsumeConsumeBclMemory.csproj diff --git a/src/ConsumeBclMemory/ConsumeBclMemory.csproj b/src/ConsumeBclMemory/ConsumeBclMemory.csproj new file mode 100644 index 00000000..75272912 --- /dev/null +++ b/src/ConsumeBclMemory/ConsumeBclMemory.csproj @@ -0,0 +1,14 @@ + + + $(NoWarn);PolyfillTargetsForNuget + net461;net462;net47;net471;net472;net48;net481;net6.0-windows + $(TargetFrameworks);netstandard2.0;netstandard2.1;netcoreapp2.0;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0 + true + + + + + + + + \ No newline at end of file diff --git a/src/ConsumeConsumeBclMemory/Consume.cs b/src/ConsumeConsumeBclMemory/Consume.cs new file mode 100644 index 00000000..825c4f6b --- /dev/null +++ b/src/ConsumeConsumeBclMemory/Consume.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; + +static class Consume +{ + static Consume() + { + var strings = new List(); + var last = strings[^1]; + } +} \ No newline at end of file diff --git a/src/ConsumeConsumeBclMemory/ConsumeConsumeBclMemory.csproj b/src/ConsumeConsumeBclMemory/ConsumeConsumeBclMemory.csproj new file mode 100644 index 00000000..76f13033 --- /dev/null +++ b/src/ConsumeConsumeBclMemory/ConsumeConsumeBclMemory.csproj @@ -0,0 +1,10 @@ + + + $(NoWarn);PolyfillTargetsForNuget + net461;net462;net47;net471;net472;net48;net481;net6.0-windows + $(TargetFrameworks);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/Directory.Packages.props b/src/Directory.Packages.props index 75adcee2..5cfc5190 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -12,6 +12,7 @@ + diff --git a/src/Polyfill.sln b/src/Polyfill.sln index b4aff1d6..eb9c6a13 100644 --- a/src/Polyfill.sln +++ b/src/Polyfill.sln @@ -57,6 +57,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsumeOnlyValueTuple", "Co EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NoExtras", "NoExtras\NoExtras.csproj", "{4F482296-D4BF-4E56-AF23-351CCEF1B96E}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsumeBclMemory", "ConsumeBclMemory\ConsumeBclMemory.csproj", "{A89A3ACD-3DC8-4321-AEBC-05DAF0DEC9E5}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsumeConsumeBclMemory", "ConsumeConsumeBclMemory\ConsumeConsumeBclMemory.csproj", "{E83A80D1-10E3-4CBE-942D-E671A04C93F7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -137,6 +141,14 @@ Global {4F482296-D4BF-4E56-AF23-351CCEF1B96E}.Debug|Any CPU.Build.0 = Debug|Any CPU {4F482296-D4BF-4E56-AF23-351CCEF1B96E}.Release|Any CPU.ActiveCfg = Release|Any CPU {4F482296-D4BF-4E56-AF23-351CCEF1B96E}.Release|Any CPU.Build.0 = Release|Any CPU + {A89A3ACD-3DC8-4321-AEBC-05DAF0DEC9E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A89A3ACD-3DC8-4321-AEBC-05DAF0DEC9E5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A89A3ACD-3DC8-4321-AEBC-05DAF0DEC9E5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A89A3ACD-3DC8-4321-AEBC-05DAF0DEC9E5}.Release|Any CPU.Build.0 = Release|Any CPU + {E83A80D1-10E3-4CBE-942D-E671A04C93F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E83A80D1-10E3-4CBE-942D-E671A04C93F7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E83A80D1-10E3-4CBE-942D-E671A04C93F7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E83A80D1-10E3-4CBE-942D-E671A04C93F7}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Polyfill/IndexRange/Index.cs b/src/Polyfill/IndexRange/Index.cs index 965986e6..55163f5f 100644 --- a/src/Polyfill/IndexRange/Index.cs +++ b/src/Polyfill/IndexRange/Index.cs @@ -1,7 +1,7 @@ // #pragma warning disable -#if FeatureValueTuple +#if FeatureValueTuple && !RefsBclMemory #if NET46X || NET47X || NET48X || NETSTANDARD2_0 || NETCOREAPP2X namespace System; diff --git a/src/Polyfill/IndexRange/Range.cs b/src/Polyfill/IndexRange/Range.cs index 90c67ce8..721ba094 100644 --- a/src/Polyfill/IndexRange/Range.cs +++ b/src/Polyfill/IndexRange/Range.cs @@ -1,7 +1,7 @@ // #pragma warning disable -#if FeatureValueTuple +#if FeatureValueTuple && !RefsBclMemory #if NET46X || NET47X || NET48X || NETSTANDARD2_0 || NETCOREAPP2X namespace System; diff --git a/src/Polyfill/Polyfill.targets b/src/Polyfill/Polyfill.targets index 358b9e14..b2970ee1 100644 --- a/src/Polyfill/Polyfill.targets +++ b/src/Polyfill/Polyfill.targets @@ -82,6 +82,9 @@ For example: $(DefineConstants);FeatureValueTuple + $(DefineConstants);RefsBclMemory + @(ResolvedCompileFileDefinitions->WithMetadataValue('NuGetPackageId', 'System.Memory')->Metadata('NuGetPackageVersion'))