summaryrefslogtreecommitdiff
path: root/src/SMAPI.Toolkit
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI.Toolkit')
-rw-r--r--src/SMAPI.Toolkit/Framework/Clients/WebApi/WebApiClient.cs4
-rw-r--r--src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiClient.cs2
-rw-r--r--src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs4
-rw-r--r--src/SMAPI.Toolkit/Framework/LowLevelEnvironmentUtility.cs2
-rw-r--r--src/SMAPI.Toolkit/Framework/ModData/ModDataRecord.cs2
-rw-r--r--src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs12
-rw-r--r--src/SMAPI.Toolkit/ModToolkit.cs2
-rw-r--r--src/SMAPI.Toolkit/SemanticVersionComparer.cs2
-rw-r--r--src/SMAPI.Toolkit/Serialization/JsonHelper.cs2
-rw-r--r--src/SMAPI.Toolkit/Utilities/PathUtilities.cs4
10 files changed, 18 insertions, 18 deletions
diff --git a/src/SMAPI.Toolkit/Framework/Clients/WebApi/WebApiClient.cs b/src/SMAPI.Toolkit/Framework/Clients/WebApi/WebApiClient.cs
index c2d906a0..f7d26d21 100644
--- a/src/SMAPI.Toolkit/Framework/Clients/WebApi/WebApiClient.cs
+++ b/src/SMAPI.Toolkit/Framework/Clients/WebApi/WebApiClient.cs
@@ -62,9 +62,9 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi
private TResult Post<TBody, TResult>(string url, TBody content)
{
// note: avoid HttpClient for macOS compatibility
- using WebClient client = new WebClient();
+ using WebClient client = new();
- Uri fullUrl = new Uri(this.BaseUrl, url);
+ Uri fullUrl = new(this.BaseUrl, url);
string data = JsonConvert.SerializeObject(content);
client.Headers["Content-Type"] = "application/json";
diff --git a/src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiClient.cs b/src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiClient.cs
index 0f5a0ec3..abbcdc81 100644
--- a/src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiClient.cs
+++ b/src/SMAPI.Toolkit/Framework/Clients/Wiki/WikiClient.cs
@@ -127,7 +127,7 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.Wiki
string pullRequestUrl = this.GetAttribute(node, "data-pr");
// parse stable compatibility
- WikiCompatibilityInfo compatibility = new WikiCompatibilityInfo
+ WikiCompatibilityInfo compatibility = new()
{
Status = this.GetAttributeAsEnum<WikiCompatibilityStatus>(node, "data-status") ?? WikiCompatibilityStatus.Ok,
BrokeIn = this.GetAttribute(node, "data-broke-in"),
diff --git a/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs b/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs
index 8d4198de..768beba1 100644
--- a/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs
+++ b/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs
@@ -45,7 +45,7 @@ namespace StardewModdingAPI.Toolkit.Framework.GameScanning
// yield valid folders
foreach (string path in paths)
{
- DirectoryInfo folder = new DirectoryInfo(path);
+ DirectoryInfo folder = new(path);
if (this.LooksLikeGameFolder(folder))
yield return folder;
}
@@ -191,7 +191,7 @@ namespace StardewModdingAPI.Toolkit.Framework.GameScanning
yield break;
// get targets file
- FileInfo file = new FileInfo(Path.Combine(homePath, "stardewvalley.targets"));
+ FileInfo file = new(Path.Combine(homePath, "stardewvalley.targets"));
if (!file.Exists)
yield break;
diff --git a/src/SMAPI.Toolkit/Framework/LowLevelEnvironmentUtility.cs b/src/SMAPI.Toolkit/Framework/LowLevelEnvironmentUtility.cs
index 8b6eb5fb..c0332331 100644
--- a/src/SMAPI.Toolkit/Framework/LowLevelEnvironmentUtility.cs
+++ b/src/SMAPI.Toolkit/Framework/LowLevelEnvironmentUtility.cs
@@ -98,7 +98,7 @@ namespace StardewModdingAPI.Toolkit.Framework
/// </remarks>
private static bool IsRunningAndroid()
{
- using Process process = new Process
+ using Process process = new()
{
StartInfo =
{
diff --git a/src/SMAPI.Toolkit/Framework/ModData/ModDataRecord.cs b/src/SMAPI.Toolkit/Framework/ModData/ModDataRecord.cs
index 5dd32acf..7e07ffde 100644
--- a/src/SMAPI.Toolkit/Framework/ModData/ModDataRecord.cs
+++ b/src/SMAPI.Toolkit/Framework/ModData/ModDataRecord.cs
@@ -82,7 +82,7 @@ namespace StardewModdingAPI.Toolkit.Framework.ModData
/// <param name="manifest">The manifest to match.</param>
public ModDataRecordVersionedFields GetVersionedFields(IManifest manifest)
{
- ModDataRecordVersionedFields parsed = new ModDataRecordVersionedFields { DisplayName = this.DisplayName, DataRecord = this };
+ ModDataRecordVersionedFields parsed = new() { DisplayName = this.DisplayName, DataRecord = this };
foreach (ModDataField field in this.Fields.Where(field => field.IsMatch(manifest)))
{
switch (field.Key)
diff --git a/src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs b/src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs
index e6105f9c..d21ccec0 100644
--- a/src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs
+++ b/src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs
@@ -18,7 +18,7 @@ namespace StardewModdingAPI.Toolkit.Framework.ModScanning
private readonly JsonHelper JsonHelper;
/// <summary>A list of filesystem entry names to ignore when checking whether a folder should be treated as a mod.</summary>
- private readonly HashSet<Regex> IgnoreFilesystemNames = new HashSet<Regex>
+ private readonly HashSet<Regex> IgnoreFilesystemNames = new()
{
new Regex(@"^__folder_managed_by_vortex$", RegexOptions.Compiled | RegexOptions.IgnoreCase), // Vortex mod manager
new Regex(@"(?:^\._|^\.DS_Store$|^__MACOSX$|^mcs$)", RegexOptions.Compiled | RegexOptions.IgnoreCase), // macOS
@@ -26,7 +26,7 @@ namespace StardewModdingAPI.Toolkit.Framework.ModScanning
};
/// <summary>A list of file extensions to ignore when searching for mod files.</summary>
- private readonly HashSet<string> IgnoreFileExtensions = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
+ private readonly HashSet<string> IgnoreFileExtensions = new(StringComparer.OrdinalIgnoreCase)
{
// text
".doc",
@@ -60,7 +60,7 @@ namespace StardewModdingAPI.Toolkit.Framework.ModScanning
};
/// <summary>The extensions for packed content files.</summary>
- private readonly HashSet<string> StrictXnbModExtensions = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
+ private readonly HashSet<string> StrictXnbModExtensions = new(StringComparer.OrdinalIgnoreCase)
{
".xgs",
".xnb",
@@ -69,7 +69,7 @@ namespace StardewModdingAPI.Toolkit.Framework.ModScanning
};
/// <summary>The extensions for files which an XNB mod may contain, in addition to <see cref="StrictXnbModExtensions"/>.</summary>
- private readonly HashSet<string> PotentialXnbModExtensions = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
+ private readonly HashSet<string> PotentialXnbModExtensions = new(StringComparer.OrdinalIgnoreCase)
{
".json",
".yaml"
@@ -96,7 +96,7 @@ namespace StardewModdingAPI.Toolkit.Framework.ModScanning
/// <param name="rootPath">The root folder containing mods.</param>
public IEnumerable<ModFolder> GetModFolders(string rootPath)
{
- DirectoryInfo root = new DirectoryInfo(rootPath);
+ DirectoryInfo root = new(rootPath);
return this.GetModFolders(root, root);
}
@@ -260,7 +260,7 @@ namespace StardewModdingAPI.Toolkit.Framework.ModScanning
while (true)
{
// check for manifest in current folder
- FileInfo file = new FileInfo(Path.Combine(folder.FullName, "manifest.json"));
+ FileInfo file = new(Path.Combine(folder.FullName, "manifest.json"));
if (file.Exists)
return file;
diff --git a/src/SMAPI.Toolkit/ModToolkit.cs b/src/SMAPI.Toolkit/ModToolkit.cs
index 38a67ae5..80008df7 100644
--- a/src/SMAPI.Toolkit/ModToolkit.cs
+++ b/src/SMAPI.Toolkit/ModToolkit.cs
@@ -34,7 +34,7 @@ namespace StardewModdingAPI.Toolkit
** Accessors
*********/
/// <summary>Encapsulates SMAPI's JSON parsing.</summary>
- public JsonHelper JsonHelper { get; } = new JsonHelper();
+ public JsonHelper JsonHelper { get; } = new();
/*********
diff --git a/src/SMAPI.Toolkit/SemanticVersionComparer.cs b/src/SMAPI.Toolkit/SemanticVersionComparer.cs
index 9f6b57a2..8eba2c9f 100644
--- a/src/SMAPI.Toolkit/SemanticVersionComparer.cs
+++ b/src/SMAPI.Toolkit/SemanticVersionComparer.cs
@@ -9,7 +9,7 @@ namespace StardewModdingAPI.Toolkit
** Accessors
*********/
/// <summary>A singleton instance of the comparer.</summary>
- public static SemanticVersionComparer Instance { get; } = new SemanticVersionComparer();
+ public static SemanticVersionComparer Instance { get; } = new();
/*********
diff --git a/src/SMAPI.Toolkit/Serialization/JsonHelper.cs b/src/SMAPI.Toolkit/Serialization/JsonHelper.cs
index 00db9903..5c465f3c 100644
--- a/src/SMAPI.Toolkit/Serialization/JsonHelper.cs
+++ b/src/SMAPI.Toolkit/Serialization/JsonHelper.cs
@@ -14,7 +14,7 @@ namespace StardewModdingAPI.Toolkit.Serialization
** Accessors
*********/
/// <summary>The JSON settings to use when serializing and deserializing files.</summary>
- public JsonSerializerSettings JsonSettings { get; } = new JsonSerializerSettings
+ public JsonSerializerSettings JsonSettings { get; } = new()
{
Formatting = Formatting.Indented,
ObjectCreationHandling = ObjectCreationHandling.Replace, // avoid issue where default ICollection<T> values are duplicated each time the config is loaded
diff --git a/src/SMAPI.Toolkit/Utilities/PathUtilities.cs b/src/SMAPI.Toolkit/Utilities/PathUtilities.cs
index 2e9e5eac..85e12bfa 100644
--- a/src/SMAPI.Toolkit/Utilities/PathUtilities.cs
+++ b/src/SMAPI.Toolkit/Utilities/PathUtilities.cs
@@ -100,8 +100,8 @@ namespace StardewModdingAPI.Toolkit.Utilities
// though, this is only for compatibility with the mod build package.
// convert to URIs
- Uri from = new Uri(sourceDir.TrimEnd(PathUtilities.PossiblePathSeparators) + "/");
- Uri to = new Uri(targetPath.TrimEnd(PathUtilities.PossiblePathSeparators) + "/");
+ 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}'.");