diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-04-25 00:15:31 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-04-25 00:15:31 -0400 |
commit | 55c254deb86d90ed0c176df0d695ff67ffe701d9 (patch) | |
tree | 80fd2bfc8b1792b31e51057888592fba0bcb3aeb /src/SMAPI | |
parent | 4a14792e4db223f1d7faf4a22759268c91186e32 (diff) | |
download | SMAPI-55c254deb86d90ed0c176df0d695ff67ffe701d9.tar.gz SMAPI-55c254deb86d90ed0c176df0d695ff67ffe701d9.tar.bz2 SMAPI-55c254deb86d90ed0c176df0d695ff67ffe701d9.zip |
fix null reference error when implicitly converting null translation to string
Diffstat (limited to 'src/SMAPI')
-rw-r--r-- | src/SMAPI/Translation.cs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/SMAPI/Translation.cs b/src/SMAPI/Translation.cs index eb608f15..01cb92b2 100644 --- a/src/SMAPI/Translation.cs +++ b/src/SMAPI/Translation.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Text.RegularExpressions; @@ -120,9 +121,10 @@ namespace StardewModdingAPI /// <summary>Get a string representation of the given translation.</summary> /// <param name="translation">The translation key.</param> /// <remarks><strong>Limitation with nullable reference types: if there's no text and you disabled the fallback via <see cref="UsePlaceholder"/>, this will return null but the return value will still be marked non-nullable.</strong></remarks> + [SuppressMessage("ReSharper", "ConstantConditionalAccessQualifier", Justification = "The null check is required due to limitations in nullable type annotations (see remarks).")] public static implicit operator string(Translation translation) { - return translation.ToString(); + return translation?.ToString()!; } |