Skip to content
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
8 changes: 8 additions & 0 deletions .github/workflows/pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ on:
- Debug
- Release

permissions:
contents: read

jobs:
build:
name: 🛠️ Build
Expand Down Expand Up @@ -146,6 +149,8 @@ jobs:
name: call-codeql
needs: [build,test]
uses: codebeltnet/jobs-codeql/.github/workflows/default.yml@v1
permissions:
security-events: write

deploy:
if: github.event_name != 'pull_request'
Expand All @@ -154,6 +159,9 @@ jobs:
timeout-minutes: 15
needs: [build, pack, test, sonarcloud, codecov, codeql]
environment: Production
permissions:
contents: write
packages: write
steps:
- uses: codebeltnet/nuget-push@v1
with:
Expand Down
3 changes: 3 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<SignAssembly Condition="('$(CI)' == 'true' OR '$(IsMainAuthor)' == 'true') AND '$(SkipSignAssembly)' == 'false'">true</SignAssembly>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)xunit.snk</AssemblyOriginatorKeyFile>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisLevel>latest</AnalysisLevel>
<AnalysisMode>Recommended</AnalysisMode>
<NoWarn>7035,CA2260</NoWarn>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<IncludeBuildOutput>false</IncludeBuildOutput>
<IncludeSymbols>false</IncludeSymbols>
<Description>Provides a convenient set of default API additions for building .NET test projects based on xUnit.</Description>
<NoWarn>NU5128</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
[assembly: SuppressMessage("Blocker Code Smell", "S3427:Method overloads with default parameter values should not overlap", Justification = "Avoid bumping major version by providing an extra overloaded member as optional argument.", Scope = "member", Target = "~M:Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebHostTestFactory.CreateWithHostBuilderContext(System.Action{Microsoft.Extensions.Hosting.HostBuilderContext,Microsoft.Extensions.DependencyInjection.IServiceCollection},System.Action{Microsoft.Extensions.Hosting.HostBuilderContext,Microsoft.AspNetCore.Builder.IApplicationBuilder},System.Action{Microsoft.Extensions.Hosting.IHostBuilder},Codebelt.Extensions.Xunit.Hosting.AspNetCore.IAspNetCoreHostFixture)~Codebelt.Extensions.Xunit.Hosting.AspNetCore.IWebHostTest")]
[assembly: SuppressMessage("Blocker Code Smell", "S3427:Method overloads with default parameter values should not overlap", Justification = "Avoid bumping major version by providing an extra overloaded member as optional argument.", Scope = "member", Target = "~M:Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebHostTestFactory.RunAsync(System.Action{Microsoft.Extensions.DependencyInjection.IServiceCollection},System.Action{Microsoft.AspNetCore.Builder.IApplicationBuilder},System.Action{Microsoft.Extensions.Hosting.IHostBuilder},System.Func{System.Net.Http.HttpClient,System.Threading.Tasks.Task{System.Net.Http.HttpResponseMessage}},Codebelt.Extensions.Xunit.Hosting.AspNetCore.IAspNetCoreHostFixture)~System.Threading.Tasks.Task{System.Net.Http.HttpResponseMessage}")]
[assembly: SuppressMessage("Blocker Code Smell", "S3427:Method overloads with default parameter values should not overlap", Justification = "Avoid bumping major version by providing an extra overloaded member as optional argument.", Scope = "member", Target = "~M:Codebelt.Extensions.Xunit.Hosting.AspNetCore.WebHostTestFactory.RunWithHostBuilderContextAsync(System.Action{Microsoft.Extensions.Hosting.HostBuilderContext,Microsoft.Extensions.DependencyInjection.IServiceCollection},System.Action{Microsoft.Extensions.Hosting.HostBuilderContext,Microsoft.AspNetCore.Builder.IApplicationBuilder},System.Action{Microsoft.Extensions.Hosting.IHostBuilder},System.Func{System.Net.Http.HttpClient,System.Threading.Tasks.Task{System.Net.Http.HttpResponseMessage}},Codebelt.Extensions.Xunit.Hosting.AspNetCore.IAspNetCoreHostFixture)~System.Threading.Tasks.Task{System.Net.Http.HttpResponseMessage}")]
[assembly: SuppressMessage("Performance", "CA1859:Use concrete types when possible for improved performance", Justification = "Nitpick.", Scope = "member", Target = "~M:Codebelt.Extensions.Xunit.Hosting.AspNetCore.Http.FakeHttpContextAccessor.MakeGreeting(System.String)~System.IO.Stream")]
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public FakeHttpContextAccessor(IServiceScopeFactory factory = null)
HttpContext = context;
}

