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
9 changes: 4 additions & 5 deletions .github/workflows/pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
strategy:
matrix:
configuration: [Debug, Release]
uses: codebeltnet/jobs-dotnet-build/.github/workflows/default.yml@v1
uses: codebeltnet/jobs-dotnet-build/.github/workflows/default.yml@v2
with:
configuration: ${{ matrix.configuration }}
strong-name-key-filename: xunit.snk
Expand All @@ -41,10 +41,9 @@ jobs:
strategy:
matrix:
configuration: [Debug, Release]
uses: codebeltnet/jobs-dotnet-pack/.github/workflows/default.yml@v1
uses: codebeltnet/jobs-dotnet-pack/.github/workflows/default.yml@v2
with:
configuration: ${{ matrix.configuration }}
upload-packed-artifact: true
version: ${{ needs.build.outputs.version }}

test:
Expand All @@ -55,7 +54,7 @@ jobs:
matrix:
os: [ubuntu-24.04, windows-2022]
configuration: [Debug, Release]
uses: codebeltnet/jobs-dotnet-test/.github/workflows/default.yml@v1
uses: codebeltnet/jobs-dotnet-test/.github/workflows/default.yml@v2
with:
configuration: ${{ matrix.configuration }}
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -90,7 +89,7 @@ jobs:
if: github.event_name != 'pull_request'
name: call-nuget
needs: [build, pack, test, sonarcloud, codecov, codeql]
uses: codebeltnet/jobs-nuget-push/.github/workflows/default.yml@v1
uses: codebeltnet/jobs-nuget-push/.github/workflows/default.yml@v2
with:
version: ${{ needs.build.outputs.version }}
environment: Production
Expand Down
8 changes: 7 additions & 1 deletion .nuget/Codebelt.Extensions.Xunit.App/PackageReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
Version 10.0.1
Version 10.0.2
Availability: .NET 9 and .NET 8

# ALM
- CHANGED Dependencies have been upgraded to the latest compatible versions for all supported target frameworks (TFMs)

Version 10.0.1
Availability: .NET 9 and .NET 8

# ALM
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
Version 10.0.1
Version 10.0.2
Availability: .NET 9 and .NET 8

# ALM
- CHANGED Dependencies have been upgraded to the latest compatible versions for all supported target frameworks (TFMs)

# Bug Fixes
- FIXED ManagedWebHostFixture class in the Codebelt.Extensions.Xunit.Hosting.AspNetCore namespace to exit ConfigureHost method if the fixture is not in a valid state (e.g., configuration delegate properties are null)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Missing release note for ConfigureApplicationCallback invocation change
The PR summary and changelog mention switching to explicit Invoke syntax for ConfigureApplicationCallback, but this isn’t documented here. Please add an entry under Improvements to cover that change.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~8-~8: You might be missing the article “the” here.
Context: ...it.Hosting.AspNetCore namespace to exit ConfigureHost method if the fixture is not in a valid...

(AI_EN_LECTOR_MISSING_DETERMINER_THE)

🤖 Prompt for AI Agents
In .nuget/Codebelt.Extensions.Xunit.Hosting.AspNetCore/PackageReleaseNotes.txt
at line 8, add a new entry under the Improvements section to document the change
to using explicit Invoke syntax for ConfigureApplicationCallback. This entry
should clearly state that the ConfigureApplicationCallback invocation was
updated to use explicit Invoke calls, reflecting the PR summary and changelog
accurately.


# Improvements
- CHANGED HasValidState method on the WebHostFixtureExtensions class in the Codebelt.Extensions.Xunit.Hosting.AspNetCore namespace to exclude check of Application property

Version 10.0.1
Availability: .NET 9 and .NET 8

# ALM
Expand Down
15 changes: 14 additions & 1 deletion .nuget/Codebelt.Extensions.Xunit.Hosting/PackageReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
Version 10.0.1
Version 10.0.2
Availability: .NET 9, .NET 8 and .NET Standard 2.0

# ALM
- CHANGED Dependencies have been upgraded to the latest compatible versions for all supported target frameworks (TFMs)

