Skip to content

Commit

Permalink
work around Bcl Memory ref (#297)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp authored Feb 3, 2025
1 parent 95192df commit 06a9ef6
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/ConsumeBclMemory/ConsumeBclMemory.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<NoWarn>$(NoWarn);PolyfillTargetsForNuget</NoWarn>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT'">net461;net462;net47;net471;net472;net48;net481;net6.0-windows</TargetFrameworks>
<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>
<PolyPublic>true</PolyPublic>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Bcl.Memory" />
<PackageReference Include="System.ValueTuple" Condition="$(TargetFramework.StartsWith('net46'))" />
</ItemGroup>
<Import Project="$(SolutionDir)\Polyfill\Polyfill.targets" />
<Import Project="$(SolutionDir)\TestIncludes.targets" />
</Project>
10 changes: 10 additions & 0 deletions src/ConsumeConsumeBclMemory/Consume.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Collections.Generic;

static class Consume
{
static Consume()
{
var strings = new List<string>();
var last = strings[^1];
}
}
10 changes: 10 additions & 0 deletions src/ConsumeConsumeBclMemory/ConsumeConsumeBclMemory.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<NoWarn>$(NoWarn);PolyfillTargetsForNuget</NoWarn>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT'">net461;net462;net47;net471;net472;net48;net481;net6.0-windows</TargetFrameworks>
<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>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\ConsumeBclMemory\ConsumeBclMemory.csproj" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<PackageVersion Include="ProjectDefaults" Version="1.0.147" />
<PackageVersion Include="System.Memory" Version="4.6.0" />
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
<PackageVersion Include="Microsoft.Bcl.Memory" Version="9.0.1" />
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.6.0" />
<PackageVersion Include="System.ValueTuple" Version="4.5.0" />
<PackageVersion Include="System.Runtime" Version="4.3.1" />
Expand Down
12 changes: 12 additions & 0 deletions src/Polyfill.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Polyfill/IndexRange/Index.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// <auto-generated />
#pragma warning disable

#if FeatureValueTuple
#if FeatureValueTuple && !RefsBclMemory
#if NET46X || NET47X || NET48X || NETSTANDARD2_0 || NETCOREAPP2X

namespace System;
Expand Down
2 changes: 1 addition & 1 deletion src/Polyfill/IndexRange/Range.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// <auto-generated />
#pragma warning disable

#if FeatureValueTuple
#if FeatureValueTuple && !RefsBclMemory
#if NET46X || NET47X || NET48X || NETSTANDARD2_0 || NETCOREAPP2X

namespace System;
Expand Down
3 changes: 3 additions & 0 deletions src/Polyfill/Polyfill.targets
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ For example:
<DefineConstants
Condition="@(ResolvedCompileFileDefinitions->AnyHaveMetadataValue('NuGetPackageId', 'System.ValueTuple'))">$(DefineConstants);FeatureValueTuple</DefineConstants>

<DefineConstants
Condition="@(ResolvedCompileFileDefinitions->AnyHaveMetadataValue('NuGetPackageId', 'Microsoft.Bcl.Memory'))">$(DefineConstants);RefsBclMemory</DefineConstants>

<MemoryVersion>@(ResolvedCompileFileDefinitions->WithMetadataValue('NuGetPackageId', 'System.Memory')->Metadata('NuGetPackageVersion'))</MemoryVersion>

<DefineConstants
Expand Down

0 comments on commit 06a9ef6

Please sign in to comment.