private Stream MakeGreeting(string greeting)
private static Stream MakeGreeting(string greeting)
{
Stream interim = null;
Stream result = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public FakeHttpResponseFeature()
}

/// <summary>
/// Registers a callback to be invoked just before the response starts. This is the last chance to modify the <see cref="P:Microsoft.AspNetCore.Http.Features.IHttpResponseFeature.Headers" />, <see cref="P:Microsoft.AspNetCore.Http.Features.IHttpResponseFeature.StatusCode" />, or <see cref="P:Microsoft.AspNetCore.Http.Features.IHttpResponseFeature.ReasonPhrase" />.
/// Registers a callback to be invoked just before the response starts. This is the last chance to modify the <see cref="IHttpResponseFeature.Headers" />, <see cref="IHttpResponseFeature.StatusCode" />, or <see cref="IHttpResponseFeature.ReasonPhrase" />.
/// </summary>
/// <param name="callback">The callback to invoke when starting the response.</param>
/// <param name="state">The state to pass into the callback.</param>
Expand All @@ -35,8 +35,8 @@ public override void OnStarting(Func<object, Task> callback, object state)
}

/// <summary>
/// Indicates if the response has started. If true, the <see cref="P:Microsoft.AspNetCore.Http.Features.IHttpResponseFeature.StatusCode" />,
/// <see cref="P:Microsoft.AspNetCore.Http.Features.IHttpResponseFeature.ReasonPhrase" />, and <see cref="P:Microsoft.AspNetCore.Http.Features.IHttpResponseFeature.Headers" /> are now immutable, and
/// Indicates if the response has started. If true, the <see cref="IHttpResponseFeature.StatusCode" />,
/// <see cref="IHttpResponseFeature.ReasonPhrase" />, and <see cref="IHttpResponseFeature.Headers" /> are now immutable, and
/// OnStarting should no longer be called.
/// </summary>
/// <value><c>true</c> if this instance has started; otherwise, <c>false</c>.</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static class HttpClientExtensions
/// <remarks>Designed to be used in conjunction with <see cref="WebHostTestFactory.RunAsync(System.Action{Microsoft.Extensions.DependencyInjection.IServiceCollection},System.Action{Microsoft.AspNetCore.Builder.IApplicationBuilder},System.Action{Microsoft.Extensions.Hosting.IHostBuilder},System.Func{System.Net.Http.HttpClient,System.Threading.Tasks.Task{System.Net.Http.HttpResponseMessage}},IWebHostFixture)"/> and <see cref="WebHostTestFactory.RunWithHostBuilderContextAsync(System.Action{Microsoft.Extensions.Hosting.HostBuilderContext,Microsoft.Extensions.DependencyInjection.IServiceCollection},System.Action{Microsoft.Extensions.Hosting.HostBuilderContext,Microsoft.AspNetCore.Builder.IApplicationBuilder},System.Action{Microsoft.Extensions.Hosting.IHostBuilder},System.Func{System.Net.Http.HttpClient,System.Threading.Tasks.Task{System.Net.Http.HttpResponseMessage}},IWebHostFixture)"/>.</remarks>
public static async Task<HttpResponseMessage> ToHttpResponseMessageAsync(this HttpClient client, Func<HttpClient, Task<HttpResponseMessage>> responseFactory = null)
{
if (client == null) { throw new ArgumentNullException(nameof(client)); }
ArgumentNullException.ThrowIfNull(client);
responseFactory ??= c => c.GetAsync("/");
return await responseFactory(client).ConfigureAwait(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public ManagedWebHostFixture()
/// </exception>
public override void ConfigureHost(Test hostTest)
{
if (hostTest == null) { throw new ArgumentNullException(nameof(hostTest)); }
ArgumentNullException.ThrowIfNull(hostTest);
if (!HasTypes(hostTest.GetType(), typeof(WebHostTest<>))) { throw new ArgumentOutOfRangeException(nameof(hostTest), typeof(WebHostTest<>), $"{nameof(hostTest)} is not assignable from WebHostTest<T>."); }

var hb = new HostBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public ManagedWebMinimalHostFixture()
/// </exception>
public override void ConfigureHost(Test hostTest)
{
if (hostTest == null) { throw new ArgumentNullException(nameof(hostTest)); }
ArgumentNullException.ThrowIfNull(hostTest);
if (!HasTypes(hostTest.GetType(), typeof(MinimalWebHostTest<>))) { throw new ArgumentOutOfRangeException(nameof(hostTest), typeof(MinimalWebHostTest<>), $"{nameof(hostTest)} is not assignable from MinimalWebHostTest<T>."); }

var hb = WebApplication.CreateBuilder(new WebApplicationOptions()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected MinimalWebHostTest(T hostFixture, ITestOutputHelper output = null, Typ
/// </exception>
protected MinimalWebHostTest(bool skipHostFixtureInitialization, T hostFixture, ITestOutputHelper output = null, Type callerType = null) : base(output, callerType)
{
if (hostFixture == null) { throw new ArgumentNullException(nameof(hostFixture)); }
ArgumentNullException.ThrowIfNull(hostFixture);
if (skipHostFixtureInitialization) { return; }
if (!hostFixture.HasValidState())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected WebHostTest(T hostFixture, ITestOutputHelper output = null, Type calle
/// <param name="callerType">The <see cref="Type"/> of caller that ends up invoking this instance.</param>
protected WebHostTest(bool skipHostFixtureInitialization, T hostFixture, ITestOutputHelper output = null, Type callerType = null) : base(skipHostFixtureInitialization, hostFixture, output, callerType)
{
if (hostFixture == null) { throw new ArgumentNullException(nameof(hostFixture)); }
ArgumentNullException.ThrowIfNull(hostFixture);
if (skipHostFixtureInitialization) { return; }
if (!hostFixture.HasValidState())
{
Expand Down
8 changes: 8 additions & 0 deletions src/Codebelt.Extensions.Xunit.Hosting/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@
[assembly: SuppressMessage("Major Code Smell", "S3971:\"GC.SuppressFinalize\" should not be called", Justification = "False-Positive due to IAsyncDisposable living side-by-side with IDisposable.", Scope = "member", Target = "~M:Codebelt.Extensions.Xunit.Hosting.HostFixture.DisposeAsync~System.Threading.Tasks.ValueTask")]
[assembly: SuppressMessage("Blocker Code Smell", "S3427:Method overloads with default parameter values should not overlap", Justification = "Avoid bumping major version by providing an extra overloaded member as optional argument.", Scope = "member", Target = "~M:Codebelt.Extensions.Xunit.Hosting.GenericHostTestFactory.Create(System.Action{Microsoft.Extensions.DependencyInjection.IServiceCollection},System.Action{Microsoft.Extensions.Hosting.IHostBuilder},Codebelt.Extensions.Xunit.Hosting.IHostFixture)~Codebelt.Extensions.Xunit.Hosting.IGenericHostTest")]
[assembly: SuppressMessage("Blocker Code Smell", "S3427:Method overloads with default parameter values should not overlap", Justification = "Avoid bumping major version by providing an extra overloaded member as optional argument.", Scope = "member", Target = "~M:Codebelt.Extensions.Xunit.Hosting.GenericHostTestFactory.CreateWithHostBuilderContext(System.Action{Microsoft.Extensions.Hosting.HostBuilderContext,Microsoft.Extensions.DependencyInjection.IServiceCollection},System.Action{Microsoft.Extensions.Hosting.IHostBuilder},Codebelt.Extensions.Xunit.Hosting.IHostFixture)~Codebelt.Extensions.Xunit.Hosting.IGenericHostTest")]
[assembly: SuppressMessage("Maintainability", "CA1510:Use ArgumentNullException throw helper", Justification = "Wont fix. Multi-TFMs. Only supported with >= .NET 7.", Scope = "member", Target = "~M:Codebelt.Extensions.Xunit.Hosting.HostTest`1.#ctor(System.Boolean,`0,Xunit.Abstractions.ITestOutputHelper,System.Type)")]
[assembly: SuppressMessage("Maintainability", "CA1510:Use ArgumentNullException throw helper", Justification = "Wont fix. Multi-TFMs. Only supported with >= .NET 7.", Scope = "member", Target = "~M:Codebelt.Extensions.Xunit.Hosting.LoggerExtensions.GetTestStore(Microsoft.Extensions.Logging.ILogger,System.String)~Codebelt.Extensions.Xunit.ITestStore{Codebelt.Extensions.Xunit.Hosting.XunitTestLoggerEntry}")]
[assembly: SuppressMessage("Maintainability", "CA1510:Use ArgumentNullException throw helper", Justification = "Wont fix. Multi-TFMs. Only supported with >= .NET 7.", Scope = "member", Target = "~M:Codebelt.Extensions.Xunit.Hosting.ManagedHostFixture.ConfigureHost(Codebelt.Extensions.Xunit.Test)")]
[assembly: SuppressMessage("Maintainability", "CA1510:Use ArgumentNullException throw helper", Justification = "Wont fix. Multi-TFMs. Only supported with >= .NET 7.", Scope = "member", Target = "~M:Codebelt.Extensions.Xunit.Hosting.ManagedMinimalHostFixture.ConfigureHost(Codebelt.Extensions.Xunit.Test)")]
[assembly: SuppressMessage("Maintainability", "CA1510:Use ArgumentNullException throw helper", Justification = "Wont fix. Multi-TFMs. Only supported with >= .NET 7.", Scope = "member", Target = "~M:Codebelt.Extensions.Xunit.Hosting.MinimalHostTest`1.#ctor(System.Boolean,`0,Xunit.Abstractions.ITestOutputHelper,System.Type)")]
[assembly: SuppressMessage("Maintainability", "CA1510:Use ArgumentNullException throw helper", Justification = "Wont fix. Multi-TFMs. Only supported with >= .NET 7.", Scope = "member", Target = "~M:Codebelt.Extensions.Xunit.Hosting.ServiceCollectionExtensions.AddXunitTestLogging(Microsoft.Extensions.DependencyInjection.IServiceCollection,Microsoft.Extensions.Logging.LogLevel)~Microsoft.Extensions.DependencyInjection.IServiceCollection")]
[assembly: SuppressMessage("Maintainability", "CA1510:Use ArgumentNullException throw helper", Justification = "Wont fix. Multi-TFMs. Only supported with >= .NET 7.", Scope = "member", Target = "~M:Codebelt.Extensions.Xunit.Hosting.ServiceCollectionExtensions.AddXunitTestLogging(Microsoft.Extensions.DependencyInjection.IServiceCollection,Xunit.Abstractions.ITestOutputHelper,Microsoft.Extensions.Logging.LogLevel)~Microsoft.Extensions.DependencyInjection.IServiceCollection")]
[assembly: SuppressMessage("Maintainability", "CA1510:Use ArgumentNullException throw helper", Justification = "Wont fix. Multi-TFMs. Only supported with >= .NET 7.", Scope = "member", Target = "~M:Codebelt.Extensions.Xunit.Hosting.ServiceCollectionExtensions.AddXunitTestLoggingOutputHelperAccessor``1(Microsoft.Extensions.DependencyInjection.IServiceCollection)~Microsoft.Extensions.DependencyInjection.IServiceCollection")]
2 changes: 1 addition & 1 deletion src/Codebelt.Extensions.Xunit/DelimitedStringOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Codebelt.Extensions.Xunit
{
internal class DelimitedStringOptions<T>
internal sealed class DelimitedStringOptions<T>
{
internal DelimitedStringOptions()
{
Expand Down
3 changes: 3 additions & 0 deletions src/Codebelt.Extensions.Xunit/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@

[assembly: SuppressMessage("Major Code Smell", "S3881:\"IDisposable\" should be implemented correctly", Justification = "This is a base class implementation of the IDisposable interface tailored to avoid wrong implementations.", Scope = "type", Target = "~T:Codebelt.Extensions.Xunit.Test")]
[assembly: SuppressMessage("Major Code Smell", "S3971:\"GC.SuppressFinalize\" should not be called", Justification = "False-Positive due to IAsyncDisposable living side-by-side with IDisposable.", Scope = "member", Target = "~M:Codebelt.Extensions.Xunit.Test.DisposeAsync~System.Threading.Tasks.ValueTask")]
[assembly: SuppressMessage("Maintainability", "CA1510:Use ArgumentNullException throw helper", Justification = "Wont fix. Multi-TFMs. Only supported with >= .NET 7.", Scope = "member", Target = "~M:Codebelt.Extensions.Xunit.DelimitedString.Create``1(System.Collections.Generic.IEnumerable{``0},System.Action{Codebelt.Extensions.Xunit.DelimitedStringOptions{``0}})~System.String")]
[assembly: SuppressMessage("Maintainability", "CA1510:Use ArgumentNullException throw helper", Justification = "Wont fix. Multi-TFMs. Only supported with >= .NET 7.", Scope = "member", Target = "~M:Codebelt.Extensions.Xunit.TestOutputHelperExtensions.WriteLines(Xunit.Abstractions.ITestOutputHelper,System.Object[])")]
[assembly: SuppressMessage("Maintainability", "CA1510:Use ArgumentNullException throw helper", Justification = "Wont fix. Multi-TFMs. Only supported with >= .NET 7.", Scope = "member", Target = "~M:Codebelt.Extensions.Xunit.TestOutputHelperExtensions.WriteLines``1(Xunit.Abstractions.ITestOutputHelper,System.Collections.Generic.IEnumerable{``0})")]