# Bug Fixes
- FIXED ManagedHostFixture class in the Codebelt.Extensions.Xunit.Hosting namespace to exit ConfigureHost method if the fixture is not in a valid state (e.g., configuration delegate properties are null)

# Improvements
- CHANGED HasValidState method on the GenericHostFixtureExtensions class in the Codebelt.Extensions.Xunit.Hosting namespace to exclude check of Host property
- CHANGED AddXunitTestLogging method on the ServiceCollectionExtensions class in the Codebelt.Extensions.Xunit.Hosting namespace to be forgiving when no active test is present (relates to https://github.com/xunit/xunit/issues/2377)

Version 10.0.1
Availability: .NET 9, .NET 8 and .NET Standard 2.0

# ALM
Expand Down
8 changes: 7 additions & 1 deletion .nuget/Codebelt.Extensions.Xunit/PackageReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
Version 10.0.1
Version 10.0.2
Availability: .NET 9 and .NET 8

# ALM
- CHANGED Dependencies have been upgraded to the latest compatible versions for all supported target frameworks (TFMs)

Version 10.0.1
Availability: .NET 9 and .NET 8

# ALM
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ For more details, please refer to `PackageReleaseNotes.txt` on a per assembly ba
> [!NOTE]
> Changelog entries prior to version 8.4.0 was migrated from previous versions of Cuemon.Extensions.Xunit, Cuemon.Extensions.Xunit.Hosting, and Cuemon.Extensions.Xunit.Hosting.AspNetCore.

## [10.0.2] - 2025-06-01

This is a minor update that addresses some non-critical issues and improves the overall developer experience of the package.

### Changed

- HasValidState method on the GenericHostFixtureExtensions class in the Codebelt.Extensions.Xunit.Hosting namespace to exclude check of Host property
- AddXunitTestLogging method on the ServiceCollectionExtensions class in the Codebelt.Extensions.Xunit.Hosting namespace to be forgiving when no active test is present (relates to https://github.com/xunit/xunit/issues/2377)
- You should use the ITestOutputHelperAccessor capability provided by AddXunitTestLoggingOutputHelperAccessor instead to set the ITestOutputHelper instance in your tests (e.g., in your constructor call `fixture.Host.Services.GetRequiredService<ITestOutputHelperAccessor>().TestOutput = output;`)

### Fixed

- ManagedHostFixture class in the Codebelt.Extensions.Xunit.Hosting namespace to exit ConfigureHost method if the fixture is not in a valid state (e.g., configuration delegate properties are null)
- ManagedWebHostFixture class in the Codebelt.Extensions.Xunit.Hosting.AspNetCore namespace to exit ConfigureHost method if the fixture is not in a valid state (e.g., configuration delegate properties are null)

## [10.0.1] - 2025-05-24

This is a service update that focuses on package dependencies.
Expand Down
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<PackageVersion Include="Cuemon.Extensions.AspNetCore" Version="9.0.5" />
<PackageVersion Include="Cuemon.Extensions.IO" Version="9.0.5" />
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="9.0.5" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />
<PackageVersion Include="MinVer" Version="6.0.0" />
<PackageVersion Include="NativeLibraryLoader" Version="1.0.13" />
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.6.3" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public override void ConfigureHost(Test 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>."); }
if (!this.HasValidState()) { return; } // had to include this due to dual-call this method (one uncontrolled from xUnit library reflection magic; second controlled from this library)
Copy link

Copilot AI Jun 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a logging or warning message for the early return when HasValidState() returns false, to help developers trace potential configuration issues in the web host fixture.

Suggested change
if (!this.HasValidState()) { return; } // had to include this due to dual-call this method (one uncontrolled from xUnit library reflection magic; second controlled from this library)
if (!this.HasValidState())
{
Logger?.LogWarning("Exiting ConfigureHost early because HasValidState() returned false. This may indicate a configuration issue.");
return;
} // had to include this due to dual-call this method (one uncontrolled from xUnit library reflection magic; second controlled from this library)

Copilot uses AI. Check for mistakes.

