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: 4 additions & 4 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<GlobalPackageReference Include="CSharpier.MSBuild" Version="1.4.2" />
<GlobalPackageReference Include="Meziantou.Analyzer" Version="3.0.279" />
<GlobalPackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="5.6.0" />
<GlobalPackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="10.0.403" />
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.403" />
<GlobalPackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="11.0.100" />
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="11.0.100" />
<GlobalPackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="18.12.1" />
<GlobalPackageReference Include="NetEvolve.Analyzer" Version="0.20.86" />
<GlobalPackageReference Include="NetEvolve.Defaults" Version="2.10.80" />
Expand All @@ -19,8 +19,8 @@
<GlobalPackageReference Include="Roslynator.Refactorings" Version="5.0.1" />
</ItemGroup>
<ItemGroup>
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="10.0.13" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="10.0.13" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="11.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="11.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.12.0" />
<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="18.12.0" />
<PackageVersion Include="NetEvolve.Extensions.TUnit" Version="3.5.658" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using global::TUnit.Core.Executors;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

[TestExecutor<STAThreadExecutor>]
public partial class IHostBuilderExtensionsTests
Expand All @@ -19,7 +20,11 @@ public async Task UseWindowsForms_IHostBuilder_StartForm_ConfigureNull_Expected(
{
cancellationToken.ThrowIfCancellationRequested();

using var host = Host.CreateDefaultBuilder().UseWindowsForms<TestForm>().Build();
// System.Diagnostics.EventLog 11.x ships no Windows implementation for net8.0/net9.0, so the default EventLog provider must not be used.
using var host = Host.CreateDefaultBuilder()
.ConfigureLogging(logging => logging.ClearProviders())
.UseWindowsForms<TestForm>()
.Build();

await host.StartAsync(cancellationToken: cancellationToken).ConfigureAwait(false);

Expand Down Expand Up @@ -47,6 +52,7 @@ public async Task UseWindowsForms_IHostBuilder_StartForm_ConfigureFine_Expected(
cancellationToken.ThrowIfCancellationRequested();

using var host = Host.CreateDefaultBuilder()
.ConfigureLogging(logging => logging.ClearProviders())
.UseWindowsForms<TestForm>(options =>
{
options.EnableConsoleShutdown = true;
Expand Down Expand Up @@ -79,7 +85,10 @@ public async Task UseWindowsForms_IHostBuilder_ApplicationContext_Expected(
{
cancellationToken.ThrowIfCancellationRequested();

using var host = Host.CreateDefaultBuilder().UseWindowsForms<TestApplicationContext>().Build();
using var host = Host.CreateDefaultBuilder()
.ConfigureLogging(logging => logging.ClearProviders())
.UseWindowsForms<TestApplicationContext>()
.Build();

await host.StartAsync(cancellationToken: cancellationToken).ConfigureAwait(false);

Expand Down Expand Up @@ -107,6 +116,7 @@ public async Task UseWindowsForms_IHostBuilder_ApplicationContextFactory_Expecte
cancellationToken.ThrowIfCancellationRequested();

using var host = Host.CreateDefaultBuilder()
.ConfigureLogging(logging => logging.ClearProviders())
.UseWindowsForms(sp => new TestApplicationContext(new TestForm()))
.Build();

Expand Down Expand Up @@ -136,6 +146,7 @@ public async Task UseWindowsForms_IHostBuilder_AdvancedFactory_Expected(
cancellationToken.ThrowIfCancellationRequested();

using var host = Host.CreateDefaultBuilder()
.ConfigureLogging(logging => logging.ClearProviders())
.UseWindowsForms<TestApplicationContext, TestForm>((sp, form) => new TestApplicationContext(form))
.Build();

Expand Down Expand Up @@ -166,6 +177,7 @@ public async Task UseWindowsForms_HostApplicationBuilder_StartForm_ConfigureNull
cancellationToken.ThrowIfCancellationRequested();

var builder = Host.CreateApplicationBuilder();
_ = builder.Logging.ClearProviders();
_ = builder.UseWindowsForms<TestForm>();
using var host = builder.Build();

Expand Down Expand Up @@ -195,6 +207,7 @@ public async Task UseWindowsForms_HostApplicationBuilder_StartForm_ConfigureFine
cancellationToken.ThrowIfCancellationRequested();

var builder = Host.CreateApplicationBuilder();
_ = builder.Logging.ClearProviders();
_ = builder.UseWindowsForms<TestForm>(options =>
{
options.EnableConsoleShutdown = true;
Expand Down Expand Up @@ -228,6 +241,7 @@ public async Task UseWindowsForms_HostApplicationBuilder_ApplicationContext_Expe
cancellationToken.ThrowIfCancellationRequested();

var builder = Host.CreateApplicationBuilder();
_ = builder.Logging.ClearProviders();
_ = builder.UseWindowsForms<TestApplicationContext>();
using var host = builder.Build();

Expand Down Expand Up @@ -257,6 +271,7 @@ public async Task UseWindowsForms_HostApplicationBuilder_ApplicationContextFacto
cancellationToken.ThrowIfCancellationRequested();

var builder = Host.CreateApplicationBuilder();
_ = builder.Logging.ClearProviders();
_ = builder.UseWindowsForms(sp => new TestApplicationContext(new TestForm()));
using var host = builder.Build();

Expand Down Expand Up @@ -286,6 +301,7 @@ public async Task UseWindowsForms_HostApplicationBuilder_AdvancedFactory_Expecte
cancellationToken.ThrowIfCancellationRequested();

var builder = Host.CreateApplicationBuilder();
_ = builder.Logging.ClearProviders();
_ = builder.UseWindowsForms<TestApplicationContext, TestForm>((sp, form) => new TestApplicationContext(form));
using var host = builder.Build();

Expand Down Expand Up @@ -317,6 +333,7 @@ public async Task UseWindowsForms_IHostBuilder_StartForm_WithDefaultFont_Expecte

using var font = new Font("Arial", 10f);
using var host = Host.CreateDefaultBuilder()
.ConfigureLogging(logging => logging.ClearProviders())
.UseWindowsForms<TestForm>(options =>
{
options.DefaultFont = font;
Expand Down Expand Up @@ -351,6 +368,7 @@ public async Task UseWindowsForms_IHostBuilder_StartForm_WithPreloadAction_Expec
var preloadInvoked = false;

using var host = Host.CreateDefaultBuilder()
.ConfigureLogging(logging => logging.ClearProviders())
.UseWindowsForms<TestForm>(options =>
{
options.PreloadAction = (_, _) => preloadInvoked = true;
Expand Down Expand Up @@ -386,6 +404,7 @@ public async Task UseWindowsForms_HostApplicationBuilder_StartForm_WithDefaultFo

using var font = new Font("Arial", 10f);
var builder = Host.CreateApplicationBuilder();
_ = builder.Logging.ClearProviders();
_ = builder.UseWindowsForms<TestForm>(options =>
{
options.DefaultFont = font;
Expand Down Expand Up @@ -415,6 +434,7 @@ public async Task UseWindowsForms_HostApplicationBuilder_StartForm_WithPreloadAc
var preloadInvoked = false;

var builder = Host.CreateApplicationBuilder();
_ = builder.Logging.ClearProviders();
_ = builder.UseWindowsForms<TestForm>(options =>
{
options.PreloadAction = (_, _) => preloadInvoked = true;
Expand Down