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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 1 addition & 5 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@
<PackageProjectUrl>https://github.com/jasperfx/wolverine</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<TargetFrameworks>net9.0;net10.0</TargetFrameworks>
<!-- xUnit1051 ("use TestContext.Current.CancellationToken") is new in the xUnit v3
analyzer set and ships at warning severity, which TreatWarningsAsErrors below
turns into a hard build break on several thousand call sites. Suppressed for the
v3 migration and tracked for reinstatement per-project. See XUNIT3-MIGRATION-PLAN.md. -->
<NoWarn>1570;1571;1572;1573;1574;1587;1591;1701;1702;1711;1735;0618;VSTHRD200;xUnit1051</NoWarn>
<NoWarn>1570;1571;1572;1573;1574;1587;1591;1701;1702;1711;1735;0618;VSTHRD200</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<ImplicitUsings>true</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
19 changes: 19 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>

<!--
xUnit1051 ("use TestContext.Current.CancellationToken") is new in the xUnit v3 analyzer set.
It ships at warning severity, and TreatWarningsAsErrors turns it into a hard build break, so
it was suppressed wholesale for the v3 migration (#3699).

Reinstating it is a per-project job rather than a flag flip: threading the token genuinely
changes how a suite cancels, and a suite has to be run, not just compiled, before its
conversion counts. A project opts in with

<XUnitCancellationTokenEnforced>true</XUnitCancellationTokenEnforced>

in its own PropertyGroup. This lives in .targets rather than .props because the property is
set by the project file, which is evaluated after Directory.Build.props. Remove this block
once every xUnit project is converted; the remaining ones are tracked in GH-3702.
-->
<PropertyGroup Condition=" '$(XUnitCancellationTokenEnforced)' != 'true' ">
<NoWarn>$(NoWarn);xUnit1051</NoWarn>
</PropertyGroup>

<!--
Security remediation for GHSA-v5pm-xwqc-g5wc (uncontrolled recursion / stack overflow
when parsing OpenAPI documents with circular schema references).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public async Task register_the_middleware()
{
// Apply the validation middleware
opts.UseDataAnnotationsValidation();
}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

#endregion
}
Expand All @@ -34,7 +34,7 @@ public async Task register_the_middleware_with_override_failure_condition()
// Override the service registration for IFailureAction
opts.Services.AddSingleton(typeof(IFailureAction<>), typeof(CustomFailureAction<>));

}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

