summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/ModHelpers/GameContentHelper.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-04-13 20:24:14 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-04-13 20:24:14 -0400
commitf39da383a17b368e92fd243cf155b27ba42671f3 (patch)
tree56c215dfb34da270a7714afd141e76a94c69a2c0 /src/SMAPI/Framework/ModHelpers/GameContentHelper.cs
parent6e9e8aef1ef97e1a4ef4410ce300cb1c47eca986 (diff)
downloadSMAPI-f39da383a17b368e92fd243cf155b27ba42671f3.tar.gz
SMAPI-f39da383a17b368e92fd243cf155b27ba42671f3.tar.bz2
SMAPI-f39da383a17b368e92fd243cf155b27ba42671f3.zip
enable nullable annotations in SMAPI where no logic changes are needed (#837)
Diffstat (limited to 'src/SMAPI/Framework/ModHelpers/GameContentHelper.cs')
-rw-r--r--src/SMAPI/Framework/ModHelpers/GameContentHelper.cs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/SMAPI/Framework/ModHelpers/GameContentHelper.cs b/src/SMAPI/Framework/ModHelpers/GameContentHelper.cs
index 6d0c2f5f..4c1cde02 100644
--- a/src/SMAPI/Framework/ModHelpers/GameContentHelper.cs
+++ b/src/SMAPI/Framework/ModHelpers/GameContentHelper.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
using System;
using System.Linq;
using StardewModdingAPI.Framework.Content;
@@ -71,6 +69,7 @@ namespace StardewModdingAPI.Framework.ModHelpers
/// <inheritdoc />
public T Load<T>(string key)
+ where T : notnull
{
IAssetName assetName = this.ContentCore.ParseAssetName(key, allowLocales: true);
return this.Load<T>(assetName);
@@ -78,6 +77,7 @@ namespace StardewModdingAPI.Framework.ModHelpers
/// <inheritdoc />
public T Load<T>(IAssetName assetName)
+ where T : notnull
{
try
{
@@ -105,6 +105,7 @@ namespace StardewModdingAPI.Framework.ModHelpers
/// <inheritdoc />
public bool InvalidateCache<T>()
+ where T : notnull
{
this.Monitor.Log($"Requested cache invalidation for all assets of type {typeof(T)}. This is an expensive operation and should be avoided if possible.");
return this.ContentCore.InvalidateCache((_, _, type) => typeof(T).IsAssignableFrom(type)).Any();
@@ -118,7 +119,8 @@ namespace StardewModdingAPI.Framework.ModHelpers
}
/// <inheritdoc />
- public IAssetData GetPatchHelper<T>(T data, string assetName = null)
+ public IAssetData GetPatchHelper<T>(T data, string? assetName = null)
+ where T : notnull
{
if (data == null)
throw new ArgumentNullException(nameof(data), "Can't get a patch helper for a null value.");