Housekeeping Add net6.0 target (#215)
* Housekeeping Add net6.0 target * Update ci-build.yml * remove duplicate packages * Update Directory.build.props cleanup * Update Directory.build.props * move references to Test project * Update API tests
This commit is contained in:
Родитель
f098460205
Коммит
5abb3f4a7f
|
@ -8,66 +8,17 @@ on:
|
|||
branches: [ main ]
|
||||
|
||||
env:
|
||||
configuration: Release
|
||||
productNamespacePrefix: "Fusillade"
|
||||
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-latest
|
||||
outputs:
|
||||
nbgv: ${{ steps.nbgv.outputs.SemVer2 }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install .NET Core
|
||||
uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: 3.1.x
|
||||
|
||||
- name: NBGV
|
||||
id: nbgv
|
||||
uses: dotnet/nbgv@master
|
||||
with:
|
||||
setAllVars: true
|
||||
|
||||
- name: NuGet Restore
|
||||
run: dotnet restore
|
||||
working-directory: src
|
||||
|
||||
- name: Add MSBuild to PATH
|
||||
uses: microsoft/setup-msbuild@v1
|
||||
|
||||
- name: Build
|
||||
run: msbuild /t:build,pack /maxcpucount /p:NoPackageAnalysis=true /verbosity:minimal /p:Configuration=${{ env.configuration }}
|
||||
working-directory: src
|
||||
|
||||
- name: Run Unit Tests and Generate Coverage
|
||||
uses: glennawatson/coverlet-msbuild@v1
|
||||
with:
|
||||
project-files: '**/*Tests*.csproj'
|
||||
no-build: true
|
||||
exclude-filter: '[${{env.productNamespacePrefix}}.*.Tests.*]*'
|
||||
include-filter: '[${{env.productNamespacePrefix}}*]*'
|
||||
output-format: cobertura
|
||||
output: '../../artifacts/'
|
||||
configuration: ${{ env.configuration }}
|
||||
|
||||
- name: Upload Code Coverage
|
||||
shell: bash
|
||||
run: |
|
||||
echo $PWD
|
||||
bash <(curl -s https://codecov.io/bash) -X gcov -X coveragepy -t ${{ env.CODECOV_TOKEN }} -s '$PWD/artifacts' -f '*.xml'
|
||||
env:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
|
||||
- name: Create NuGet Artifacts
|
||||
uses: actions/upload-artifact@master
|
||||
with:
|
||||
name: nuget
|
||||
path: '**/*.nupkg'
|
||||
uses: reactiveui/actions-common/.github/workflows/workflow-common-setup-and-build.yml@main
|
||||
with:
|
||||
configuration: Release
|
||||
productNamespacePrefix: "Fusillade"
|
||||
useVisualStudioPreview: false
|
||||
useMauiCheckDotNetTool: false
|
||||
solutionFile: "Fusillade.sln"
|
||||
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
|
|
|
@ -239,3 +239,4 @@ tools/
|
|||
artifacts/
|
||||
src/CommonAssemblyInfo.cs
|
||||
src/ReactiveUI.Events/Events_*.cs
|
||||
src/Fusillade.Tests/API/ApiApprovalTests.*.received.txt
|
||||
|
|
|
@ -1,61 +1,43 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<NoWarn>$(NoWarn);VSX1000</NoWarn>
|
||||
<Platform>AnyCPU</Platform>
|
||||
<IsTestProject>$(MSBuildProjectName.Contains('Tests'))</IsTestProject>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)analyzers.ruleset</CodeAnalysisRuleSet>
|
||||
<IsTestProject>$(MSBuildProjectName.Contains('Tests'))</IsTestProject>
|
||||
<DebugType>Embedded</DebugType>
|
||||
<!-- Optional: Publish the repository URL in the built .nupkg (in the NuSpec <Repository> element) -->
|
||||
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
||||
<!-- Optional: Embed source files that are not tracked by the source control manager in the PDB -->
|
||||
<EmbedUntrackedSources>true</EmbedUntrackedSources>
|
||||
<!-- Optional: Include PDB in the built .nupkg -->
|
||||
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
|
||||
<!-- disable sourcelink on mono, to workaround https://github.com/dotnet/sourcelink/issues/155 -->
|
||||
<PackageIconUrl>https://raw.githubusercontent.com/reactiveui/styleguide/master/logo_fusillade/main.png?raw=true</PackageIconUrl>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="$(IsTestProject)">
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<NoWarn>$(NoWarn);VSX1000</NoWarn>
|
||||
<Platform>AnyCPU</Platform>
|
||||
<IsTestProject>$(MSBuildProjectName.Contains('Tests'))</IsTestProject>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)analyzers.ruleset</CodeAnalysisRuleSet>
|
||||
<DebugType>Embedded</DebugType>
|
||||
<Authors>.NET Foundation and Contributors</Authors>
|
||||
<Copyright>Copyright (c) .NET Foundation and Contributors</Copyright>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<!-- Optional: Publish the repository URL in the built .nupkg (in the NuSpec <Repository> element) -->
|
||||
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
||||
<!-- Optional: Embed source files that are not tracked by the source control manager in the PDB -->
|
||||
<EmbedUntrackedSources>true</EmbedUntrackedSources>
|
||||
<!-- Optional: Include PDB in the built .nupkg -->
|
||||
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
|
||||
<!-- disable sourcelink on mono, to workaround https://github.com/dotnet/sourcelink/issues/155 -->
|
||||
<PackageIconUrl>https://raw.githubusercontent.com/reactiveui/styleguide/master/logo_fusillade/main.png?raw=true</PackageIconUrl>
|
||||
<EnableNETAnalyzers>True</EnableNETAnalyzers>
|
||||
<AnalysisLevel>latest</AnalysisLevel>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="$(IsTestProject)">
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.console" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
|
||||
<PackageReference Include="Xunit.StaFact" Version="1.0.37" />
|
||||
<PackageReference Include="Microsoft.Reactive.Testing" Version="5.*" />
|
||||
<PackageReference Include="PublicApiGenerator" Version="10.2.0" />
|
||||
<PackageReference Include="coverlet.msbuild" Version="3.1.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="DiffEngine" Version="8.5.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(IsTestProject)' != 'true'">
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="$(MSBuildThisFileDirectory)..\LICENSE" Pack="true" PackagePath="LICENSE" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Nerdbank.GitVersioning" Version="3.4.244" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="stylecop.analyzers" Version="1.2.0-beta.205" PrivateAssets="all" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.2" PrivateAssets="all" />
|
||||
<PackageReference Include="Roslynator.Analyzers" Version="3.3.0" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(IsTestProject)' != 'true'">
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="$(MSBuildThisFileDirectory)..\LICENSE" Pack="true" PackagePath="LICENSE" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Nerdbank.GitVersioning" Version="3.4.244" PrivateAssets="all" />
|
||||
<PackageReference Include="stylecop.analyzers" Version="1.2.0-beta.376" PrivateAssets="all" />
|
||||
<PackageReference Include="Roslynator.Analyzers" Version="3.3.0" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
// 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>
|
||||
/// Api Approval Base.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
[UsesVerify]
|
||||
public abstract class ApiApprovalBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Check Approval.
|
||||
/// </summary>
|
||||
/// <param name="assembly">The assembly.</param>
|
||||
/// <param name="filePath">The file path.</param>
|
||||
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
|
||||
protected static Task CheckApproval(Assembly assembly, [CallerFilePath] string? filePath = null)
|
||||
{
|
||||
if (filePath is null)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
var generatorOptions = new ApiGeneratorOptions { WhitelistedNamespacePrefixes = new[] { "Fusillade" } };
|
||||
var apiText = assembly.GeneratePublicApi(generatorOptions);
|
||||
return 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));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
[assembly: System.Runtime.Versioning.TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName="")]
|
||||
[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName="")]
|
||||
namespace Fusillade
|
||||
{
|
||||
public interface IRequestCache
|
|
@ -1,4 +1,4 @@
|
|||
[assembly: System.Runtime.Versioning.TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName="")]
|
||||
[assembly: System.Runtime.Versioning.TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName="")]
|
||||
namespace Fusillade
|
||||
{
|
||||
public interface IRequestCache
|
|
@ -1,43 +0,0 @@
|
|||
[assembly: System.Runtime.Versioning.TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName="")]
|
||||
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
|
||||
{
|
||||
public LimitingHttpMessageHandler() { }
|
||||
public 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
|
||||
{
|
||||
Speculative = 10,
|
||||
UserInitiated = 100,
|
||||
Background = 20,
|
||||
Explicit = 0,
|
||||
}
|
||||
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) { }
|
||||
}
|
||||
}
|
|
@ -3,24 +3,8 @@
|
|||
// 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.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
using Akavache.Sqlite3;
|
||||
|
||||
using DiffEngine;
|
||||
|
||||
using Fusillade;
|
||||
|
||||
using PublicApiGenerator;
|
||||
|
||||
using Splat;
|
||||
|
||||
using VerifyXunit;
|
||||
using Xunit;
|
||||
|
||||
namespace Fusillade.APITests
|
||||
|
@ -29,10 +13,9 @@ namespace Fusillade.APITests
|
|||
/// Tests for handling API approval.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ApiApprovalTests
|
||||
[UsesVerify]
|
||||
public class ApiApprovalTests : ApiApprovalBase
|
||||
{
|
||||
private static readonly Regex _removeCoverletSectionRegex = new Regex(@"^namespace Coverlet\.Core\.Instrumentation\.Tracker.*?^}", RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.Compiled);
|
||||
|
||||
/// <summary>
|
||||
/// Tests to make sure the akavache project is approved.
|
||||
/// </summary>
|
||||
|
@ -41,53 +24,5 @@ namespace Fusillade.APITests
|
|||
{
|
||||
CheckApproval(typeof(OfflineHttpMessageHandler).Assembly);
|
||||
}
|
||||
|
||||
private static void CheckApproval(Assembly assembly, [CallerMemberName] string memberName = null, [CallerFilePath] string filePath = null)
|
||||
{
|
||||
var targetFrameworkName = Assembly.GetExecutingAssembly().GetTargetFrameworkName();
|
||||
|
||||
var sourceDirectory = Path.GetDirectoryName(filePath);
|
||||
|
||||
var approvedFileName = Path.Combine(sourceDirectory, $"ApiApprovalTests.{memberName}.{targetFrameworkName}.approved.txt");
|
||||
var receivedFileName = Path.Combine(sourceDirectory, $"ApiApprovalTests.{memberName}.{targetFrameworkName}.received.txt");
|
||||
|
||||
if (!File.Exists(receivedFileName))
|
||||
{
|
||||
File.Create(receivedFileName).Close();
|
||||
}
|
||||
|
||||
if (!File.Exists(approvedFileName))
|
||||
{
|
||||
File.Create(approvedFileName).Close();
|
||||
}
|
||||
|
||||
var approvedPublicApi = File.ReadAllText(approvedFileName);
|
||||
|
||||
var generatorOptions = new ApiGeneratorOptions { WhitelistedNamespacePrefixes = new[] { "Akavache" } };
|
||||
var receivedPublicApi = Filter(assembly.GeneratePublicApi(generatorOptions));
|
||||
|
||||
if (!string.Equals(receivedPublicApi, approvedPublicApi, StringComparison.InvariantCulture))
|
||||
{
|
||||
File.WriteAllText(receivedFileName, receivedPublicApi);
|
||||
DiffRunner.Launch(receivedFileName, approvedFileName);
|
||||
}
|
||||
|
||||
Assert.Equal(approvedPublicApi, receivedPublicApi);
|
||||
}
|
||||
|
||||
private static string Filter(string text)
|
||||
{
|
||||
text = _removeCoverletSectionRegex.Replace(text, string.Empty);
|
||||
return string.Join(Environment.NewLine, text.Split(
|
||||
new[]
|
||||
{
|
||||
Environment.NewLine
|
||||
}, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Where(l =>
|
||||
!l.StartsWith("[assembly: AssemblyVersion(", StringComparison.InvariantCulture) &&
|
||||
!l.StartsWith("[assembly: AssemblyFileVersion(", StringComparison.InvariantCulture) &&
|
||||
!l.StartsWith("[assembly: AssemblyInformationalVersion(", StringComparison.InvariantCulture) &&
|
||||
!string.IsNullOrWhiteSpace(l)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,29 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
|
||||
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net461</TargetFrameworks>
|
||||
<NoWarn>$(NoWarn);1591;CA1707;SA1633</NoWarn>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<NoWarn>$(NoWarn);CA2000;CA1031;CA1307;CA1305</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net6.0</TargetFrameworks>
|
||||
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net462</TargetFrameworks>
|
||||
<NoWarn>$(NoWarn);1591;CA1707;SA1633</NoWarn>
|
||||
<IsPackable>false</IsPackable>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<NoWarn>$(NoWarn);CA2000;CA1031;CA1307;CA1305</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Fusillade\Fusillade.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Fusillade\Fusillade.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="akavache" Version="8.*" />
|
||||
<PackageReference Include="DynamicData" Version="7.*" />
|
||||
<PackageReference Include="ReactiveUI" Version="16.*" />
|
||||
<PackageReference Include="ReactiveUI.Testing" Version="16.*" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="akavache" Version="8.*" />
|
||||
<PackageReference Include="ReactiveUI.Testing" Version="17.*" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.console" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
|
||||
<PackageReference Include="Xunit.StaFact" Version="1.0.37" />
|
||||
<PackageReference Include="FluentAssertions" Version="6.2.0" />
|
||||
<PackageReference Include="Microsoft.Reactive.Testing" Version="5.0.0" />
|
||||
<PackageReference Include="PublicApiGenerator" Version="10.2.0" />
|
||||
<PackageReference Include="coverlet.msbuild" Version="3.1.0" PrivateAssets="All" />
|
||||
<PackageReference Include="Verify.Xunit" Version="14.10.1" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -42,7 +42,12 @@ namespace Fusillade.Tests.Http
|
|||
});
|
||||
|
||||
var contentResponses = new List<byte[]>();
|
||||
|
||||
#if NET462
|
||||
var fixture = new RateLimitedHttpMessageHandler(innerHandler, Priority.UserInitiated, cacheResultFunc: async (rq, re, key, ct) => contentResponses.Add(await re.Content.ReadAsByteArrayAsync().ConfigureAwait(false)));
|
||||
#else
|
||||
var fixture = new RateLimitedHttpMessageHandler(innerHandler, Priority.UserInitiated, cacheResultFunc: async (rq, re, key, ct) => contentResponses.Add(await re.Content.ReadAsByteArrayAsync(ct).ConfigureAwait(false)));
|
||||
#endif
|
||||
|
||||
var client = new HttpClient(fixture);
|
||||
var str = await client.GetStringAsync(new Uri("http://lol/bar")).ConfigureAwait(false);
|
||||
|
|
|
@ -93,8 +93,10 @@ namespace Fusillade.Tests
|
|||
return blockedRqs[rq].Select(_ => ret).Finally(() => completedCount++);
|
||||
}));
|
||||
|
||||
var client = new HttpClient(fixture);
|
||||
client.BaseAddress = new Uri("http://example");
|
||||
var client = new HttpClient(fixture)
|
||||
{
|
||||
BaseAddress = new Uri("http://example")
|
||||
};
|
||||
|
||||
var rqs =
|
||||
Enumerable
|
||||
|
@ -182,7 +184,7 @@ namespace Fusillade.Tests
|
|||
public async Task ConcurrentRequestsToTheSameResourceAreDebounced()
|
||||
{
|
||||
int messageCount = 0;
|
||||
Subject<Unit> gate = new Subject<Unit>();
|
||||
Subject<Unit> gate = new();
|
||||
|
||||
var fixture = CreateFixture(new TestHttpMessageHandler(_ =>
|
||||
{
|
||||
|
@ -231,7 +233,7 @@ namespace Fusillade.Tests
|
|||
public async Task DebouncedRequestsDontGetUnfairlyCancelled()
|
||||
{
|
||||
int messageCount = 0;
|
||||
Subject<Unit> gate = new Subject<Unit>();
|
||||
Subject<Unit> gate = new();
|
||||
|
||||
var fixture = CreateFixture(new TestHttpMessageHandler(_ =>
|
||||
{
|
||||
|
@ -292,7 +294,7 @@ namespace Fusillade.Tests
|
|||
public async Task RequestsToDifferentPathsArentDebounced()
|
||||
{
|
||||
int messageCount = 0;
|
||||
Subject<Unit> gate = new Subject<Unit>();
|
||||
Subject<Unit> gate = new();
|
||||
|
||||
var fixture = CreateFixture(new TestHttpMessageHandler(_ =>
|
||||
{
|
||||
|
@ -342,7 +344,7 @@ namespace Fusillade.Tests
|
|||
{
|
||||
int messageCount = 0;
|
||||
int finalMessageCount = 0;
|
||||
Subject<Unit> gate = new Subject<Unit>();
|
||||
Subject<Unit> gate = new();
|
||||
|
||||
var fixture = CreateFixture(new TestHttpMessageHandler(_ =>
|
||||
{
|
||||
|
@ -410,7 +412,7 @@ namespace Fusillade.Tests
|
|||
{
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
|
||||
|
||||
var input = @"https://github.com/akavache/Akavache/releases/download/3.2.0/Akavache.3.2.0.zip";
|
||||
const string input = "https://github.com/akavache/Akavache/releases/download/3.2.0/Akavache.3.2.0.zip";
|
||||
var fixture = CreateFixture(new HttpClientHandler()
|
||||
{
|
||||
AllowAutoRedirect = true,
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<PackageId>fusillade</PackageId>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<WarningsAsErrors>CS8625;CS8604;CS8600;CS8614;CS8603;CS8618;CS8619</WarningsAsErrors>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
|
||||
<PackageId>fusillade</PackageId>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<WarningsAsErrors>CS8625;CS8604;CS8600;CS8614;CS8603;CS8618;CS8619</WarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="punchclock" Version="3.*" />
|
||||
<PackageReference Include="Splat" Version="14.*" />
|
||||
<PackageReference Include="System.Net.Http" Version="4.3.4" />
|
||||
<PackageReference Include="System.Reactive" Version="5.*" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="punchclock" Version="3.*" />
|
||||
<PackageReference Include="Splat" Version="14.*" />
|
||||
<PackageReference Include="System.Net.Http" Version="4.3.4" />
|
||||
<PackageReference Include="System.Reactive" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace Fusillade
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a unique key for for a <see cref="HttpRequestMessage"/>.
|
||||
/// Generates a unique key for a <see cref="HttpRequestMessage"/>.
|
||||
/// This assists with the caching.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to generate a unique key for.</param>
|
||||
|
@ -66,12 +66,12 @@ namespace Fusillade
|
|||
|
||||
var ret = new[]
|
||||
{
|
||||
request.RequestUri.ToString(),
|
||||
request.RequestUri!.ToString(),
|
||||
request.Method.Method,
|
||||
request.Headers.Accept.ConcatenateAll(x => x.CharSet + x.MediaType),
|
||||
request.Headers.AcceptEncoding.ConcatenateAll(x => x.Value),
|
||||
(request.Headers.Referrer ?? new Uri("http://example")).AbsoluteUri,
|
||||
request.Headers.UserAgent.ConcatenateAll(x => (x.Product != null ? x.Product.ToString() : x.Comment)),
|
||||
request.Headers.UserAgent.ConcatenateAll(x => x.Product != null ? x.Product.ToString() : x.Comment!),
|
||||
}.Aggregate(
|
||||
new StringBuilder(),
|
||||
(acc, x) =>
|
||||
|
@ -82,7 +82,7 @@ namespace Fusillade
|
|||
|
||||
if (request.Headers.Authorization != null)
|
||||
{
|
||||
ret.AppendLine(request.Headers.Authorization.Parameter + request.Headers.Authorization.Scheme);
|
||||
ret.Append(request.Headers.Authorization.Parameter).AppendLine(request.Headers.Authorization.Scheme);
|
||||
}
|
||||
|
||||
return "HttpSchedulerCache_" + ret.ToString().GetHashCode().ToString("x", CultureInfo.InvariantCulture);
|
||||
|
@ -95,7 +95,6 @@ namespace Fusillade
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope", Justification = "Doesn't need to be disposed.")]
|
||||
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (request is null)
|
||||
|
@ -115,7 +114,7 @@ namespace Fusillade
|
|||
cacheResult = NetCache.RequestCache.Save;
|
||||
}
|
||||
|
||||
if (_maxBytesToRead != null && _maxBytesToRead.Value < 0)
|
||||
if (_maxBytesToRead < 0)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<HttpResponseMessage>();
|
||||
tcs.SetCanceled();
|
||||
|
@ -161,7 +160,7 @@ namespace Fusillade
|
|||
{
|
||||
var resp = await base.SendAsync(request, realToken.Token).ConfigureAwait(false);
|
||||
|
||||
if (_maxBytesToRead != null && resp.Content != null && resp.Content.Headers.ContentLength != null)
|
||||
if (_maxBytesToRead != null && resp.Content?.Headers.ContentLength != null)
|
||||
{
|
||||
_maxBytesToRead -= resp.Content.Headers.ContentLength;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче