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