From 2d42999fa5aefdd101d95e728ba9604a593ab14b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20G=C3=B6pel?= Date: Sun, 26 Jul 2026 12:10:35 +0800 Subject: [PATCH] chore: enable TreatWarningsAsErrors and fix existing warnings --- Directory.Build.props | 5 +++++ samples/Directory.Build.props | 5 +++++ .../Account/Pages/ConfirmEmail.Tests.cs | 16 ++++++++-------- .../Account/Pages/ConfirmEmailChange.Tests.cs | 16 ++++++++-------- .../Account/Pages/Login.Localization.Tests.cs | 16 ++++++++-------- .../Account/Pages/Login.Tests.cs | 16 ++++++++-------- .../Pages/LoginForm.Localization.Tests.cs | 16 ++++++++-------- .../Account/Pages/LoginForm.Tests.cs | 16 ++++++++-------- .../Manage/ChangePassword.Validation.Tests.cs | 16 ++++++++-------- .../Pages/Manage/Passkeys.Localization.Tests.cs | 2 +- .../Account/Pages/RegisterConfirmation.Tests.cs | 16 ++++++++-------- .../Pages/ResetPassword.Localization.Tests.cs | 16 ++++++++-------- .../Account/Pages/ResetPassword.Tests.cs | 16 ++++++++-------- .../Tests/InvitationTests.cs | 12 ++++++++++-- .../Http/CookieLoginMiddleware.Tests.cs | 16 ++++++++-------- 15 files changed, 109 insertions(+), 91 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index f4d9544..444ce71 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -13,5 +13,10 @@ true + true + + NU1901;NU1902 diff --git a/samples/Directory.Build.props b/samples/Directory.Build.props index 175943a..64f2818 100644 --- a/samples/Directory.Build.props +++ b/samples/Directory.Build.props @@ -12,5 +12,10 @@ false false + true + + NU1901;NU1902 diff --git a/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/ConfirmEmail.Tests.cs b/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/ConfirmEmail.Tests.cs index 5928e6d..18d4843 100644 --- a/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/ConfirmEmail.Tests.cs +++ b/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/ConfirmEmail.Tests.cs @@ -20,14 +20,14 @@ private static UserManager BuildUserManager() var store = Substitute.For>(); return Substitute.For>( store, - null, - null, - null, - null, - null, - null, - null, - null + null!, + null!, + null!, + null!, + null!, + null!, + null!, + null! ); } diff --git a/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/ConfirmEmailChange.Tests.cs b/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/ConfirmEmailChange.Tests.cs index 9e153b8..2ceab1c 100644 --- a/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/ConfirmEmailChange.Tests.cs +++ b/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/ConfirmEmailChange.Tests.cs @@ -23,14 +23,14 @@ private static UserManager BuildUserManager() var store = Substitute.For>(); return Substitute.For>( store, - null, - null, - null, - null, - null, - null, - null, - null + null!, + null!, + null!, + null!, + null!, + null!, + null!, + null! ); } diff --git a/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/Login.Localization.Tests.cs b/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/Login.Localization.Tests.cs index ba7d102..8b73c06 100644 --- a/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/Login.Localization.Tests.cs +++ b/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/Login.Localization.Tests.cs @@ -112,14 +112,14 @@ private IRenderedComponent Render() var um = Substitute.For>( Substitute.For>(), - null, - null, - null, - null, - null, - null, - null, - null + null!, + null!, + null!, + null!, + null!, + null!, + null!, + null! ); var sm = Substitute.For>( um, diff --git a/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/Login.Tests.cs b/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/Login.Tests.cs index eebf842..b6466a5 100644 --- a/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/Login.Tests.cs +++ b/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/Login.Tests.cs @@ -59,14 +59,14 @@ private IRenderedComponent Render(IdentityFeatureFlags flags) var um = Substitute.For>( Substitute.For>(), - null, - null, - null, - null, - null, - null, - null, - null + null!, + null!, + null!, + null!, + null!, + null!, + null!, + null! ); var sm = Substitute.For>( um, diff --git a/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/LoginForm.Localization.Tests.cs b/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/LoginForm.Localization.Tests.cs index fa9ea69..fdc8872 100644 --- a/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/LoginForm.Localization.Tests.cs +++ b/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/LoginForm.Localization.Tests.cs @@ -140,14 +140,14 @@ Action, SignInManager> configure JSInterop.Mode = JSRuntimeMode.Loose; var um = Substitute.For>( Substitute.For>(), - null, - null, - null, - null, - null, - null, - null, - null + null!, + null!, + null!, + null!, + null!, + null!, + null!, + null! ); var sm = Substitute.For>( um, diff --git a/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/LoginForm.Tests.cs b/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/LoginForm.Tests.cs index c17e2f7..9d5dcc8 100644 --- a/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/LoginForm.Tests.cs +++ b/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/LoginForm.Tests.cs @@ -22,14 +22,14 @@ public class LoginFormTests : BunitContext private static UserManager BuildUserManager() => Substitute.For>( Substitute.For>(), - null, - null, - null, - null, - null, - null, - null, - null + null!, + null!, + null!, + null!, + null!, + null!, + null!, + null! ); private static SignInManager BuildSignInManager(UserManager userManager) => diff --git a/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/Manage/ChangePassword.Validation.Tests.cs b/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/Manage/ChangePassword.Validation.Tests.cs index 51dff33..60276a1 100644 --- a/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/Manage/ChangePassword.Validation.Tests.cs +++ b/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/Manage/ChangePassword.Validation.Tests.cs @@ -73,14 +73,14 @@ public async Task ChangePassword_ValidInput_ShowsNoValidationMessages() // Arrange var um = Substitute.For>( Substitute.For>(), - null, - null, - null, - null, - null, - null, - null, - null + null!, + null!, + null!, + null!, + null!, + null!, + null!, + null! ); var cut = Render(um); diff --git a/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/Manage/Passkeys.Localization.Tests.cs b/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/Manage/Passkeys.Localization.Tests.cs index 592eae3..2a797f8 100644 --- a/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/Manage/Passkeys.Localization.Tests.cs +++ b/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/Manage/Passkeys.Localization.Tests.cs @@ -71,7 +71,7 @@ public async Task GermanCulture_Delete_PassesTheLocalizedNameAndTitleToTheConfir await dialog .Received(1) .Confirm( - Arg.Is(m => m.Contains("Passkey **My iPhone**")), + Arg.Is(m => m != null && m.Contains("Passkey **My iPhone**")), "Passkey löschen", Arg.Any() ); diff --git a/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/RegisterConfirmation.Tests.cs b/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/RegisterConfirmation.Tests.cs index 573e2b7..90c5792 100644 --- a/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/RegisterConfirmation.Tests.cs +++ b/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/RegisterConfirmation.Tests.cs @@ -18,14 +18,14 @@ private static UserManager BuildUserManager() var store = Substitute.For>(); return Substitute.For>( store, - null, - null, - null, - null, - null, - null, - null, - null + null!, + null!, + null!, + null!, + null!, + null!, + null!, + null! ); } diff --git a/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/ResetPassword.Localization.Tests.cs b/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/ResetPassword.Localization.Tests.cs index 56b9271..3521239 100644 --- a/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/ResetPassword.Localization.Tests.cs +++ b/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/ResetPassword.Localization.Tests.cs @@ -96,14 +96,14 @@ private static UserManager BuildUserManager() var store = Substitute.For>(); return Substitute.For>( store, - null, - null, - null, - null, - null, - null, - null, - null + null!, + null!, + null!, + null!, + null!, + null!, + null!, + null! ); } diff --git a/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/ResetPassword.Tests.cs b/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/ResetPassword.Tests.cs index 5d08385..dacd059 100644 --- a/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/ResetPassword.Tests.cs +++ b/tests/AndreGoepel.Marten.Identity.Blazor.Tests/Account/Pages/ResetPassword.Tests.cs @@ -20,14 +20,14 @@ private static UserManager BuildUserManager() var store = Substitute.For>(); return Substitute.For>( store, - null, - null, - null, - null, - null, - null, - null, - null + null!, + null!, + null!, + null!, + null!, + null!, + null!, + null! ); } diff --git a/tests/AndreGoepel.Marten.Identity.E2ETests/Tests/InvitationTests.cs b/tests/AndreGoepel.Marten.Identity.E2ETests/Tests/InvitationTests.cs index b9fc4eb..d432e33 100644 --- a/tests/AndreGoepel.Marten.Identity.E2ETests/Tests/InvitationTests.cs +++ b/tests/AndreGoepel.Marten.Identity.E2ETests/Tests/InvitationTests.cs @@ -26,7 +26,11 @@ public async Task Admin_InvitesUser_InviteeSetsPassword_AndIsSignedIn() // The invitation link is captured from the outgoing mail (the sample's default // sender routes invitations through the password-reset path). - var link = await Fixture.Email.WaitForLinkAsync(invitee, "Account/AcceptInvitation"); + var link = await Fixture.Email.WaitForLinkAsync( + invitee, + "Account/AcceptInvitation", + ct: TestContext.Current.CancellationToken + ); // The invitee opens the link in their own fresh session, not the admin's. await using var inviteeContext = await Fixture.NewContextAsync(); @@ -71,7 +75,11 @@ public async Task InvitationLink_CannotBeReplayed_AfterAcceptance() await Page.ClickButtonAsync("Invite user"); await Page.FillFieldAsync("Email", invitee); await Page.ClickButtonAsync("Send invitation"); - var link = await Fixture.Email.WaitForLinkAsync(invitee, "Account/AcceptInvitation"); + var link = await Fixture.Email.WaitForLinkAsync( + invitee, + "Account/AcceptInvitation", + ct: TestContext.Current.CancellationToken + ); await using (var firstContext = await Fixture.NewContextAsync()) { diff --git a/tests/AndreGoepel.Marten.Identity.Tests/Http/CookieLoginMiddleware.Tests.cs b/tests/AndreGoepel.Marten.Identity.Tests/Http/CookieLoginMiddleware.Tests.cs index 025ec18..88aed9d 100644 --- a/tests/AndreGoepel.Marten.Identity.Tests/Http/CookieLoginMiddleware.Tests.cs +++ b/tests/AndreGoepel.Marten.Identity.Tests/Http/CookieLoginMiddleware.Tests.cs @@ -25,14 +25,14 @@ private static SignInManager BuildSignInManager() var store = Substitute.For>(); var userManager = Substitute.For>( store, - null, - null, - null, - null, - null, - null, - null, - null + null!, + null!, + null!, + null!, + null!, + null!, + null!, + null! ); return Substitute.For>( userManager,