Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update target frameworks #662

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<LangVersion>latest</LangVersion>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<!-- https://stackoverflow.com/a/59916801/131345 -->
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
Expand Down
2 changes: 1 addition & 1 deletion BitFaster.Caching.Benchmarks/DataStructureBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace BitFaster.Caching.Benchmarks
#if Windows
[SimpleJob(RuntimeMoniker.Net48)]
#endif
[SimpleJob(RuntimeMoniker.Net60)]
[SimpleJob(RuntimeMoniker.Net90)]
[MemoryDiagnoser(displayGenColumns: false)]
public class DataStructureBenchmarks
{
Expand Down
2 changes: 1 addition & 1 deletion BitFaster.Caching.Benchmarks/DisposerBench.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace BitFaster.Caching.Benchmarks
[DisassemblyDiagnoser(printSource: true, maxDepth: 3)]
[SimpleJob(RuntimeMoniker.Net48)]
#endif
[SimpleJob(RuntimeMoniker.Net60)]
[SimpleJob(RuntimeMoniker.Net90)]
[MemoryDiagnoser(displayGenColumns: false)]
[HideColumns("Job", "Median", "RatioSD", "Alloc Ratio")]
public class DisposerBench
Expand Down
4 changes: 2 additions & 2 deletions BitFaster.Caching.Benchmarks/DrainBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace BitFaster.Caching.Benchmarks
[DisassemblyDiagnoser(printSource: true, maxDepth: 3)]
[SimpleJob(RuntimeMoniker.Net48)]
#endif
[SimpleJob(RuntimeMoniker.Net60)]
[SimpleJob(RuntimeMoniker.Net90)]
[HideColumns("Job", "Median", "RatioSD", "Alloc Ratio")]
public class DrainBenchmarks
{
Expand Down Expand Up @@ -187,7 +187,7 @@ public void Add()
public void DrainArray()
{
Add();
#if NETCOREAPP3_1_OR_GREATER
#if NET
Joy-less marked this conversation as resolved.
Show resolved Hide resolved
buffer.DrainTo(output.AsSpan());
#else
buffer.DrainTo(new ArraySegment<string>(output));
Expand Down
8 changes: 4 additions & 4 deletions BitFaster.Caching.Benchmarks/Lfu/CmSketchFlat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Text;
using System.Threading.Tasks;

#if NETCOREAPP3_1_OR_GREATER
#if NET
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
#endif
Expand Down Expand Up @@ -53,7 +53,7 @@ public CmSketchFlat(long maximumSize, IEqualityComparer<T> comparer)
/// <returns>The estimated frequency of the value.</returns>
public int EstimateFrequency(T value)
{
#if !NETCOREAPP3_1_OR_GREATER
#if !NET
return EstimateFrequencyStd(value);
#else

Expand All @@ -76,7 +76,7 @@ public int EstimateFrequency(T value)
/// <param name="value">The value.</param>
public void Increment(T value)
{
#if !NETCOREAPP3_1_OR_GREATER
#if !NET
IncrementStd(value);
#else

Expand Down Expand Up @@ -207,7 +207,7 @@ private int Spread(int x)
return (int)((y >> 16) ^ y);
}

#if NETCOREAPP3_1_OR_GREATER
#if NET
private unsafe int EstimateFrequencyAvx(T value)
{
int hash = Spread(comparer.GetHashCode(value));
Expand Down
17 changes: 8 additions & 9 deletions BitFaster.Caching.Benchmarks/Lfu/CmSketchNoPin.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;


#if NET6_0_OR_GREATER
#if NET
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.Arm;
using System.Runtime.Intrinsics.X86;
Expand Down Expand Up @@ -57,7 +56,7 @@ public CmSketchNoPin(long maximumSize, IEqualityComparer<T> comparer)
/// <returns>The estimated frequency of the value.</returns>
public int EstimateFrequency(T value)
{
#if NET48
#if NETSTANDARD
Joy-less marked this conversation as resolved.
Show resolved Hide resolved
return EstimateFrequencyStd(value);
#else

Expand All @@ -67,7 +66,7 @@ public int EstimateFrequency(T value)
{
return EstimateFrequencyAvx(value);
}
#if NET6_0_OR_GREATER
#if NET
else if (isa.IsArm64Supported)
{
return EstimateFrequencyArm(value);
Expand All @@ -86,7 +85,7 @@ public int EstimateFrequency(T value)
/// <param name="value">The value.</param>
public void Increment(T value)
{
#if NET48
#if NETSTANDARD
Joy-less marked this conversation as resolved.
Show resolved Hide resolved
IncrementStd(value);
#else

Expand All @@ -96,7 +95,7 @@ public void Increment(T value)
{
IncrementAvx(value);
}
#if NET6_0_OR_GREATER
#if NET
else if (isa.IsArm64Supported)
{
IncrementArm(value);
Expand Down Expand Up @@ -233,7 +232,7 @@ private void Reset()
size = (size - (count0 >> 2)) >> 1;
}

#if NET6_0_OR_GREATER
#if NET
private unsafe int EstimateFrequencyAvx(T value)
{
int blockHash = Spread(comparer.GetHashCode(value));
Expand Down Expand Up @@ -267,7 +266,7 @@ private unsafe int EstimateFrequencyAvx(T value)
.AsUInt16();

// set the zeroed high parts of the long value to ushort.Max
#if NET6_0
#if NET
count = Avx2.Blend(count, Vector128<ushort>.AllBitsSet, 0b10101010);
#else
count = Avx2.Blend(count, Vector128.Create(ushort.MaxValue), 0b10101010);
Joy-less marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -333,7 +332,7 @@ private unsafe void IncrementAvx(T value)
}
#endif

#if NET6_0_OR_GREATER
#if NET
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private unsafe void IncrementArm(T value)
{
Expand Down
2 changes: 1 addition & 1 deletion BitFaster.Caching.Benchmarks/TimeBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public int EnvironmentTickCount()
[Benchmark()]
public long EnvironmentTickCount64()
{
#if NETCOREAPP3_0_OR_GREATER
#if NET
return Environment.TickCount64;
#else
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ServerGarbageCollection>true</ServerGarbageCollection>
<ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>
<RetainVMGarbageCollection>true</RetainVMGarbageCollection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<SignAssembly>False</SignAssembly>
<Version>2.0.0</Version>
<ServerGarbageCollection>true</ServerGarbageCollection>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks>
<LangVersion>9.0</LangVersion>
<TargetFrameworks>net9.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion BitFaster.Caching.UnitTests.Std/DurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void SinceEpoch()
// On .NET Standard, only windows uses TickCount64
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Duration.SinceEpoch().raw.Should().BeCloseTo(Duration.GetTickCount64(), 15);
Duration.SinceEpoch().raw.Should().BeCloseTo(Environment.TickCount64, 15);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ public void WhenRemovedEventHandlerIsRegisteredItIsFired()
this.removedItems.First().Key.Should().Be(1);
}

// backcompat: remove conditional compile
#if NETCOREAPP3_0_OR_GREATER
// backcompat: remove conditional compile
#if NET
[Fact]
public void WhenUpdatedEventHandlerIsRegisteredItIsFired()
{
Expand Down Expand Up @@ -258,8 +258,8 @@ public async Task WhenFactoryThrowsEmptyKeyIsNotEnumerable()
cache.Keys.Count().Should().Be(0);
}

// backcompat: remove conditional compile
#if NETCOREAPP3_0_OR_GREATER
// backcompat: remove conditional compile
#if NET
[Fact]
public void WhenRemovedValueIsReturned()
{
Expand Down
4 changes: 2 additions & 2 deletions BitFaster.Caching.UnitTests/Atomic/AtomicFactoryCacheTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ public void WhenRemovedEventHandlerIsRegisteredItIsFired()
this.removedItems.First().Key.Should().Be(1);
}

// backcompat: remove conditional compile
#if NETCOREAPP3_0_OR_GREATER
// backcompat: remove conditional compile
#if NET
[Fact]
public void WhenRemovedValueIsReturned()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net48;netcoreapp3.1;net6.0</TargetFrameworks>
<LangVersion>9.0</LangVersion>
<TargetFrameworks>net48;net8.0;net9.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void WhenBufferEmptyDrainReturnsZero()
buffer.DrainTo(output).Should().Be(0);
}

#if NETCOREAPP3_0_OR_GREATER
#if NET
[Fact]
public void WhenBufferContainsItemsDrainArrayTakesItems()
{
Expand Down
4 changes: 2 additions & 2 deletions BitFaster.Caching.UnitTests/CacheEventProxyBaseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void WhenTwoRemovedEventHandlersAddedThenOneRemovedEventIsFired()
}

// backcompat: remove conditional compile
#if NETCOREAPP3_0_OR_GREATER
#if NET
[Fact]
public void WheUpdatedEventHandlerIsRegisteredItIsFired()
{
Expand Down Expand Up @@ -155,7 +155,7 @@ public void WhenUpdatedEventHandlerIsRegisteredAndProxyUsesDefaultUpdateTranslat

this.testCacheEvents.FireUpdated(1, new AtomicFactory<int, int>(2), new AtomicFactory<int, int>(3));

#if NETCOREAPP3_0_OR_GREATER
#if NET
this.updatedItems.First().Key.Should().Be(1);
#else
this.updatedItems.Should().BeEmpty();
Expand Down
2 changes: 1 addition & 1 deletion BitFaster.Caching.UnitTests/CacheEventsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace BitFaster.Caching.UnitTests
{
// backcompat: remove
#if NETCOREAPP3_1_OR_GREATER
#if NET
public class CacheEventsTests
{
[Fact]
Expand Down
2 changes: 1 addition & 1 deletion BitFaster.Caching.UnitTests/CacheMetricsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace BitFaster.Caching.UnitTests
{
// backcompat: remove
#if NETCOREAPP3_1_OR_GREATER
#if NET
public class CacheMetricsTests
{
[Fact]
Expand Down
2 changes: 1 addition & 1 deletion BitFaster.Caching.UnitTests/CacheTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace BitFaster.Caching.UnitTests
public class CacheTests
{
// backcompat: remove conditional compile
#if NETCOREAPP3_0_OR_GREATER
#if NET
[Fact]
public void WhenCacheInterfaceDefaultGetOrAddFallback()
{
Expand Down
8 changes: 4 additions & 4 deletions BitFaster.Caching.UnitTests/DurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public DurationTests(ITestOutputHelper testOutputHelper)
[Fact]
public void SinceEpoch()
{
#if NETCOREAPP3_0_OR_GREATER
#if NET
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
// eps is 1/200 of a second
Expand All @@ -36,7 +36,7 @@ public void SinceEpoch()
#else
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Duration.SinceEpoch().raw.Should().BeCloseTo(Duration.GetTickCount64(), 15);
Duration.SinceEpoch().raw.Should().BeCloseTo(Environment.TickCount, 15);
}
else
{
Expand All @@ -50,7 +50,7 @@ public void SinceEpoch()
[Fact]
public void ToTimeSpan()
{
#if NETCOREAPP3_0_OR_GREATER
#if NET
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
new Duration(100).ToTimeSpan().Should().BeCloseTo(new TimeSpan(100), TimeSpan.FromMilliseconds(50));
Expand All @@ -75,7 +75,7 @@ public void ToTimeSpan()
[Fact]
public void FromTimeSpan()
{
#if NETCOREAPP3_0_OR_GREATER
#if NET
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
Duration.FromTimeSpan(TimeSpan.FromSeconds(1)).raw
Expand Down
12 changes: 2 additions & 10 deletions BitFaster.Caching.UnitTests/Intrinsics.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#if NETCOREAPP3_1_OR_GREATER
#if NET
using System.Runtime.Intrinsics.X86;
#endif
#if NET6_0_OR_GREATER
using System.Runtime.Intrinsics.Arm;
#endif

Expand All @@ -13,15 +11,9 @@ public static class Intrinsics
{
public static void SkipAvxIfNotSupported<I>()
{
#if NETCOREAPP3_1_OR_GREATER
#if NET6_0_OR_GREATER
#if NET
// when we are trying to test Avx2/Arm64, skip the test if it's not supported
Skip.If(typeof(I) == typeof(DetectIsa) && !(Avx2.IsSupported || AdvSimd.Arm64.IsSupported));
#else
// when we are trying to test Avx2, skip the test if it's not supported
Skip.If(typeof(I) == typeof(DetectIsa) && !Avx2.IsSupported);
#endif

#else
Skip.If(true);
#endif
Expand Down
6 changes: 3 additions & 3 deletions BitFaster.Caching.UnitTests/Lfu/ConcurrentLfuCoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void WhenKeyIsRequestedItIsCreatedAndCached()
valueFactory.timesCalled.Should().Be(1);
result1.Should().Be(result2);
}
#if NETCOREAPP3_0_OR_GREATER
#if NET
[Fact]
public void WhenKeyIsRequestedWithArgItIsCreatedAndCached()
{
Expand All @@ -63,7 +63,7 @@ public async Task WhenKeyIsRequesteItIsCreatedAndCachedAsync()
result1.Should().Be(result2);
}

#if NETCOREAPP3_0_OR_GREATER
#if NET
[Fact]
public async Task WhenKeyIsRequestedWithArgItIsCreatedAndCachedAsync()
{
Expand Down Expand Up @@ -105,7 +105,7 @@ public void WhenKeyExistsTryRemoveRemovesItem()
lfu.TryGet(1, out _).Should().BeFalse();
}

#if NETCOREAPP3_0_OR_GREATER
#if NET
[Fact]
public void WhenKeyExistsTryRemoveReturnsValue()
{
Expand Down
2 changes: 1 addition & 1 deletion BitFaster.Caching.UnitTests/Lfu/ConcurrentLfuTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ public void WhenWriteBufferIsFullAddDoesMaintenance()
}

// backcompat: remove conditional compile
#if NETCOREAPP3_0_OR_GREATER
#if NET
[Fact]
public void WhenWriteBufferIsFullUpdatesAreDropped()
{
Expand Down
Loading
Loading