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

Feature : Add Net 8.0 #347

Merged
merged 1 commit into from
Jan 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 7 additions & 7 deletions src/Directory.build.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@
</PropertyGroup>

<ItemGroup Condition="'$(IsTestProject)' != 'true'">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
</ItemGroup>

<ItemGroup Condition="'$(IsTestProject)' == 'true'">
<PackageReference Include="ReactiveUI.Testing" Version="19.*" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.runner.console" Version="2.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="xunit.runner.console" Version="2.6.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4" />
<PackageReference Include="Xunit.StaFact" Version="1.1.11" />
<PackageReference Include="Verify.Xunit" Version="22.1.4" />
<PackageReference Include="Verify.Xunit" Version="22.5.0" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="PublicApiGenerator" Version="11.0.0" />
<PackageReference Include="coverlet.msbuild" Version="6.0.0" PrivateAssets="All" />
Expand All @@ -52,7 +52,7 @@
<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.133" PrivateAssets="all" />
<PackageReference Include="stylecop.analyzers" Version="1.2.0-beta.507" PrivateAssets="all" />
<PackageReference Include="Roslynator.Analyzers" Version="4.6.1" PrivateAssets="All" />
<PackageReference Include="Roslynator.Analyzers" Version="4.6.2" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 0 additions & 3 deletions src/Directory.build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
<PropertyGroup Condition="$(TargetFramework.StartsWith('net4'))">
<DefineConstants>$(DefineConstants);NET_45;XAML</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith('uap'))">
<DefineConstants>$(DefineConstants);NETFX_CORE;XAML;WINDOWS_UWP</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith('Xamarin.iOS'))">
<DefineConstants>$(DefineConstants);MONO;UIKIT;COCOA</DefineConstants>
</PropertyGroup>
Expand Down
48 changes: 0 additions & 48 deletions src/Fusillade.Tests/API/ApiApprovalBase.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v7.0", FrameworkDisplayName=".NET 7.0")]
namespace Fusillade
{
public interface IRequestCache
{
System.Threading.Tasks.Task<byte[]> Fetch(System.Net.Http.HttpRequestMessage request, string key, System.Threading.CancellationToken ct);
System.Threading.Tasks.Task Save(System.Net.Http.HttpRequestMessage request, System.Net.Http.HttpResponseMessage response, string key, System.Threading.CancellationToken ct);
}
public abstract class LimitingHttpMessageHandler : System.Net.Http.DelegatingHandler
{
protected LimitingHttpMessageHandler() { }
protected LimitingHttpMessageHandler(System.Net.Http.HttpMessageHandler innerHandler) { }
public abstract void ResetLimit(long? maxBytesToRead = default);
}
public static class NetCache
{
public static System.Net.Http.HttpMessageHandler Background { get; set; }
public static System.Net.Http.HttpMessageHandler Offline { get; set; }
public static Punchclock.OperationQueue OperationQueue { get; set; }
public static Fusillade.IRequestCache? RequestCache { get; set; }
public static Fusillade.LimitingHttpMessageHandler Speculative { get; set; }
public static System.Net.Http.HttpMessageHandler UserInitiated { get; set; }
}
public class OfflineHttpMessageHandler : System.Net.Http.HttpMessageHandler
{
public OfflineHttpMessageHandler(System.Func<System.Net.Http.HttpRequestMessage, string, System.Threading.CancellationToken, System.Threading.Tasks.Task<byte[]>>? retrieveBodyFunc) { }
protected override System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) { }
}
public enum Priority
{
Explicit = 0,
Speculative = 10,
Background = 20,
UserInitiated = 100,
}
public class RateLimitedHttpMessageHandler : Fusillade.LimitingHttpMessageHandler
{
public RateLimitedHttpMessageHandler(System.Net.Http.HttpMessageHandler handler, Fusillade.Priority basePriority, int priority = 0, long? maxBytesToRead = default, Punchclock.OperationQueue? opQueue = null, System.Func<System.Net.Http.HttpRequestMessage, System.Net.Http.HttpResponseMessage, string, System.Threading.CancellationToken, System.Threading.Tasks.Task>? cacheResultFunc = null) { }
public override void ResetLimit(long? maxBytesToRead = default) { }
protected override System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) { }
public static string UniqueKeyForRequest(System.Net.Http.HttpRequestMessage request) { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName=".NET 8.0")]
namespace Fusillade
{
public interface IRequestCache
{
System.Threading.Tasks.Task<byte[]> Fetch(System.Net.Http.HttpRequestMessage request, string key, System.Threading.CancellationToken ct);
System.Threading.Tasks.Task Save(System.Net.Http.HttpRequestMessage request, System.Net.Http.HttpResponseMessage response, string key, System.Threading.CancellationToken ct);
}
public abstract class LimitingHttpMessageHandler : System.Net.Http.DelegatingHandler
{
protected LimitingHttpMessageHandler() { }
protected LimitingHttpMessageHandler(System.Net.Http.HttpMessageHandler innerHandler) { }
public abstract void ResetLimit(long? maxBytesToRead = default);
}
public static class NetCache
{
public static System.Net.Http.HttpMessageHandler Background { get; set; }
public static System.Net.Http.HttpMessageHandler Offline { get; set; }
public static Punchclock.OperationQueue OperationQueue { get; set; }
public static Fusillade.IRequestCache? RequestCache { get; set; }
public static Fusillade.LimitingHttpMessageHandler Speculative { get; set; }
public static System.Net.Http.HttpMessageHandler UserInitiated { get; set; }
}
public class OfflineHttpMessageHandler : System.Net.Http.HttpMessageHandler
{
public OfflineHttpMessageHandler(System.Func<System.Net.Http.HttpRequestMessage, string, System.Threading.CancellationToken, System.Threading.Tasks.Task<byte[]>>? retrieveBodyFunc) { }
protected override System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) { }
}
public enum Priority
{
Explicit = 0,
Speculative = 10,
Background = 20,
UserInitiated = 100,
}
public class RateLimitedHttpMessageHandler : Fusillade.LimitingHttpMessageHandler
{
public RateLimitedHttpMessageHandler(System.Net.Http.HttpMessageHandler handler, Fusillade.Priority basePriority, int priority = 0, long? maxBytesToRead = default, Punchclock.OperationQueue? opQueue = null, System.Func<System.Net.Http.HttpRequestMessage, System.Net.Http.HttpResponseMessage, string, System.Threading.CancellationToken, System.Threading.Tasks.Task>? cacheResultFunc = null) { }
public override void ResetLimit(long? maxBytesToRead = default) { }
protected override System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) { }
public static string UniqueKeyForRequest(System.Net.Http.HttpRequestMessage request) { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ namespace Fusillade
}
public abstract class LimitingHttpMessageHandler : System.Net.Http.DelegatingHandler
{
public LimitingHttpMessageHandler() { }
public LimitingHttpMessageHandler(System.Net.Http.HttpMessageHandler innerHandler) { }
protected LimitingHttpMessageHandler() { }
protected LimitingHttpMessageHandler(System.Net.Http.HttpMessageHandler innerHandler) { }
public abstract void ResetLimit(long? maxBytesToRead = default);
}
public static class NetCache
Expand All @@ -28,10 +28,10 @@ namespace Fusillade
}
public enum Priority
{
Explicit = 0,
Speculative = 10,
UserInitiated = 100,
Background = 20,
Explicit = 0,
UserInitiated = 100,
}
public class RateLimitedHttpMessageHandler : Fusillade.LimitingHttpMessageHandler
{
Expand Down
9 changes: 4 additions & 5 deletions src/Fusillade.Tests/API/ApiApprovalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// See the LICENSE file in the project root for full license information.

using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using VerifyXunit;
using Xunit;

Expand All @@ -14,15 +15,13 @@ namespace Fusillade.APITests
/// </summary>
[ExcludeFromCodeCoverage]
[UsesVerify]
public class ApiApprovalTests : ApiApprovalBase
public class ApiApprovalTests
{
/// <summary>
/// Tests to make sure the akavache project is approved.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
[Fact]
public void FusilladeTests()
{
CheckApproval(typeof(OfflineHttpMessageHandler).Assembly);
}
public Task FusilladeTests() => typeof(OfflineHttpMessageHandler).Assembly.CheckApproval(["Fusillade"]);
}
}
43 changes: 43 additions & 0 deletions src/Fusillade.Tests/API/ApiExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (c) 2021 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using PublicApiGenerator;
using VerifyXunit;

