diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-04-13 20:24:14 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-04-13 20:24:14 -0400 |
commit | f39da383a17b368e92fd243cf155b27ba42671f3 (patch) | |
tree | 56c215dfb34da270a7714afd141e76a94c69a2c0 /src/SMAPI/Events | |
parent | 6e9e8aef1ef97e1a4ef4410ce300cb1c47eca986 (diff) | |
download | SMAPI-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/Events')
-rw-r--r-- | src/SMAPI/Events/AssetRequestedEventArgs.cs | 14 | ||||
-rw-r--r-- | src/SMAPI/Events/MenuChangedEventArgs.cs | 16 |
2 files changed, 14 insertions, 16 deletions
diff --git a/src/SMAPI/Events/AssetRequestedEventArgs.cs b/src/SMAPI/Events/AssetRequestedEventArgs.cs index 3c51c95d..3bcf83b9 100644 --- a/src/SMAPI/Events/AssetRequestedEventArgs.cs +++ b/src/SMAPI/Events/AssetRequestedEventArgs.cs @@ -1,5 +1,3 @@ -#nullable disable - using System; using System.Collections.Generic; using Microsoft.Xna.Framework.Graphics; @@ -19,7 +17,7 @@ namespace StardewModdingAPI.Events private readonly IModMetadata Mod; /// <summary>Get the mod metadata for a content pack, if it's a valid content pack for the mod.</summary> - private readonly Func<IModMetadata, string, string, IModMetadata> GetOnBehalfOf; + private readonly Func<IModMetadata, string?, string, IModMetadata?> GetOnBehalfOf; /********* @@ -51,7 +49,7 @@ namespace StardewModdingAPI.Events /// <param name="dataType">The requested data type.</param> /// <param name="nameWithoutLocale">The <paramref name="name"/> with any locale codes stripped.</param> /// <param name="getOnBehalfOf">Get the mod metadata for a content pack, if it's a valid content pack for the mod.</param> - internal AssetRequestedEventArgs(IModMetadata mod, IAssetName name, IAssetName nameWithoutLocale, Type dataType, Func<IModMetadata, string, string, IModMetadata> getOnBehalfOf) + internal AssetRequestedEventArgs(IModMetadata mod, IAssetName name, IAssetName nameWithoutLocale, Type dataType, Func<IModMetadata, string?, string, IModMetadata?> getOnBehalfOf) { this.Mod = mod; this.Name = name; @@ -71,7 +69,7 @@ namespace StardewModdingAPI.Events /// <item>Each asset can logically only have one initial instance. If multiple loads apply at the same time, SMAPI will use the <paramref name="priority"/> parameter to decide what happens. If you're making changes to the existing asset instead of replacing it, you should use <see cref="Edit"/> instead to avoid those limitations and improve mod compatibility.</item> /// </list> /// </remarks> - public void LoadFrom(Func<object> load, AssetLoadPriority priority, string onBehalfOf = null) + public void LoadFrom(Func<object> load, AssetLoadPriority priority, string? onBehalfOf = null) { this.LoadOperations.Add( new AssetLoadOperation( @@ -95,13 +93,15 @@ namespace StardewModdingAPI.Events /// </list> /// </remarks> public void LoadFromModFile<TAsset>(string relativePath, AssetLoadPriority priority) + where TAsset : notnull { this.LoadOperations.Add( new AssetLoadOperation( mod: this.Mod, priority: priority, onBehalfOf: null, - _ => this.Mod.Mod.Helper.ModContent.Load<TAsset>(relativePath)) + _ => this.Mod.Mod!.Helper.ModContent.Load<TAsset>(relativePath) + ) ); } @@ -116,7 +116,7 @@ namespace StardewModdingAPI.Events /// <item>You can apply any number of edits to the asset. Each edit will be applied on top of the previous one (i.e. it'll see the merged asset from all previous edits as its input).</item> /// </list> /// </remarks> - public void Edit(Action<IAssetData> apply, AssetEditPriority priority = AssetEditPriority.Default, string onBehalfOf = null) + public void Edit(Action<IAssetData> apply, AssetEditPriority priority = AssetEditPriority.Default, string? onBehalfOf = null) { this.EditOperations.Add( new AssetEditOperation( diff --git a/src/SMAPI/Events/MenuChangedEventArgs.cs b/src/SMAPI/Events/MenuChangedEventArgs.cs index 362accec..c37fd216 100644 --- a/src/SMAPI/Events/MenuChangedEventArgs.cs +++ b/src/SMAPI/Events/MenuChangedEventArgs.cs @@ -1,5 +1,3 @@ -#nullable disable - using System; using StardewValley.Menus; @@ -11,20 +9,20 @@ namespace StardewModdingAPI.Events /********* ** Accessors *********/ - /// <summary>The previous menu.</summary> - public IClickableMenu OldMenu { get; } + /// <summary>The previous menu, if any.</summary> + public IClickableMenu? OldMenu { get; } - /// <summary>The current menu.</summary> - public IClickableMenu NewMenu { get; } + /// <summary>The current menu, if any.</summary> + public IClickableMenu? NewMenu { get; } /********* ** Public methods *********/ /// <summary>Construct an instance.</summary> - /// <param name="oldMenu">The previous menu.</param> - /// <param name="newMenu">The current menu.</param> - internal MenuChangedEventArgs(IClickableMenu oldMenu, IClickableMenu newMenu) + /// <param name="oldMenu">The previous menu, if any.</param> + /// <param name="newMenu">The current menu, if any.</param> + internal MenuChangedEventArgs(IClickableMenu? oldMenu, IClickableMenu? newMenu) { this.OldMenu = oldMenu; this.NewMenu = newMenu; |