summaryrefslogtreecommitdiff
path: root/src/SMAPI
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-04-07 00:56:00 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-04-07 00:56:00 -0400
commitab6cf45b03073f324c46f9e93a98e3342a1bdff7 (patch)
tree91452bd1e99230561add031cd2223db29ab46110 /src/SMAPI
parent3f9b412beda2d9c9168473089f201149cb27f755 (diff)
downloadSMAPI-ab6cf45b03073f324c46f9e93a98e3342a1bdff7.tar.gz
SMAPI-ab6cf45b03073f324c46f9e93a98e3342a1bdff7.tar.bz2
SMAPI-ab6cf45b03073f324c46f9e93a98e3342a1bdff7.zip
enable nullable annotations for semantic versions (#837)
Diffstat (limited to 'src/SMAPI')
-rw-r--r--src/SMAPI/SemanticVersion.cs31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/SMAPI/SemanticVersion.cs b/src/SMAPI/SemanticVersion.cs
index 4e484633..7a6cdcdd 100644
--- a/src/SMAPI/SemanticVersion.cs
+++ b/src/SMAPI/SemanticVersion.cs
@@ -1,6 +1,5 @@
-#nullable disable
-
using System;
+using System.Diagnostics.CodeAnalysis;
using Newtonsoft.Json;
namespace StardewModdingAPI
@@ -28,10 +27,10 @@ namespace StardewModdingAPI
public int PatchVersion => this.Version.PatchVersion;
/// <inheritdoc />
- public string PrereleaseTag => this.Version.PrereleaseTag;
+ public string? PrereleaseTag => this.Version.PrereleaseTag;
/// <inheritdoc />
- public string BuildMetadata => this.Version.BuildMetadata;
+ public string? BuildMetadata => this.Version.BuildMetadata;
/*********
@@ -43,7 +42,7 @@ namespace StardewModdingAPI
/// <param name="patchVersion">The patch version for backwards-compatible bug fixes.</param>
/// <param name="prereleaseTag">An optional prerelease tag.</param>
/// <param name="buildMetadata">Optional build metadata. This is ignored when determining version precedence.</param>
- public SemanticVersion(int majorVersion, int minorVersion, int patchVersion, string prereleaseTag = null, string buildMetadata = null)
+ public SemanticVersion(int majorVersion, int minorVersion, int patchVersion, string? prereleaseTag = null, string? buildMetadata = null)
: this(majorVersion, minorVersion, patchVersion, 0, prereleaseTag, buildMetadata) { }
/// <summary>Construct an instance.</summary>
@@ -54,7 +53,7 @@ namespace StardewModdingAPI
/// <param name="platformRelease">The platform-specific version (if applicable).</param>
/// <param name="buildMetadata">Optional build metadata. This is ignored when determining version precedence.</param>
[JsonConstructor]
- internal SemanticVersion(int majorVersion, int minorVersion, int patchVersion, int platformRelease, string prereleaseTag = null, string buildMetadata = null)
+ internal SemanticVersion(int majorVersion, int minorVersion, int patchVersion, int platformRelease, string? prereleaseTag = null, string? buildMetadata = null)
: this(new Toolkit.SemanticVersion(majorVersion, minorVersion, patchVersion, platformRelease, prereleaseTag, buildMetadata)) { }
/// <summary>Construct an instance.</summary>
@@ -93,49 +92,49 @@ namespace StardewModdingAPI
/// <inheritdoc />
/// <remarks>The implementation is defined by Semantic Version 2.0 (https://semver.org/).</remarks>
- public int CompareTo(ISemanticVersion other)
+ public int CompareTo(ISemanticVersion? other)
{
return this.Version.CompareTo(other);
}
/// <inheritdoc />
- public bool IsOlderThan(ISemanticVersion other)
+ public bool IsOlderThan(ISemanticVersion? other)
{
return this.Version.IsOlderThan(other);
}
/// <inheritdoc />
- public bool IsOlderThan(string other)
+ public bool IsOlderThan(string? other)
{
return this.Version.IsOlderThan(other);
}
/// <inheritdoc />
- public bool IsNewerThan(ISemanticVersion other)
+ public bool IsNewerThan(ISemanticVersion? other)
{
return this.Version.IsNewerThan(other);
}
/// <inheritdoc />
- public bool IsNewerThan(string other)
+ public bool IsNewerThan(string? other)
{
return this.Version.IsNewerThan(other);
}
/// <inheritdoc />
- public bool IsBetween(ISemanticVersion min, ISemanticVersion max)
+ public bool IsBetween(ISemanticVersion? min, ISemanticVersion? max)
{
return this.Version.IsBetween(min, max);
}
/// <inheritdoc />
- public bool IsBetween(string min, string max)
+ public bool IsBetween(string? min, string? max)
{
return this.Version.IsBetween(min, max);
}
/// <inheritdoc />
- public bool Equals(ISemanticVersion other)
+ public bool Equals(ISemanticVersion? other)
{
return other != null && this.CompareTo(other) == 0;
}
@@ -156,9 +155,9 @@ namespace StardewModdingAPI
/// <param name="version">The version string.</param>
/// <param name="parsed">The parsed representation.</param>
/// <returns>Returns whether parsing the version succeeded.</returns>
- public static bool TryParse(string version, out ISemanticVersion parsed)
+ public static bool TryParse(string version, [NotNullWhen(true)] out ISemanticVersion? parsed)
{
- if (Toolkit.SemanticVersion.TryParse(version, out ISemanticVersion versionImpl))
+ if (Toolkit.SemanticVersion.TryParse(version, out ISemanticVersion? versionImpl))
{
parsed = new SemanticVersion(versionImpl);
return true;