From 2e7c233f6c9bf6430672b39f970a3324deba79dd Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 6 Apr 2022 21:48:55 -0400 Subject: enable nullable annotations by default (#837) This adds `#nullable disable` to all existing code (except where null is impossible like enum files), so it can be migrated incrementally. --- src/SMAPI.Toolkit.CoreInterfaces/IManifest.cs | 2 ++ src/SMAPI.Toolkit.CoreInterfaces/IManifestContentPackFor.cs | 2 ++ src/SMAPI.Toolkit.CoreInterfaces/IManifestDependency.cs | 2 ++ src/SMAPI.Toolkit.CoreInterfaces/ISemanticVersion.cs | 2 ++ 4 files changed, 8 insertions(+) (limited to 'src/SMAPI.Toolkit.CoreInterfaces') diff --git a/src/SMAPI.Toolkit.CoreInterfaces/IManifest.cs b/src/SMAPI.Toolkit.CoreInterfaces/IManifest.cs index 7375f005..a9251446 100644 --- a/src/SMAPI.Toolkit.CoreInterfaces/IManifest.cs +++ b/src/SMAPI.Toolkit.CoreInterfaces/IManifest.cs @@ -1,3 +1,5 @@ +#nullable disable + using System.Collections.Generic; namespace StardewModdingAPI diff --git a/src/SMAPI.Toolkit.CoreInterfaces/IManifestContentPackFor.cs b/src/SMAPI.Toolkit.CoreInterfaces/IManifestContentPackFor.cs index f05a3873..d898b716 100644 --- a/src/SMAPI.Toolkit.CoreInterfaces/IManifestContentPackFor.cs +++ b/src/SMAPI.Toolkit.CoreInterfaces/IManifestContentPackFor.cs @@ -1,3 +1,5 @@ +#nullable disable + namespace StardewModdingAPI { /// Indicates which mod can read the content pack represented by the containing manifest. diff --git a/src/SMAPI.Toolkit.CoreInterfaces/IManifestDependency.cs b/src/SMAPI.Toolkit.CoreInterfaces/IManifestDependency.cs index e86cd1f4..49b7aed6 100644 --- a/src/SMAPI.Toolkit.CoreInterfaces/IManifestDependency.cs +++ b/src/SMAPI.Toolkit.CoreInterfaces/IManifestDependency.cs @@ -1,3 +1,5 @@ +#nullable disable + namespace StardewModdingAPI { /// A mod dependency listed in a mod manifest. diff --git a/src/SMAPI.Toolkit.CoreInterfaces/ISemanticVersion.cs b/src/SMAPI.Toolkit.CoreInterfaces/ISemanticVersion.cs index b228b2d1..52cec52e 100644 --- a/src/SMAPI.Toolkit.CoreInterfaces/ISemanticVersion.cs +++ b/src/SMAPI.Toolkit.CoreInterfaces/ISemanticVersion.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; namespace StardewModdingAPI -- cgit From ab6cf45b03073f324c46f9e93a98e3342a1bdff7 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 7 Apr 2022 00:56:00 -0400 Subject: enable nullable annotations for semantic versions (#837) --- .../ISemanticVersion.cs | 38 ++++++++++++---------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'src/SMAPI.Toolkit.CoreInterfaces') diff --git a/src/SMAPI.Toolkit.CoreInterfaces/ISemanticVersion.cs b/src/SMAPI.Toolkit.CoreInterfaces/ISemanticVersion.cs index 52cec52e..7998272f 100644 --- a/src/SMAPI.Toolkit.CoreInterfaces/ISemanticVersion.cs +++ b/src/SMAPI.Toolkit.CoreInterfaces/ISemanticVersion.cs @@ -1,5 +1,3 @@ -#nullable disable - using System; namespace StardewModdingAPI @@ -20,10 +18,10 @@ namespace StardewModdingAPI int PatchVersion { get; } /// An optional prerelease tag. - string PrereleaseTag { get; } + string? PrereleaseTag { get; } /// Optional build metadata. This is ignored when determining version precedence. - string BuildMetadata { get; } + string? BuildMetadata { get; } /********* @@ -34,32 +32,38 @@ namespace StardewModdingAPI /// Get whether this version is older than the specified version. /// The version to compare with this instance. - bool IsOlderThan(ISemanticVersion other); + /// Although the parameter is nullable, it isn't optional. A null version is considered earlier than every possible valid version, so passing null to will always return false. + bool IsOlderThan(ISemanticVersion? other); /// Get whether this version is older than the specified version. - /// The version to compare with this instance. + /// The version to compare with this instance. A null value is never older. /// The specified version is not a valid semantic version. - bool IsOlderThan(string other); + /// Although the parameter is nullable, it isn't optional. A null version is considered earlier than every possible valid version, so passing null to will always return false. + bool IsOlderThan(string? other); /// Get whether this version is newer than the specified version. - /// The version to compare with this instance. - bool IsNewerThan(ISemanticVersion other); + /// The version to compare with this instance. A null value is always older. + /// Although the parameter is nullable, it isn't optional. A null version is considered earlier than every possible valid version, so passing null to will always return true. + bool IsNewerThan(ISemanticVersion? other); /// Get whether this version is newer than the specified version. - /// The version to compare with this instance. + /// The version to compare with this instance. A null value is always older. /// The specified version is not a valid semantic version. - bool IsNewerThan(string other); + /// Although the parameter is nullable, it isn't optional. A null version is considered earlier than every possible valid version, so passing null to will always return true. + bool IsNewerThan(string? other); /// Get whether this version is between two specified versions (inclusively). - /// The minimum version. - /// The maximum version. - bool IsBetween(ISemanticVersion min, ISemanticVersion max); + /// The minimum version. A null value is always older. + /// The maximum version. A null value is never newer. + /// Although the and parameters are nullable, they are not optional. A null version is considered earlier than every possible valid version. For example, passing null to will always return false, since no valid version can be earlier than null. + bool IsBetween(ISemanticVersion? min, ISemanticVersion? max); /// Get whether this version is between two specified versions (inclusively). - /// The minimum version. - /// The maximum version. + /// The minimum version. A null value is always older. + /// The maximum version. A null value is never newer. /// One of the specified versions is not a valid semantic version. - bool IsBetween(string min, string max); + /// Although the and parameters are nullable, they are not optional. A null version is considered earlier than every possible valid version. For example, passing null to will always return false, since no valid version can be earlier than null. + bool IsBetween(string? min, string? max); /// Get a string representation of the version. string ToString(); -- cgit From e58e8a22836081ec4baffa5a9b4b093a329f3d88 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 7 Apr 2022 01:38:02 -0400 Subject: enable nullable annotations for manifests (#837) --- src/SMAPI.Toolkit.CoreInterfaces/IManifest.cs | 8 +++----- src/SMAPI.Toolkit.CoreInterfaces/IManifestContentPackFor.cs | 4 +--- src/SMAPI.Toolkit.CoreInterfaces/IManifestDependency.cs | 4 +--- 3 files changed, 5 insertions(+), 11 deletions(-) (limited to 'src/SMAPI.Toolkit.CoreInterfaces') diff --git a/src/SMAPI.Toolkit.CoreInterfaces/IManifest.cs b/src/SMAPI.Toolkit.CoreInterfaces/IManifest.cs index a9251446..ee6cc0b6 100644 --- a/src/SMAPI.Toolkit.CoreInterfaces/IManifest.cs +++ b/src/SMAPI.Toolkit.CoreInterfaces/IManifest.cs @@ -1,5 +1,3 @@ -#nullable disable - using System.Collections.Generic; namespace StardewModdingAPI @@ -23,16 +21,16 @@ namespace StardewModdingAPI ISemanticVersion Version { get; } /// The minimum SMAPI version required by this mod, if any. - ISemanticVersion MinimumApiVersion { get; } + ISemanticVersion? MinimumApiVersion { get; } /// The unique mod ID. string UniqueID { get; } /// The name of the DLL in the directory that has the Entry method. Mutually exclusive with . - string EntryDll { get; } + string? EntryDll { get; } /// The mod which will read this as a content pack. Mutually exclusive with . - IManifestContentPackFor ContentPackFor { get; } + IManifestContentPackFor? ContentPackFor { get; } /// The other mods that must be loaded before this mod. IManifestDependency[] Dependencies { get; } diff --git a/src/SMAPI.Toolkit.CoreInterfaces/IManifestContentPackFor.cs b/src/SMAPI.Toolkit.CoreInterfaces/IManifestContentPackFor.cs index d898b716..52ac8f1c 100644 --- a/src/SMAPI.Toolkit.CoreInterfaces/IManifestContentPackFor.cs +++ b/src/SMAPI.Toolkit.CoreInterfaces/IManifestContentPackFor.cs @@ -1,5 +1,3 @@ -#nullable disable - namespace StardewModdingAPI { /// Indicates which mod can read the content pack represented by the containing manifest. @@ -9,6 +7,6 @@ namespace StardewModdingAPI string UniqueID { get; } /// The minimum required version (if any). - ISemanticVersion MinimumVersion { get; } + ISemanticVersion? MinimumVersion { get; } } } diff --git a/src/SMAPI.Toolkit.CoreInterfaces/IManifestDependency.cs b/src/SMAPI.Toolkit.CoreInterfaces/IManifestDependency.cs index 49b7aed6..58425eb2 100644 --- a/src/SMAPI.Toolkit.CoreInterfaces/IManifestDependency.cs +++ b/src/SMAPI.Toolkit.CoreInterfaces/IManifestDependency.cs @@ -1,5 +1,3 @@ -#nullable disable - namespace StardewModdingAPI { /// A mod dependency listed in a mod manifest. @@ -12,7 +10,7 @@ namespace StardewModdingAPI string UniqueID { get; } /// The minimum required version (if any). - ISemanticVersion MinimumVersion { get; } + ISemanticVersion? MinimumVersion { get; } /// Whether the dependency must be installed to use the mod. bool IsRequired { get; } -- cgit From 6b05296e71c32abd158f354eeeaf1e135e72e6e2 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 7 Apr 2022 01:51:50 -0400 Subject: migrate mod build package to .NET 5 to allow full nullable annotations (#837) --- src/SMAPI.Toolkit.CoreInterfaces/SMAPI.Toolkit.CoreInterfaces.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/SMAPI.Toolkit.CoreInterfaces') diff --git a/src/SMAPI.Toolkit.CoreInterfaces/SMAPI.Toolkit.CoreInterfaces.csproj b/src/SMAPI.Toolkit.CoreInterfaces/SMAPI.Toolkit.CoreInterfaces.csproj index 4c92b4db..d69d53d5 100644 --- a/src/SMAPI.Toolkit.CoreInterfaces/SMAPI.Toolkit.CoreInterfaces.csproj +++ b/src/SMAPI.Toolkit.CoreInterfaces/SMAPI.Toolkit.CoreInterfaces.csproj @@ -2,7 +2,7 @@ StardewModdingAPI Provides toolkit interfaces which are available to SMAPI mods. - net5.0; netstandard2.0 + net5.0 true -- cgit From 238045ba9c5937f684cad3c55a8f9b9c2733e45f Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 7 Apr 2022 22:19:48 -0400 Subject: reverse mod build package migration to .NET 5 (#837) The migrated package didn't work consistently in VIsual Studio, so this suppresses nullable annotations in .NET Standard instead. --- src/SMAPI.Toolkit.CoreInterfaces/SMAPI.Toolkit.CoreInterfaces.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/SMAPI.Toolkit.CoreInterfaces') diff --git a/src/SMAPI.Toolkit.CoreInterfaces/SMAPI.Toolkit.CoreInterfaces.csproj b/src/SMAPI.Toolkit.CoreInterfaces/SMAPI.Toolkit.CoreInterfaces.csproj index d69d53d5..4c92b4db 100644 --- a/src/SMAPI.Toolkit.CoreInterfaces/SMAPI.Toolkit.CoreInterfaces.csproj +++ b/src/SMAPI.Toolkit.CoreInterfaces/SMAPI.Toolkit.CoreInterfaces.csproj @@ -2,7 +2,7 @@ StardewModdingAPI Provides toolkit interfaces which are available to SMAPI mods. - net5.0 + net5.0; netstandard2.0 true -- cgit From 0b48c1748b354458059c7607415288de072b01e9 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Tue, 12 Apr 2022 19:15:39 -0400 Subject: enable nullable annotations in the web project & related code (#837) --- src/SMAPI.Toolkit.CoreInterfaces/ISemanticVersion.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/SMAPI.Toolkit.CoreInterfaces') diff --git a/src/SMAPI.Toolkit.CoreInterfaces/ISemanticVersion.cs b/src/SMAPI.Toolkit.CoreInterfaces/ISemanticVersion.cs index 7998272f..dc226b7c 100644 --- a/src/SMAPI.Toolkit.CoreInterfaces/ISemanticVersion.cs +++ b/src/SMAPI.Toolkit.CoreInterfaces/ISemanticVersion.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics.CodeAnalysis; namespace StardewModdingAPI { @@ -28,6 +29,9 @@ namespace StardewModdingAPI ** Accessors *********/ /// Whether this is a prerelease version. +#if NET5_0_OR_GREATER + [MemberNotNullWhen(true, nameof(ISemanticVersion.PrereleaseTag))] +#endif bool IsPrerelease(); /// Get whether this version is older than the specified version. -- cgit