Skip to content

Commit

Permalink
Merge branch 'develop' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
Pathoschild committed Nov 21, 2020
2 parents e20d26a + a0cb83e commit 85b947d
Show file tree
Hide file tree
Showing 19 changed files with 1,350 additions and 1,243 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ csharp_style_expression_bodied_accessors = true:suggestion
csharp_style_inlined_variable_declaration = true:warning

# avoid superfluous braces
csharp_prefer_braces = false:suggestion
csharp_prefer_braces = false:hint

##########
## Column guidelines
Expand Down
2 changes: 1 addition & 1 deletion build/common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<!--set properties -->
<PropertyGroup>
<Version>3.7.5</Version>
<Version>3.7.6</Version>
<Product>SMAPI</Product>

<LangVersion>latest</LangVersion>
Expand Down
1,128 changes: 1,128 additions & 0 deletions docs/release-notes-archived.md

Large diffs are not rendered by default.

1,140 changes: 17 additions & 1,123 deletions docs/release-notes.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="2.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0">
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ internal class SearchableItem
/// <summary>The item type.</summary>
public ItemType Type { get; }

/// <summary>The item instance.</summary>
/// <summary>A sample item instance.</summary>
public Item Item { get; }

/// <summary>Create an item instance.</summary>
public Func<Item> CreateItem { get; }

/// <summary>The item's unique ID for its type.</summary>
public int ID { get; }

Expand All @@ -31,12 +34,23 @@ internal class SearchableItem
/// <summary>Construct an instance.</summary>
/// <param name="type">The item type.</param>
/// <param name="id">The unique ID (if different from the item's parent sheet index).</param>
/// <param name="item">The item instance.</param>
public SearchableItem(ItemType type, int id, Item item)
/// <param name="createItem">Create an item instance.</param>
public SearchableItem(ItemType type, int id, Func<SearchableItem, Item> createItem)
{
this.Type = type;
this.ID = id;
this.Item = item;
this.CreateItem = () => createItem(this);
this.Item = createItem(this);
}

/// <summary>Construct an instance.</summary>
/// <param name="item">The item metadata to copy.</param>
public SearchableItem(SearchableItem item)
{
this.Type = item.Type;
this.ID = item.ID;
this.CreateItem = item.CreateItem;
this.Item = item.Item;
}

