Skip to content

Commit 06a9ef6

Browse files
authored
work around Bcl Memory ref (#297)
1 parent 95192df commit 06a9ef6

File tree

8 files changed

+52
-2
lines changed

8 files changed

+52
-2
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<NoWarn>$(NoWarn);PolyfillTargetsForNuget</NoWarn>
4+
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT'">net461;net462;net47;net471;net472;net48;net481;net6.0-windows</TargetFrameworks>
5+
<TargetFrameworks>$(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</TargetFrameworks>
6+
<PolyPublic>true</PolyPublic>
7+
</PropertyGroup>
8+
<ItemGroup>
9+
<PackageReference Include="Microsoft.Bcl.Memory" />
10+
<PackageReference Include="System.ValueTuple" Condition="$(TargetFramework.StartsWith('net46'))" />
11+
</ItemGroup>
12+
<Import Project="$(SolutionDir)\Polyfill\Polyfill.targets" />
13+
<Import Project="$(SolutionDir)\TestIncludes.targets" />
14+
</Project>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Collections.Generic;
2+
3+
static class Consume
4+
{
5+
static Consume()
6+
{
7+
var strings = new List<string>();
8+
var last = strings[^1];
9+
}
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<NoWarn>$(NoWarn);PolyfillTargetsForNuget</NoWarn>
4+
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT'">net461;net462;net47;net471;net472;net48;net481;net6.0-windows</TargetFrameworks>
5+
<TargetFrameworks>$(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</TargetFrameworks>
6+
</PropertyGroup>
7+
<ItemGroup>
8+
<ProjectReference Include="..\ConsumeBclMemory\ConsumeBclMemory.csproj" />
9+
</ItemGroup>
10+
</Project>

src/Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<PackageVersion Include="ProjectDefaults" Version="1.0.147" />
1313
<PackageVersion Include="System.Memory" Version="4.6.0" />
1414
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
15+
<PackageVersion Include="Microsoft.Bcl.Memory" Version="9.0.1" />
1516
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.6.0" />
1617
<PackageVersion Include="System.ValueTuple" Version="4.5.0" />
1718
<PackageVersion Include="System.Runtime" Version="4.3.1" />

src/Polyfill.sln

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsumeOnlyValueTuple", "Co
5757
EndProject
5858
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NoExtras", "NoExtras\NoExtras.csproj", "{4F482296-D4BF-4E56-AF23-351CCEF1B96E}"
5959
EndProject
60+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsumeBclMemory", "ConsumeBclMemory\ConsumeBclMemory.csproj", "{A89A3ACD-3DC8-4321-AEBC-05DAF0DEC9E5}"
61+
EndProject
62+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsumeConsumeBclMemory", "ConsumeConsumeBclMemory\ConsumeConsumeBclMemory.csproj", "{E83A80D1-10E3-4CBE-942D-E671A04C93F7}"
63+
EndProject
6064
Global
6165
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6266
Debug|Any CPU = Debug|Any CPU
@@ -137,6 +141,14 @@ Global
137141
{4F482296-D4BF-4E56-AF23-351CCEF1B96E}.Debug|Any CPU.Build.0 = Debug|Any CPU
138142
{4F482296-D4BF-4E56-AF23-351CCEF1B96E}.Release|Any CPU.ActiveCfg = Release|Any CPU
139143
{4F482296-D4BF-4E56-AF23-351CCEF1B96E}.Release|Any CPU.Build.0 = Release|Any CPU
144+
{A89A3ACD-3DC8-4321-AEBC-05DAF0DEC9E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
145+
{A89A3ACD-3DC8-4321-AEBC-05DAF0DEC9E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
146+
{A89A3ACD-3DC8-4321-AEBC-05DAF0DEC9E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
147+
{A89A3ACD-3DC8-4321-AEBC-05DAF0DEC9E5}.Release|Any CPU.Build.0 = Release|Any CPU
148+
{E83A80D1-10E3-4CBE-942D-E671A04C93F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
149+
{E83A80D1-10E3-4CBE-942D-E671A04C93F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
150+
{E83A80D1-10E3-4CBE-942D-E671A04C93F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
151+
{E83A80D1-10E3-4CBE-942D-E671A04C93F7}.Release|Any CPU.Build.0 = Release|Any CPU
140152
EndGlobalSection
141153
GlobalSection(SolutionProperties) = preSolution
142154
HideSolutionNode = FALSE

src/Polyfill/IndexRange/Index.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 FeatureValueTuple
4+
#if FeatureValueTuple && !RefsBclMemory
55
#if NET46X || NET47X || NET48X || NETSTANDARD2_0 || NETCOREAPP2X
66

77
namespace System;

src/Polyfill/IndexRange/Range.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 FeatureValueTuple
4+
#if FeatureValueTuple && !RefsBclMemory
55
#if NET46X || NET47X || NET48X || NETSTANDARD2_0 || NETCOREAPP2X
66

77
namespace System;

src/Polyfill/Polyfill.targets

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ For example:
8282
<DefineConstants
8383
Condition="@(ResolvedCompileFileDefinitions->AnyHaveMetadataValue('NuGetPackageId', 'System.ValueTuple'))">$(DefineConstants);FeatureValueTuple</DefineConstants>
8484

85+
<DefineConstants
86+
Condition="@(ResolvedCompileFileDefinitions->AnyHaveMetadataValue('NuGetPackageId', 'Microsoft.Bcl.Memory'))">$(DefineConstants);RefsBclMemory</DefineConstants>
87+
8588
<MemoryVersion>@(ResolvedCompileFileDefinitions->WithMetadataValue('NuGetPackageId', 'System.Memory')->Metadata('NuGetPackageVersion'))</MemoryVersion>
8689

8790
<DefineConstants

0 commit comments

Comments
 (0)