diff options
Diffstat (limited to 'src/SMAPI.Toolkit')
-rw-r--r-- | src/SMAPI.Toolkit/SMAPI.Toolkit.csproj | 2 | ||||
-rw-r--r-- | src/SMAPI.Toolkit/SemanticVersion.cs | 14 | ||||
-rw-r--r-- | src/SMAPI.Toolkit/Serialization/Models/Manifest.cs | 2 | ||||
-rw-r--r-- | src/SMAPI.Toolkit/Serialization/Models/ManifestContentPackFor.cs | 2 | ||||
-rw-r--r-- | src/SMAPI.Toolkit/Serialization/Models/ManifestDependency.cs | 2 | ||||
-rw-r--r-- | src/SMAPI.Toolkit/Utilities/PathUtilities.cs | 36 |
6 files changed, 3 insertions, 55 deletions
diff --git a/src/SMAPI.Toolkit/SMAPI.Toolkit.csproj b/src/SMAPI.Toolkit/SMAPI.Toolkit.csproj index ec27bf79..6a8c4c43 100644 --- a/src/SMAPI.Toolkit/SMAPI.Toolkit.csproj +++ b/src/SMAPI.Toolkit/SMAPI.Toolkit.csproj @@ -2,7 +2,7 @@ <PropertyGroup> <RootNamespace>StardewModdingAPI.Toolkit</RootNamespace> <Description>A library which encapsulates mod-handling logic for mod managers and tools. Not intended for use by mods.</Description> - <TargetFrameworks>net5.0; netstandard2.0</TargetFrameworks> + <TargetFrameworks>net5.0</TargetFrameworks> <GenerateDocumentationFile>true</GenerateDocumentationFile> </PropertyGroup> diff --git a/src/SMAPI.Toolkit/SemanticVersion.cs b/src/SMAPI.Toolkit/SemanticVersion.cs index cea8c447..ca9d15f5 100644 --- a/src/SMAPI.Toolkit/SemanticVersion.cs +++ b/src/SMAPI.Toolkit/SemanticVersion.cs @@ -198,12 +198,7 @@ namespace StardewModdingAPI.Toolkit /// <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, -#if NET5_0_OR_GREATER - [NotNullWhen(true)] -#endif - out ISemanticVersion? parsed - ) + public static bool TryParse(string? version, [NotNullWhen(true)] out ISemanticVersion? parsed) { return SemanticVersion.TryParse(version, allowNonStandard: false, out parsed); } @@ -213,12 +208,7 @@ namespace StardewModdingAPI.Toolkit /// <param name="allowNonStandard">Whether to allow non-standard extensions to semantic versioning.</param> /// <param name="parsed">The parsed representation.</param> /// <returns>Returns whether parsing the version succeeded.</returns> - public static bool TryParse(string? version, bool allowNonStandard, -#if NET5_0_OR_GREATER - [NotNullWhen(true)] -#endif - out ISemanticVersion? parsed - ) + public static bool TryParse(string? version, bool allowNonStandard, [NotNullWhen(true)] out ISemanticVersion? parsed) { if (version == null) { diff --git a/src/SMAPI.Toolkit/Serialization/Models/Manifest.cs b/src/SMAPI.Toolkit/Serialization/Models/Manifest.cs index 01010602..3ab5edfb 100644 --- a/src/SMAPI.Toolkit/Serialization/Models/Manifest.cs +++ b/src/SMAPI.Toolkit/Serialization/Models/Manifest.cs @@ -115,9 +115,7 @@ namespace StardewModdingAPI.Toolkit.Serialization.Models *********/ /// <summary>Normalize whitespace in a raw string.</summary> /// <param name="input">The input to strip.</param> -#if NET5_0_OR_GREATER [return: NotNullIfNotNull("input")] -#endif private string? NormalizeWhitespace(string? input) { return input diff --git a/src/SMAPI.Toolkit/Serialization/Models/ManifestContentPackFor.cs b/src/SMAPI.Toolkit/Serialization/Models/ManifestContentPackFor.cs index f7dc8aa8..dcdbcf74 100644 --- a/src/SMAPI.Toolkit/Serialization/Models/ManifestContentPackFor.cs +++ b/src/SMAPI.Toolkit/Serialization/Models/ManifestContentPackFor.cs @@ -33,9 +33,7 @@ namespace StardewModdingAPI.Toolkit.Serialization.Models *********/ /// <summary>Normalize whitespace in a raw string.</summary> /// <param name="input">The input to strip.</param> -#if NET5_0_OR_GREATER [return: NotNullIfNotNull("input")] -#endif private string? NormalizeWhitespace(string? input) { return input?.Trim(); diff --git a/src/SMAPI.Toolkit/Serialization/Models/ManifestDependency.cs b/src/SMAPI.Toolkit/Serialization/Models/ManifestDependency.cs index e7acf71d..64725818 100644 --- a/src/SMAPI.Toolkit/Serialization/Models/ManifestDependency.cs +++ b/src/SMAPI.Toolkit/Serialization/Models/ManifestDependency.cs @@ -54,9 +54,7 @@ namespace StardewModdingAPI.Toolkit.Serialization.Models *********/ /// <summary>Normalize whitespace in a raw string.</summary> /// <param name="input">The input to strip.</param> -#if NET5_0_OR_GREATER [return: NotNullIfNotNull("input")] -#endif private string? NormalizeWhitespace(string? input) { return input?.Trim(); diff --git a/src/SMAPI.Toolkit/Utilities/PathUtilities.cs b/src/SMAPI.Toolkit/Utilities/PathUtilities.cs index 9a0e2ea7..d035d4cd 100644 --- a/src/SMAPI.Toolkit/Utilities/PathUtilities.cs +++ b/src/SMAPI.Toolkit/Utilities/PathUtilities.cs @@ -92,43 +92,7 @@ namespace StardewModdingAPI.Toolkit.Utilities [Pure] public static string GetRelativePath(string sourceDir, string targetPath) { -#if NET5_0 return Path.GetRelativePath(sourceDir, targetPath); -#else - // NOTE: - // this is a heuristic implementation that works in the cases SMAPI needs it for, but it - // doesn't handle all edge cases (e.g. case-sensitivity on Linux, or traversing between - // UNC paths on Windows). SMAPI and mods will use the more robust .NET 5 version anyway - // though, this is only for compatibility with the mod build package. - - // convert to URIs - Uri from = new(sourceDir.TrimEnd(PathUtilities.PossiblePathSeparators) + "/"); - Uri to = new(targetPath.TrimEnd(PathUtilities.PossiblePathSeparators) + "/"); - if (from.Scheme != to.Scheme) - throw new InvalidOperationException($"Can't get path for '{targetPath}' relative to '{sourceDir}'."); - - // get relative path - string rawUrl = Uri.UnescapeDataString(from.MakeRelativeUri(to).ToString()); - if (rawUrl.StartsWith("file://")) - rawUrl = PathUtilities.WindowsUncRoot + rawUrl.Substring("file://".Length); - string relative = PathUtilities.NormalizePath(rawUrl); - - // normalize - if (relative == "") - relative = "."; - else - { - // trim trailing slash from URL - if (relative.EndsWith(PathUtilities.PreferredPathSeparator.ToString())) - relative = relative.Substring(0, relative.Length - 1); - - // fix root - if (relative.StartsWith("file:") && !targetPath.Contains("file:")) - relative = relative.Substring("file:".Length); - } - - return relative; -#endif } /// <summary>Get whether a path is relative and doesn't try to climb out of its containing folder (e.g. doesn't contain <c>../</c>).</summary> |