From 55c254deb86d90ed0c176df0d695ff67ffe701d9 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 25 Apr 2022 00:15:31 -0400 Subject: fix null reference error when implicitly converting null translation to string --- src/SMAPI/Translation.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/SMAPI') 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 /// Get a string representation of the given translation. /// The translation key. /// Limitation with nullable reference types: if there's no text and you disabled the fallback via , this will return null but the return value will still be marked non-nullable. + [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()!; } -- cgit