summaryrefslogtreecommitdiff
path: root/src/SMAPI
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
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')
-rw-r--r--src/SMAPI/Constants.cs26
-rw-r--r--src/SMAPI/Events/AssetRequestedEventArgs.cs14
-rw-r--r--src/SMAPI/Events/MenuChangedEventArgs.cs16
-rw-r--r--src/SMAPI/Framework/Command.cs6
-rw-r--r--src/SMAPI/Framework/Commands/HarmonySummaryCommand.cs20
-rw-r--r--src/SMAPI/Framework/Content/AssetData.cs7
-rw-r--r--src/SMAPI/Framework/Content/AssetDataForDictionary.cs4
-rw-r--r--src/SMAPI/Framework/Content/AssetDataForImage.cs4
-rw-r--r--src/SMAPI/Framework/Content/AssetDataForObject.cs4
-rw-r--r--src/SMAPI/Framework/Content/AssetEditOperation.cs6
-rw-r--r--src/SMAPI/Framework/Content/AssetInfo.cs12
-rw-r--r--src/SMAPI/Framework/Content/AssetInterceptorChange.cs7
-rw-r--r--src/SMAPI/Framework/Content/AssetLoadOperation.cs6
-rw-r--r--src/SMAPI/Framework/ContentCoordinator.cs35
-rw-r--r--src/SMAPI/Framework/ContentManagers/GameContentManager.cs34
-rw-r--r--src/SMAPI/Framework/ContentManagers/GameContentManagerForAssetPropagation.cs4
-rw-r--r--src/SMAPI/Framework/ContentManagers/IContentManager.cs13
-rw-r--r--src/SMAPI/Framework/ContentPack.cs9
-rw-r--r--src/SMAPI/Framework/CursorPosition.cs4
-rw-r--r--src/SMAPI/Framework/Events/ManagedEvent.cs8
-rw-r--r--src/SMAPI/Framework/Events/ManagedEventHandler.cs4
-rw-r--r--src/SMAPI/Framework/Exceptions/SContentLoadException.cs4
-rw-r--r--src/SMAPI/Framework/GameVersion.cs10
-rw-r--r--src/SMAPI/Framework/IModMetadata.cs26
-rw-r--r--src/SMAPI/Framework/Logging/LogFileManager.cs4
-rw-r--r--src/SMAPI/Framework/ModHelpers/ContentHelper.cs9
-rw-r--r--src/SMAPI/Framework/ModHelpers/DataHelper.cs28
-rw-r--r--src/SMAPI/Framework/ModHelpers/GameContentHelper.cs8
-rw-r--r--src/SMAPI/Framework/ModHelpers/ModContentHelper.cs6
-rw-r--r--src/SMAPI/Framework/ModHelpers/ModRegistryHelper.cs13
-rw-r--r--src/SMAPI/Framework/ModHelpers/MultiplayerHelper.cs8
-rw-r--r--src/SMAPI/Framework/ModHelpers/ReflectionHelper.cs26
-rw-r--r--src/SMAPI/Framework/ModLoading/AssemblyDefinitionResolver.cs8
-rw-r--r--src/SMAPI/Framework/ModLoading/Finders/EventFinder.cs4
-rw-r--r--src/SMAPI/Framework/ModLoading/Finders/FieldFinder.cs4
-rw-r--r--src/SMAPI/Framework/ModLoading/Finders/MethodFinder.cs4
-rw-r--r--src/SMAPI/Framework/ModLoading/Finders/PropertyFinder.cs4
-rw-r--r--src/SMAPI/Framework/ModLoading/Finders/ReferenceToMemberWithUnexpectedTypeFinder.cs15
-rw-r--r--src/SMAPI/Framework/ModLoading/Finders/ReferenceToMissingMemberFinder.cs13
-rw-r--r--src/SMAPI/Framework/ModLoading/Finders/TypeAssemblyFinder.cs6
-rw-r--r--src/SMAPI/Framework/ModLoading/Finders/TypeFinder.cs8
-rw-r--r--src/SMAPI/Framework/ModLoading/Framework/BaseInstructionHandler.cs4
-rw-r--r--src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs25
-rw-r--r--src/SMAPI/Framework/ModLoading/Framework/RewriteHelper.cs10
-rw-r--r--src/SMAPI/Framework/ModLoading/InvalidModStateException.cs4
-rw-r--r--src/SMAPI/Framework/ModLoading/ModMetadata.cs38
-rw-r--r--src/SMAPI/Framework/ModLoading/RewriteFacades/AccessToolsFacade.cs6
-rw-r--r--src/SMAPI/Framework/ModLoading/RewriteFacades/HarmonyInstanceFacade.cs9
-rw-r--r--src/SMAPI/Framework/ModLoading/RewriteFacades/HarmonyMethodFacade.cs6
-rw-r--r--src/SMAPI/Framework/ModLoading/Rewriters/HarmonyRewriter.cs16
-rw-r--r--src/SMAPI/Framework/ModLoading/Rewriters/HeuristicFieldRewriter.cs19
-rw-r--r--src/SMAPI/Framework/ModLoading/Rewriters/HeuristicMethodRewriter.cs15
-rw-r--r--src/SMAPI/Framework/ModLoading/Rewriters/MethodParentRewriter.cs13
-rw-r--r--src/SMAPI/Framework/ModLoading/Rewriters/TypeReferenceRewriter.cs6
-rw-r--r--src/SMAPI/Framework/ModLoading/Symbols/SymbolReaderProvider.cs6
-rw-r--r--src/SMAPI/Framework/ModLoading/TypeReferenceComparer.cs14
-rw-r--r--src/SMAPI/Framework/ModRegistry.cs16
-rw-r--r--src/SMAPI/Framework/Reflection/ReflectedField.cs16
-rw-r--r--src/SMAPI/Framework/Reflection/ReflectedMethod.cs18
-rw-r--r--src/SMAPI/Framework/Reflection/ReflectedProperty.cs18
-rw-r--r--src/SMAPI/Framework/Rendering/SDisplayDevice.cs8
-rw-r--r--src/SMAPI/Framework/Rendering/SXnaDisplayDevice.cs4
-rw-r--r--src/SMAPI/Framework/SGame.cs27
-rw-r--r--src/SMAPI/Framework/SModHooks.cs4
-rw-r--r--src/SMAPI/Framework/SnapshotDiff.cs6
-rw-r--r--src/SMAPI/Framework/SnapshotItemListDiff.cs5
-rw-r--r--src/SMAPI/Framework/SnapshotListDiff.cs4
-rw-r--r--src/SMAPI/Framework/StateTracking/ChestTracker.cs5
-rw-r--r--src/SMAPI/Framework/StateTracking/Comparers/EquatableComparer.cs4
-rw-r--r--src/SMAPI/Framework/StateTracking/Comparers/GenericEqualsComparer.cs4
-rw-r--r--src/SMAPI/Framework/StateTracking/Comparers/ObjectReferenceComparer.cs4
-rw-r--r--src/SMAPI/Framework/StateTracking/FieldWatchers/NetDictionaryWatcher.cs3
-rw-r--r--src/SMAPI/Framework/StateTracking/FieldWatchers/ObservableCollectionWatcher.cs8
-rw-r--r--src/SMAPI/Framework/StateTracking/FieldWatchers/WatcherFactory.cs15
-rw-r--r--src/SMAPI/Framework/StateTracking/LocationTracker.cs14
-rw-r--r--src/SMAPI/Framework/StateTracking/Snapshots/LocationSnapshot.cs4
-rw-r--r--src/SMAPI/Framework/StateTracking/Snapshots/WatcherSnapshot.cs6
-rw-r--r--src/SMAPI/Framework/StateTracking/Snapshots/WorldLocationsSnapshot.cs4
-rw-r--r--src/SMAPI/Framework/StateTracking/WorldLocationsTracker.cs23
-rw-r--r--src/SMAPI/Framework/Translator.cs20
-rw-r--r--src/SMAPI/Framework/Utilities/TickCacheDictionary.cs5
-rw-r--r--src/SMAPI/Framework/WatcherCore.cs4
-rw-r--r--src/SMAPI/IAssetData.cs3
-rw-r--r--src/SMAPI/IAssetInfo.cs4
-rw-r--r--src/SMAPI/IAssetName.cs12
-rw-r--r--src/SMAPI/IContentHelper.cs14
-rw-r--r--src/SMAPI/IContentPack.cs11
-rw-r--r--src/SMAPI/IDataHelper.cs20
-rw-r--r--src/SMAPI/IGameContentHelper.cs14
-rw-r--r--src/SMAPI/IMod.cs4
-rw-r--r--src/SMAPI/IModContentHelper.cs8
-rw-r--r--src/SMAPI/IModRegistry.cs9
-rw-r--r--src/SMAPI/IMultiplayerHelper.cs6
-rw-r--r--src/SMAPI/IMultiplayerPeer.cs10
-rw-r--r--src/SMAPI/IReflectedField.cs6
-rw-r--r--src/SMAPI/IReflectedMethod.cs6
-rw-r--r--src/SMAPI/IReflectedProperty.cs6
-rw-r--r--src/SMAPI/IReflectionHelper.cs30
-rw-r--r--src/SMAPI/Metadata/InstructionMetadata.cs24
-rw-r--r--src/SMAPI/Mod.cs12
-rw-r--r--src/SMAPI/Patches/Game1Patcher.cs6
-rw-r--r--src/SMAPI/Patches/TitleMenuPatcher.cs4
-rw-r--r--src/SMAPI/Program.cs22
-rw-r--r--src/SMAPI/Translation.cs30
-rw-r--r--src/SMAPI/Utilities/CaseInsensitivePathCache.cs4
-rw-r--r--src/SMAPI/Utilities/Keybind.cs5
-rw-r--r--src/SMAPI/Utilities/KeybindList.cs11
-rw-r--r--src/SMAPI/Utilities/SDate.cs55
108 files changed, 554 insertions, 673 deletions
diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs
index 2d9ab666..fd2b813a 100644
--- a/src/SMAPI/Constants.cs
+++ b/src/SMAPI/Constants.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
using System;
using System.Collections.Generic;
using System.IO;
@@ -33,7 +31,7 @@ namespace StardewModdingAPI
** Accessors
*********/
/// <summary>The path to the game folder.</summary>
- public static string GamePath { get; } = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
+ public static string GamePath { get; } = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!;
/// <summary>The absolute path to the folder containing SMAPI's internal files.</summary>
public static readonly string InternalFilesPath = Path.Combine(EarlyConstants.GamePath, "smapi-internal");
@@ -69,8 +67,8 @@ namespace StardewModdingAPI
/// <summary>The minimum supported version of Stardew Valley.</summary>
public static ISemanticVersion MinimumGameVersion { get; } = new GameVersion("1.5.6");
- /// <summary>The maximum supported version of Stardew Valley.</summary>
- public static ISemanticVersion MaximumGameVersion { get; } = null;
+ /// <summary>The maximum supported version of Stardew Valley, if any.</summary>
+ public static ISemanticVersion? MaximumGameVersion { get; } = null;
/// <summary>The target game platform.</summary>
public static GamePlatform TargetPlatform { get; } = EarlyConstants.Platform;
@@ -111,10 +109,10 @@ namespace StardewModdingAPI
public static string SavesPath { get; } = Path.Combine(Constants.DataPath, "Saves");
/// <summary>The name of the current save folder (if save info is available, regardless of whether the save file exists yet).</summary>
- public static string SaveFolderName => Constants.GetSaveFolderName();
+ public static string? SaveFolderName => Constants.GetSaveFolderName();
/// <summary>The absolute path to the current save folder (if save info is available and the save file exists).</summary>
- public static string CurrentSavePath => Constants.GetSaveFolderPathIfExists();
+ public static string? CurrentSavePath => Constants.GetSaveFolderPathIfExists();
/****
** Internal
@@ -164,7 +162,7 @@ namespace StardewModdingAPI
internal static string DefaultModsPath { get; } = Path.Combine(Constants.GamePath, "Mods");
/// <summary>The actual full path to search for mods.</summary>
- internal static string ModsPath { get; set; }
+ internal static string ModsPath { get; set; } = null!; // initialized early during SMAPI startup
/// <summary>The game's current semantic version.</summary>
internal static ISemanticVersion GameVersion { get; } = new GameVersion(Game1.version);
@@ -179,7 +177,7 @@ namespace StardewModdingAPI
/// <summary>Get the SMAPI version to recommend for an older game version, if any.</summary>
/// <param name="version">The game version to search.</param>
/// <returns>Returns the compatible SMAPI version, or <c>null</c> if none was found.</returns>
- internal static ISemanticVersion GetCompatibleApiVersion(ISemanticVersion version)
+ internal static ISemanticVersion? GetCompatibleApiVersion(ISemanticVersion version)
{
// This covers all officially supported public game updates. It might seem like version
// ranges would be better, but the given SMAPI versions may not be compatible with
@@ -337,22 +335,22 @@ namespace StardewModdingAPI
}
/// <summary>Get the name of the save folder, if any.</summary>
- private static string GetSaveFolderName()
+ private static string? GetSaveFolderName()
{
return Constants.GetSaveFolder()?.Name;
}
/// <summary>Get the absolute path to the current save folder, if any.</summary>
- private static string GetSaveFolderPathIfExists()
+ private static string? GetSaveFolderPathIfExists()
{
- DirectoryInfo saveFolder = Constants.GetSaveFolder();
+ DirectoryInfo? saveFolder = Constants.GetSaveFolder();
return saveFolder?.Exists == true
? saveFolder.FullName
: null;
}
/// <summary>Get the current save folder, if any.</summary>
- private static DirectoryInfo GetSaveFolder()
+ private static DirectoryInfo? GetSaveFolder()
{
// save not available
if (Context.LoadStage == LoadStage.None)
@@ -365,7 +363,7 @@ namespace StardewModdingAPI
: Game1.uniqueIDForThisGame;
// get best match (accounting for rare case where folder name isn't sanitized)
- DirectoryInfo folder = null;
+ DirectoryInfo? folder = null;
foreach (string saveName in new[] { rawSaveName, new string(rawSaveName.Where(char.IsLetterOrDigit).ToArray()) })
{
try
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 n