#endregion
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<!-- GH-3702: xUnit1051 reinstated for this project -->
<XUnitCancellationTokenEnforced>true</XUnitCancellationTokenEnforced>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public async Task add_the_default_services()
.UseWolverine(opts =>
{
opts.UseDataAnnotationsValidation();
}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

host.Services.GetRequiredService<IFailureAction<Command1>>()
.ShouldBeOfType<FailureAction<Command1>>();
Expand All @@ -32,7 +32,7 @@ public async Task place_or_not_place_the_middleware_correctly()
.UseWolverine(opts =>
{
opts.UseDataAnnotationsValidation();
}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

var wolverineOptions = host.Services.GetRequiredService<IWolverineRuntime>()
.As<WolverineRuntime>().Options;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public async Task invoke_happy_path_with_multiple_validators()
.UseWolverine(opts =>
{
opts.UseDataAnnotationsValidation();
}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

var command = new Command1
{
Expand All @@ -31,7 +31,7 @@ public async Task invoke_sad_path_with_multiple_validators()
.UseWolverine(opts =>
{
opts.UseDataAnnotationsValidation();
}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

var command = new Command1
{
Expand All @@ -48,7 +48,7 @@ public async Task invoke_happy_path_with_single_validator()
.UseWolverine(opts =>
{
opts.UseDataAnnotationsValidation();
}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

var command = new Command2
{
Expand All @@ -66,7 +66,7 @@ public async Task invoke_sad_path_with_single_validator()
.UseWolverine(opts =>
{
opts.UseDataAnnotationsValidation();
}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

var command = new Command2
{
Expand All @@ -83,15 +83,15 @@ public async Task invoke_sad_path_validator_with_async_rule()
.UseWolverine(opts =>
{
opts.UseDataAnnotationsValidation();
}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

var command = new Command4
{
Email = "existing@email.me"
};

await Should.ThrowAsync<ValidationException>(() => host.InvokeAsync(command));
await host.StopAsync();
await host.StopAsync(TestContext.Current.CancellationToken);
}

[Fact]
Expand All @@ -101,14 +101,14 @@ public async Task invoke_happy_path_validator_with_async_rule()
.UseWolverine(opts =>
{
opts.UseDataAnnotationsValidation();
}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

var command = new Command4
{
Email = "new@email.me"
};

await Should.NotThrowAsync(() => host.InvokeAsync(command));
await host.StopAsync();
await host.StopAsync(TestContext.Current.CancellationToken);
}
}
6 changes: 3 additions & 3 deletions src/Extensions/Wolverine.FluentValidation.Tests/Samples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public async Task register_the_middleware()

// Just a prerequisite for some of the test validators
opts.Services.AddSingleton<IDataService, DataService>();
}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

#endregion
}
Expand All @@ -49,7 +49,7 @@ public async Task register_the_middleware_with_validator_options()

// Just a prerequisite for some of the test validators
opts.Services.AddSingleton<IDataService, DataService>();
}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

#endregion
}
Expand All @@ -70,7 +70,7 @@ public async Task register_the_middleware_with_override_failure_condition()

// Just a prerequisite for some of the test validators
opts.Services.AddSingleton<IDataService, DataService>();
}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

#endregion
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<!-- GH-3702: xUnit1051 reinstated for this project -->
<XUnitCancellationTokenEnforced>true</XUnitCancellationTokenEnforced>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public async Task register_validators_in_application_assembly()
opts.UseFluentValidation();

opts.Services.AddScoped<IDataService, DataService>();
}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

var container = host.Services.GetRequiredService<IServiceContainer>();

Expand All @@ -55,7 +55,7 @@ public async Task add_the_default_services()
opts.UseFluentValidation();

opts.Services.AddScoped<IDataService, DataService>();
}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

host.Services.GetRequiredService<IFailureAction<Command1>>()
.ShouldBeOfType<FailureAction<Command1>>();
Expand All @@ -70,7 +70,7 @@ public async Task place_or_not_place_the_middleware_correctly()
opts.UseFluentValidation();

opts.Services.AddScoped<IDataService, DataService>();
}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

var wolverineOptions = host.Services.GetRequiredService<IWolverineRuntime>()
.As<WolverineRuntime>().Options;
Expand Down Expand Up @@ -110,7 +110,7 @@ public async Task configure_validator_options_via_action_overload()
});

opts.Services.AddScoped<IDataService, DataService>();
}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

ValidatorOptions.Global.DefaultRuleLevelCascadeMode.ShouldBe(CascadeMode.Stop);
ValidatorOptions.Global.DefaultClassLevelCascadeMode.ShouldBe(CascadeMode.Stop);
Expand All @@ -129,7 +129,7 @@ public async Task configure_registration_behavior_via_action_overload()
{
fv.RegistrationBehavior = RegistrationBehavior.ExplicitRegistration;
});
}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

var container = host.Services.GetRequiredService<IServiceContainer>();

Expand All @@ -150,7 +150,7 @@ public async Task action_overload_still_applies_middleware()
});

opts.Services.AddScoped<IDataService, DataService>();
}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

var wolverineOptions = host.Services.GetRequiredService<IWolverineRuntime>()
.As<WolverineRuntime>().Options;
Expand All @@ -177,7 +177,7 @@ public async Task discover_internal_validators_when_include_internal_types_is_tr
});

opts.Services.AddScoped<IDataService, DataService>();
}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

var container = host.Services.GetRequiredService<IServiceContainer>();

Expand All @@ -196,7 +196,7 @@ public async Task do_not_discover_internal_validators_by_default()
opts.UseFluentValidation();

