-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
653aed1
commit 9079f4b
Showing
13 changed files
with
155 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
43 changes: 43 additions & 0 deletions
43
src/Fusillade.Tests/API/ApiApprovalTests.FusilladeTests.DotNet7_0.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { } | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/Fusillade.Tests/API/ApiApprovalTests.FusilladeTests.DotNet8_0.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": { | ||
|