namespace Fusillade.APITests;

/// <summary>
/// A helper for doing API approvals.
/// </summary>
public static class ApiExtensions
{
/// <summary>
/// Checks to make sure the API is approved.
/// </summary>
/// <param name="assembly">The assembly that is being checked.</param>
/// <param name="namespaces">The namespaces.</param>
/// <param name="filePath">The caller file path.</param>
/// <returns>
/// A Task.
/// </returns>
public static async Task CheckApproval(this Assembly assembly, string[] namespaces, [CallerFilePath] string filePath = "")
{
var generatorOptions = new ApiGeneratorOptions { AllowNamespacePrefixes = namespaces };
var apiText = assembly.GeneratePublicApi(generatorOptions);
var result = await Verifier.Verify(apiText, null, filePath)
.UniqueForRuntimeAndVersion()
.ScrubEmptyLines()
.ScrubLines(l =>
l.StartsWith("[assembly: AssemblyVersion(", StringComparison.InvariantCulture) ||
l.StartsWith("[assembly: AssemblyFileVersion(", StringComparison.InvariantCulture) ||
l.StartsWith("[assembly: AssemblyInformationalVersion(", StringComparison.InvariantCulture) ||
l.StartsWith("[assembly: System.Reflection.AssemblyMetadata(", StringComparison.InvariantCulture));
}
}
2 changes: 1 addition & 1 deletion src/Fusillade.Tests/Fusillade.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net472</TargetFrameworks>
<NoWarn>$(NoWarn);1591;CA1707;SA1633</NoWarn>
<IsPackable>false</IsPackable>
Expand Down
6 changes: 2 additions & 4 deletions src/Fusillade.Tests/Http/BaseHttpSchedulerSharedTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ namespace Fusillade.Tests
public class BaseHttpSchedulerSharedTests : HttpSchedulerSharedTests
{
/// <inheritdoc/>
protected override LimitingHttpMessageHandler CreateFixture(HttpMessageHandler innerHandler)
{
return new RateLimitedHttpMessageHandler(innerHandler, Priority.UserInitiated, opQueue: new OperationQueue(4));
}
protected override LimitingHttpMessageHandler CreateFixture(HttpMessageHandler innerHandler) =>
new RateLimitedHttpMessageHandler(innerHandler, Priority.UserInitiated, opQueue: new OperationQueue(4));
}
}
19 changes: 6 additions & 13 deletions src/Fusillade.Tests/Http/TestHttpMessageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,12 @@ namespace Fusillade.Tests
/// <summary>
/// Tests the main http scheduler.
/// </summary>
public class TestHttpMessageHandler : HttpMessageHandler
/// <remarks>
/// Initializes a new instance of the <see cref="TestHttpMessageHandler"/> class.
/// </remarks>
/// <param name="createResult">Creates a http response.</param>
public class TestHttpMessageHandler(Func<HttpRequestMessage, IObservable<HttpResponseMessage>> createResult) : HttpMessageHandler
{
private readonly Func<HttpRequestMessage, IObservable<HttpResponseMessage>> _block;

/// <summary>
/// Initializes a new instance of the <see cref="TestHttpMessageHandler"/> class.
/// </summary>
/// <param name="createResult">Creates a http response.</param>
public TestHttpMessageHandler(Func<HttpRequestMessage, IObservable<HttpResponseMessage>> createResult)
{
_block = createResult;
}

/// <inheritdoc/>
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
Expand All @@ -36,7 +29,7 @@ protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage reques
return Observable.Throw<HttpResponseMessage>(new OperationCanceledException()).ToTask();
}

return _block(request).ToTask(cancellationToken);
return createResult(request).ToTask(cancellationToken);
}
}
}
2 changes: 1 addition & 1 deletion src/Fusillade/Fusillade.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
<PackageId>fusillade</PackageId>
<Nullable>enable</Nullable>
<WarningsAsErrors>CS8625;CS8604;CS8600;CS8614;CS8603;CS8618;CS8619</WarningsAsErrors>
Expand Down
2 changes: 1 addition & 1 deletion src/global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.400",
"version": "8.0.10",
"rollForward": "latestMinor"
},
"msbuild-sdks": {
Expand Down
Loading