/// <summary>Get whether the item name contains a case-insensitive substring.</summary>
Expand Down
194 changes: 127 additions & 67 deletions src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/SMAPI.Mods.ConsoleCommands/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"Name": "Console Commands",
"Author": "SMAPI",
"Version": "3.7.5",
"Version": "3.7.6",
"Description": "Adds SMAPI console commands that let you manipulate the game.",
"UniqueID": "SMAPI.ConsoleCommands",
"EntryDll": "ConsoleCommands.dll",
"MinimumApiVersion": "3.7.5"
"MinimumApiVersion": "3.7.6"
}
4 changes: 2 additions & 2 deletions src/SMAPI.Mods.SaveBackup/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"Name": "Save Backup",
"Author": "SMAPI",
"Version": "3.7.5",
"Version": "3.7.6",
"Description": "Automatically backs up all your saves once per day into its folder.",
"UniqueID": "SMAPI.SaveBackup",
"EntryDll": "SaveBackup.dll",
"MinimumApiVersion": "3.7.5"
"MinimumApiVersion": "3.7.6"
}
2 changes: 1 addition & 1 deletion src/SMAPI.Tests/SMAPI.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Moq" Version="4.14.6" />
<PackageReference Include="Moq" Version="4.15.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="NUnit" Version="3.12.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/SMAPI.Toolkit/SMAPI.Toolkit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.11.24" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.28" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Pathoschild.Http.FluentClient" Version="4.0.0" />
<PackageReference Include="System.Management" Version="4.5.0" Condition="'$(OS)' == 'Windows_NT'" />
Expand Down
8 changes: 4 additions & 4 deletions src/SMAPI.Web/SMAPI.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Azure.Storage.Blobs" Version="12.6.0" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.7.14" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.7.0" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.7.17" />
<PackageReference Include="Hangfire.MemoryStorage" Version="1.7.0" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.24" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.28" />
<PackageReference Include="Humanizer.Core" Version="2.8.26" />
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
<PackageReference Include="Markdig" Version="0.21.1" />
<PackageReference Include="Markdig" Version="0.22.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.8" />
<PackageReference Include="Newtonsoft.Json.Schema" Version="3.0.13" />
<PackageReference Include="Pathoschild.FluentNexus" Version="1.0.1" />
Expand Down
1 change: 1 addition & 0 deletions src/SMAPI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{EB35A917-6
ProjectSection(SolutionItems) = preProject
..\docs\mod-build-config.md = ..\docs\mod-build-config.md
..\docs\README.md = ..\docs\README.md
..\docs\release-notes-archived.md = ..\docs\release-notes-archived.md
..\docs\release-notes.md = ..\docs\release-notes.md
EndProjectSection
EndProject
Expand Down
2 changes: 1 addition & 1 deletion src/SMAPI/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static class Constants
** Public
****/
/// <summary>SMAPI's current semantic version.</summary>
public static ISemanticVersion ApiVersion { get; } = new Toolkit.SemanticVersion("3.7.5");
public static ISemanticVersion ApiVersion { get; } = new Toolkit.SemanticVersion("3.7.6");

/// <summary>The minimum supported version of Stardew Valley.</summary>
public static ISemanticVersion MinimumGameVersion { get; } = new GameVersion("1.4.1");
Expand Down
4 changes: 2 additions & 2 deletions src/SMAPI/Framework/Commands/HarmonySummaryCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ private IEnumerable<SearchResult> FilterPatches(string[] searchTerms)
private IEnumerable<SearchResult> GetAllPatches()
{
#if HARMONY_2
foreach (MethodBase method in Harmony.GetAllPatchedMethods())
foreach (MethodBase method in Harmony.GetAllPatchedMethods().ToArray())
#else
foreach (MethodBase method in this.HarmonyInstance.GetPatchedMethods())
foreach (MethodBase method in this.HarmonyInstance.GetPatchedMethods().ToArray())
#endif
{
// get metadata for method
Expand Down
15 changes: 10 additions & 5 deletions src/SMAPI/Framework/Logging/LogManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,10 @@ public void WriteCrashLog()

/// <summary>Write an update alert marker file.</summary>
/// <param name="version">The new version found.</param>
public void WriteUpdateMarker(string version)
/// <param name="url">The download URL for the update.</param>
public void WriteUpdateMarker(string version, string url)
{
File.WriteAllText(Constants.UpdateMarker, version);
File.WriteAllText(Constants.UpdateMarker, $"{version}|{url}");
}

/// <summary>Check whether SMAPI crashed or detected an update during the last session, and display them in the SMAPI console.</summary>
Expand All @@ -206,13 +207,17 @@ public void HandleMarkerFiles()
// show update alert
if (File.Exists(Constants.UpdateMarker))
{
string rawUpdateFound = File.ReadAllText(Constants.UpdateMarker);
if (SemanticVersion.TryParse(rawUpdateFound, out ISemanticVersion updateFound))
string[] rawUpdateFound = File.ReadAllText(Constants.UpdateMarker).Split(new [] { '|' }, 2);
if (SemanticVersion.TryParse(rawUpdateFound[0], out ISemanticVersion updateFound))
{
if (Constants.ApiVersion.IsPrerelease() && updateFound.IsNewerThan(Constants.ApiVersion))
{
string url = rawUpdateFound.Length > 1
? rawUpdateFound[1]
: Constants.HomePageUrl;

this.Monitor.Log("A new version of SMAPI was detected last time you played.", LogLevel.Error);
this.Monitor.Log($"You can update to {updateFound}: https://smapi.io.", LogLevel.Error);
this.Monitor.Log($"You can update to {updateFound}: {url}.", LogLevel.Error);
this.Monitor.Log("Press any key to continue playing anyway. (This only appears when using a SMAPI beta.)", LogLevel.Info);
Console.ReadKey();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private bool ShouldValidate(TypeReference type)
private bool TryRewriteToProperty(ModuleDefinition module, Instruction instruction, FieldReference fieldRef, TypeDefinition declaringType, bool isRead)
{
// get equivalent property
PropertyDefinition property = declaringType.Properties.FirstOrDefault(p => p.Name == fieldRef.Name);
PropertyDefinition property = declaringType?.Properties.FirstOrDefault(p => p.Name == fieldRef.Name);
MethodDefinition method = isRead ? property?.GetMethod : property?.SetMethod;
if (method == null)
return false;
Expand Down
57 changes: 31 additions & 26 deletions src/SMAPI/Framework/SCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1195,37 +1195,42 @@ private void CheckForUpdatesAsync(IModMetadata[] mods)
this.Monitor.Log("Checking for updates...");

// check SMAPI version
ISemanticVersion updateFound = null;
try
{
// fetch update check
ModEntryModel response = client.GetModInfo(new[] { new ModSearchEntryModel("Pathoschild.SMAPI", Constants.ApiVersion, new[] { $"GitHub:{this.Settings.GitHubProjectName}" }) }, apiVersion: Constants.ApiVersion, gameVersion: Constants.GameVersion, platform: Constants.Platform).Single().Value;
if (response.SuggestedUpdate != null)
this.Monitor.Log($"You can update SMAPI to {response.SuggestedUpdate.Version}: {Constants.HomePageUrl}", LogLevel.Alert);
else
this.Monitor.Log(" SMAPI okay.");

updateFound = response.SuggestedUpdate?.Version;
ISemanticVersion updateFound = null;
string updateUrl = null;
try
{
// fetch update check
ModEntryModel response = client.GetModInfo(new[] { new ModSearchEntryModel("Pathoschild.SMAPI", Constants.ApiVersion, new[] { $"GitHub:{this.Settings.GitHubProjectName}" }) }, apiVersion: Constants.ApiVersion, gameVersion: Constants.GameVersion, platform: Constants.Platform).Single().Value;
updateFound = response.SuggestedUpdate?.Version;
updateUrl = response.SuggestedUpdate?.Url ?? Constants.HomePageUrl;

// log message
if (updateFound != null)
this.Monitor.Log($"You can update SMAPI to {updateFound}: {updateUrl}", LogLevel.Alert);
else
this.Monitor.Log(" SMAPI okay.");

// show errors
if (response.Errors.Any())
// show errors
if (response.Errors.Any())
{
this.Monitor.Log("Couldn't check for a new version of SMAPI. This won't affect your game, but you may not be notified of new versions if this keeps happening.", LogLevel.Warn);
this.Monitor.Log($"Error: {string.Join("\n", response.Errors)}");
}
}
catch (Exception ex)
{
this.Monitor.Log("Couldn't check for a new version of SMAPI. This won't affect your game, but you may not be notified of new versions if this keeps happening.", LogLevel.Warn);
this.Monitor.Log($"Error: {string.Join("\n", response.Errors)}");
this.Monitor.Log("Couldn't check for a new version of SMAPI. This won't affect your game, but you won't be notified of new versions if this keeps happening.", LogLevel.Warn);
this.Monitor.Log(ex is WebException && ex.InnerException == null
? $"Error: {ex.Message}"
: $"Error: {ex.GetLogSummary()}"
);
}
}
catch (Exception ex)
{
this.Monitor.Log("Couldn't check for a new version of SMAPI. This won't affect your game, but you won't be notified of new versions if this keeps happening.", LogLevel.Warn);
this.Monitor.Log(ex is WebException && ex.InnerException == null
? $"Error: {ex.Message}"
: $"Error: {ex.GetLogSummary()}"
);
}

// show update message on next launch
if (updateFound != null)
this.LogManager.WriteUpdateMarker(updateFound.ToString());
// show update message on next launch
if (updateFound != null)
this.LogManager.WriteUpdateMarker(updateFound.ToString(), updateUrl);
}

// check mod versions
if (mods.Any())
Expand Down
2 changes: 1 addition & 1 deletion src/SMAPI/SMAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageReference Include="LargeAddressAware" Version="1.0.5" />
<PackageReference Include="Mono.Cecil" Version="0.11.3" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Platonymous.TMXTile" Version="1.5.6" />
<PackageReference Include="Platonymous.TMXTile" Version="1.5.8" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 85b947d

Please sign in to comment.