var hb = new HostBuilder()
.ConfigureWebHost(webBuilder =>
Expand Down Expand Up @@ -73,7 +74,7 @@ public override void ConfigureHost(Test hostTest)
})
.Configure(app =>
{
ConfigureApplicationCallback(app);
ConfigureApplicationCallback.Invoke(app);
Application = app;
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ public static class WebHostFixtureExtensions
/// <returns><c>true</c> if the specified <see cref="IWebHostFixture"/> has a valid state; otherwise, <c>false</c>.</returns>
/// <remarks>
/// A valid state is defined as having non-null values for the following properties:
/// <see cref="IWebHostFixture.ConfigureApplicationCallback"/>, <see cref="IGenericHostFixture.ConfigureServicesCallback"/>, <see cref="IHostTest.Host"/>,
/// <see cref="IGenericHostFixture.ConfigureHostCallback"/> and <see cref="IPipelineTest.Application"/>.
/// <see cref="IWebHostFixture.ConfigureApplicationCallback"/>, <see cref="IGenericHostFixture.ConfigureServicesCallback"/> and <see cref="IGenericHostFixture.ConfigureHostCallback"/>.
/// </remarks>
public static bool HasValidState(this IWebHostFixture hostFixture)
{
var hasValidState = ((IGenericHostFixture)hostFixture).HasValidState();
return hasValidState && hostFixture.ConfigureApplicationCallback != null && hostFixture.Application != null;
return hasValidState && hostFixture.ConfigureApplicationCallback != null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ public static class GenericHostFixtureExtensions
/// <returns><c>true</c> if the specified <see cref="IGenericHostFixture"/> has a valid state; otherwise, <c>false</c>.</returns>
/// <remarks>
/// A valid state is defined as having non-null values for the following properties:
/// <see cref="IGenericHostFixture.ConfigureServicesCallback"/>, <see cref="IHostTest.Host"/> and <see cref="IGenericHostFixture.ConfigureHostCallback"/>.
/// <see cref="IGenericHostFixture.ConfigureServicesCallback"/> and <see cref="IGenericHostFixture.ConfigureHostCallback"/>.
/// </remarks>
public static bool HasValidState(this IGenericHostFixture hostFixture)
{
return hostFixture.ConfigureServicesCallback != null &&
hostFixture.Host != null &&
hostFixture.ConfigureHostCallback != null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public virtual void ConfigureHost(Test hostTest)
{
if (hostTest == null) { throw new ArgumentNullException(nameof(hostTest)); }
if (!HasTypes(hostTest.GetType(), typeof(HostTest<>))) { throw new ArgumentOutOfRangeException(nameof(hostTest), typeof(HostTest<>), $"{nameof(hostTest)} is not assignable from HostTest<T>."); }
if (!this.HasValidState()) { return; } // had to include this due to dual-call this method (one uncontrolled from xUnit library reflection magic; second controlled from this library)
Copy link

Copilot AI Jun 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a logging statement or warning message before returning when HasValidState() is false so that unexpected early exits during host configuration can be more easily diagnosed.

Suggested change
if (!this.HasValidState()) { return; } // had to include this due to dual-call this method (one uncontrolled from xUnit library reflection magic; second controlled from this library)
if (!this.HasValidState())
{
Logger?.LogWarning("Exiting ConfigureHost early because the host is in an invalid state.");
return;
} // had to include this due to dual-call this method (one uncontrolled from xUnit library reflection magic; second controlled from this library)

Copilot uses AI. Check for mistakes.

var hb = new HostBuilder()
.UseContentRoot(Directory.GetCurrentDirectory())
Expand Down
9 changes: 8 additions & 1 deletion src/Codebelt.Extensions.Xunit.Hosting/XunitTestLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except
}
else
{
_output?.WriteLine(message);
try
{
_output?.WriteLine(message);
}
catch (InvalidOperationException)
{
// can happen when there is no currently active test (e.g., you should use the ITestOutputHelperAccessor capability)
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion testenvironments.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{
"name": "Docker-Ubuntu",
"type": "docker",
"dockerImage": "gimlichael/ubuntu-testrunner:mono-net8.0.409-9.0.300"
"dockerImage": "gimlichael/ubuntu-testrunner:net8.0.409-9.0.300"
}
]
}
Loading