opts.Services.AddScoped<IDataService, DataService>();
}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

var container = host.Services.GetRequiredService<IServiceContainer>();

Expand All @@ -216,7 +216,7 @@ public async Task discover_internal_validator_with_dependencies_as_scoped()
});

opts.Services.AddScoped<IDataService, DataService>();
}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

var container = host.Services.GetRequiredService<IServiceContainer>();

Expand Down
24 changes: 12 additions & 12 deletions src/Extensions/Wolverine.FluentValidation.Tests/end_to_end.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public async Task invoke_happy_path_with_multiple_validators()
opts.UseFluentValidation();

opts.Services.AddScoped<IDataService, DataService>();
}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

var command = new Command1
{
Expand All @@ -36,7 +36,7 @@ public async Task invoke_sad_path_with_multiple_validators()
opts.UseFluentValidation();

opts.Services.AddScoped<IDataService, DataService>();
}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

var command = new Command1
{
Expand All @@ -55,7 +55,7 @@ public async Task invoke_happy_path_with_single_validator()
opts.UseFluentValidation();

opts.Services.AddScoped<IDataService, DataService>();
}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

var command = new Command2
{
Expand All @@ -75,7 +75,7 @@ public async Task invoke_sad_path_with_single_validator()
opts.UseFluentValidation();

opts.Services.AddScoped<IDataService, DataService>();
}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

var command = new Command2
{
Expand All @@ -94,15 +94,15 @@ public async Task invoke_sad_path_validator_with_async_rule()
opts.UseFluentValidation();

opts.Services.AddScoped<IDataService, DataService>();
}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

var command = new Command4
{
Email = "existing@email.me"
};

await Should.ThrowAsync<ValidationException>(() => host.InvokeAsync(command));
await host.StopAsync();
await host.StopAsync(TestContext.Current.CancellationToken);
}

[Fact]
Expand All @@ -114,15 +114,15 @@ public async Task invoke_happy_path_validator_with_async_rule()
opts.UseFluentValidation();

opts.Services.AddScoped<IDataService, DataService>();
}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

var command = new Command4
{
Email = "new@email.me"
};

await Should.NotThrowAsync(() => host.InvokeAsync(command));
await host.StopAsync();
await host.StopAsync(TestContext.Current.CancellationToken);
}

[Fact]
Expand All @@ -134,7 +134,7 @@ public async Task invoke_sad_path_multiple_validators_with_async_rule()
opts.UseFluentValidation();

opts.Services.AddScoped<IDataService, DataService>();
}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

var command = new Command5
{
Expand All @@ -143,7 +143,7 @@ public async Task invoke_sad_path_multiple_validators_with_async_rule()
};

await Should.ThrowAsync<ValidationException>(() => host.InvokeAsync(command));
await host.StopAsync();
await host.StopAsync(TestContext.Current.CancellationToken);
}

[Fact]
Expand All @@ -155,7 +155,7 @@ public async Task invoke_happy_path_multiple_validators_with_async_rule()
opts.UseFluentValidation();

opts.Services.AddScoped<IDataService, DataService>();
}).StartAsync();
}).StartAsync(cancellationToken: TestContext.Current.CancellationToken);

var command = new Command5
{
Expand All @@ -164,6 +164,6 @@ public async Task invoke_happy_path_multiple_validators_with_async_rule()
};

await Should.NotThrowAsync(() => host.InvokeAsync(command));
await host.StopAsync();
await host.StopAsync(TestContext.Current.CancellationToken);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public async Task default_validation_action_throws_exception()
var validator = new Command1Validator();
var command = new Command1();

var result = await validator.ValidateAsync(command);
var result = await validator.ValidateAsync(command, TestContext.Current.CancellationToken);

var ex = Should.Throw<ValidationException>(() =>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<!-- GH-3702: xUnit1051 reinstated for this project -->
<XUnitCancellationTokenEnforced>true</XUnitCancellationTokenEnforced>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
Loading
Loading