Skip to content

Commit 0205063

Browse files
authored
MemoryCache: use net9.cs file rather than #if for TFM limits (#112786)
1 parent 6dcd8d1 commit 0205063

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

src/libraries/Microsoft.Extensions.Caching.Memory/ref/Microsoft.Extensions.Caching.Memory.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@ protected virtual void Dispose(bool disposing) { }
3737
public Microsoft.Extensions.Caching.Memory.MemoryCacheStatistics? GetCurrentStatistics() { throw null; }
3838
public void Remove(object key) { }
3939
public bool TryGetValue(object key, out object? result) { throw null; }
40-
41-
#if NET9_0_OR_GREATER
42-
[System.Runtime.CompilerServices.OverloadResolutionPriority(1)]
43-
public bool TryGetValue(System.ReadOnlySpan<char> key, out object? value) { throw null; }
44-
[System.Runtime.CompilerServices.OverloadResolutionPriority(1)]
45-
public bool TryGetValue<TItem>(System.ReadOnlySpan<char> key, out TItem? value) { throw null; }
46-
#endif
4740
}
4841
public partial class MemoryCacheOptions : Microsoft.Extensions.Options.IOptions<Microsoft.Extensions.Caching.Memory.MemoryCacheOptions>
4942
{

src/libraries/Microsoft.Extensions.Caching.Memory/ref/Microsoft.Extensions.Caching.Memory.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFrameworks>$(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum)</TargetFrameworks>
44
</PropertyGroup>
@@ -7,6 +7,10 @@
77
<Compile Include="Microsoft.Extensions.Caching.Memory.cs" />
88
</ItemGroup>
99

10+
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net9.0'))">
11+
<Compile Include="Microsoft.Extensions.Caching.Memory.net9.cs" />
12+
</ItemGroup>
13+
1014
<ItemGroup>
1115
<ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Extensions.Caching.Abstractions\ref\Microsoft.Extensions.Caching.Abstractions.csproj" />
1216
<ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Extensions.DependencyInjection.Abstractions\ref\Microsoft.Extensions.DependencyInjection.Abstractions.csproj" />
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// ------------------------------------------------------------------------------
4+
// Changes to this file must follow the https://aka.ms/api-review process.
5+
// ------------------------------------------------------------------------------
6+
7+
namespace Microsoft.Extensions.Caching.Memory
8+
{
9+
public partial class MemoryCache
10+
{
11+
[System.Runtime.CompilerServices.OverloadResolutionPriority(1)]
12+
public bool TryGetValue(System.ReadOnlySpan<char> key, out object? value) { throw null; }
13+
[System.Runtime.CompilerServices.OverloadResolutionPriority(1)]
14+
public bool TryGetValue<TItem>(System.ReadOnlySpan<char> key, out TItem? value) { throw null; }
15+
}
16+
}

0 commit comments

Comments
 (0)