Get null check outside of IsTrimable extension method.
MODIFY
WalletWasabi/Extensions/StringExtensions.cs
WalletWasabi/Extensions/StringExtensions.cs
@@ -63,14 +63,9 @@ namespace System
return me;
}
- public static bool IsTrimable(this string? me)
+ public static bool IsTrimable(this string me)
{
- if (string.IsNullOrEmpty(me))
- {
- return false;
- }
-
- return char.IsWhiteSpace(me.First()) || char.IsWhiteSpace(me.Last());
+ return me.Any() && (char.IsWhiteSpace(me.First()) || char.IsWhiteSpace(me.Last()));
}
}
}

MODIFY
WalletWasabi/Userfacing/PasswordHelper.cs
WalletWasabi/Userfacing/PasswordHelper.cs
@@ -72,9 +72,9 @@ namespace WalletWasabi.Userfacing
{
trimmedPassword = password;
- if (password.IsTrimable())
+ if (password is {} && password.IsTrimable())
{
- trimmedPassword = password!.Trim(); // IsTrimable() returns false if string is null
+ trimmedPassword = password.Trim();
return true;
}

Get null check outside of IsTrimable extension method.