diff options
Diffstat (limited to 'src/SMAPI/Framework/Content/AssetDataForObject.cs')
-rw-r--r-- | src/SMAPI/Framework/Content/AssetDataForObject.cs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/SMAPI/Framework/Content/AssetDataForObject.cs b/src/SMAPI/Framework/Content/AssetDataForObject.cs index d91873ae..4a6df64b 100644 --- a/src/SMAPI/Framework/Content/AssetDataForObject.cs +++ b/src/SMAPI/Framework/Content/AssetDataForObject.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using System.Collections.Generic; using Microsoft.Xna.Framework.Graphics; @@ -47,9 +49,9 @@ namespace StardewModdingAPI.Framework.Content /// <inheritdoc /> public TData GetData<TData>() { - if (!(this.Data is TData)) + if (this.Data is not TData data) throw new InvalidCastException($"The content data of type {this.Data.GetType().FullName} can't be converted to the requested {typeof(TData).FullName}."); - return (TData)this.Data; + return data; } } } |