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 Jun 1, 2022
2 parents 0209e70 + 1cded44 commit e10147e
Show file tree
Hide file tree
Showing 21 changed files with 297 additions and 103 deletions.
6 changes: 4 additions & 2 deletions build/common.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!--set general build properties -->
<Version>3.14.6</Version>
<Version>3.14.7</Version>
<Product>SMAPI</Product>
<LangVersion>latest</LangVersion>
<AssemblySearchPaths>$(AssemblySearchPaths);{GAC}</AssemblySearchPaths>
Expand Down Expand Up @@ -69,8 +69,10 @@
<Copy SourceFiles="$(TargetDir)\MonoMod.Common.dll" DestinationFolder="$(GamePath)\smapi-internal" />

<!-- .NET dependencies -->
<Copy SourceFiles="$(TargetDir)\System.Configuration.ConfigurationManager.dll" DestinationFolder="$(GamePath)\smapi-internal" />
<Copy SourceFiles="$(TargetDir)\System.Management.dll" DestinationFolder="$(GamePath)\smapi-internal" Condition="$(OS) == 'Windows_NT'" />

<!-- Legacy .NET dependencies (remove in SMAPI 4.0.0) -->
<Copy SourceFiles="$(TargetDir)\System.Configuration.ConfigurationManager.dll" DestinationFolder="$(GamePath)\smapi-internal" />
<Copy SourceFiles="$(TargetDir)\System.Runtime.Caching.dll" DestinationFolder="$(GamePath)\smapi-internal" />
<Copy SourceFiles="$(TargetDir)\System.Security.Permissions.dll" DestinationFolder="$(GamePath)\smapi-internal" />
</Target>
Expand Down
9 changes: 5 additions & 4 deletions build/unix/prepare-install-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,20 @@ for folder in ${folders[@]}; do
cp "$smapiBin/SMAPI.metadata.json" "$bundlePath/smapi-internal/metadata.json"
if [ $folder == "linux" ] || [ $folder == "macOS" ]; then
cp "$installAssets/unix-launcher.sh" "$bundlePath"
cp "$smapiBin/System.Runtime.Caching.dll" "$bundlePath/smapi-internal"
else
cp "$installAssets/windows-exe-config.xml" "$bundlePath/StardewModdingAPI.exe.config"
fi

# copy .NET dependencies
cp "$smapiBin/System.Configuration.ConfigurationManager.dll" "$bundlePath/smapi-internal"
cp "$smapiBin/System.Runtime.Caching.dll" "$bundlePath/smapi-internal"
cp "$smapiBin/System.Security.Permissions.dll" "$bundlePath/smapi-internal"
if [ $folder == "windows" ]; then
cp "$smapiBin/System.Management.dll" "$bundlePath/smapi-internal"
fi

# copy legacy .NET dependencies (remove in SMAPI 4.0.0)
cp "$smapiBin/System.Configuration.ConfigurationManager.dll" "$bundlePath/smapi-internal"
cp "$smapiBin/System.Runtime.Caching.dll" "$bundlePath/smapi-internal"
cp "$smapiBin/System.Security.Permissions.dll" "$bundlePath/smapi-internal"

# copy bundled mods
for modName in ${bundleModNames[@]}; do
fromPath="src/SMAPI.Mods.$modName/bin/$buildConfig/$runtime/publish"
Expand Down
9 changes: 5 additions & 4 deletions build/windows/prepare-install-package.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -162,20 +162,21 @@ foreach ($folder in $folders) {
cp "$smapiBin/SMAPI.metadata.json" "$bundlePath/smapi-internal/metadata.json"
if ($folder -eq "linux" -or $folder -eq "macOS") {
cp "$installAssets/unix-launcher.sh" "$bundlePath"
cp "$smapiBin/System.Runtime.Caching.dll" "$bundlePath/smapi-internal"
}
else {
cp "$installAssets/windows-exe-config.xml" "$bundlePath/StardewModdingAPI.exe.config"
}

# copy .NET dependencies
cp "$smapiBin/System.Configuration.ConfigurationManager.dll" "$bundlePath/smapi-internal"
cp "$smapiBin/System.Runtime.Caching.dll" "$bundlePath/smapi-internal"
cp "$smapiBin/System.Security.Permissions.dll" "$bundlePath/smapi-internal"
if ($folder -eq "windows") {
cp "$smapiBin/System.Management.dll" "$bundlePath/smapi-internal"
}

# copy legacy .NET dependencies (remove in SMAPI 4.0.0)
cp "$smapiBin/System.Configuration.ConfigurationManager.dll" "$bundlePath/smapi-internal"
cp "$smapiBin/System.Runtime.Caching.dll" "$bundlePath/smapi-internal"
cp "$smapiBin/System.Security.Permissions.dll" "$bundlePath/smapi-internal"

# copy bundled mods
foreach ($modName in $bundleModNames) {
$fromPath = "src/SMAPI.Mods.$modName/bin/$buildConfig/$runtime/publish"
Expand Down
8 changes: 8 additions & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
[README](README.md)

# Release notes
## 3.14.7
Released 01 June 2022 for Stardew Valley 1.5.6 or later.

* For players:
* Optimized reflection cache to reduce frame skips for some players.
* For mod authors:
* Removed `runtimeconfig.json` setting which impacted hot reload support.

## 3.14.6
Released 27 May 2022 for Stardew Valley 1.5.6 or later.

Expand Down
5 changes: 3 additions & 2 deletions src/SMAPI.Installer/assets/runtimeconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
}
],
"configProperties": {
"System.Runtime.TieredCompilation": false,
"System.Reflection.Metadata.MetadataUpdater.IsSupported": false
// disable tiered runtime JIT: https://github.com/dotnet/runtime/blob/main/docs/design/features/tiered-compilation.md
// This is disabled by the base game, and causes issues with Harmony patches.
"System.Runtime.TieredCompilation": false
}
}
}
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.14.6",
"Version": "3.14.7",
"Description": "Adds SMAPI console commands that let you manipulate the game.",
"UniqueID": "SMAPI.ConsoleCommands",
"EntryDll": "ConsoleCommands.dll",
"MinimumApiVersion": "3.14.6"
"MinimumApiVersion": "3.14.7"
}
4 changes: 2 additions & 2 deletions src/SMAPI.Mods.ErrorHandler/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"Name": "Error Handler",
"Author": "SMAPI",
"Version": "3.14.6",
"Version": "3.14.7",
"Description": "Handles some common vanilla errors to log more useful info or avoid breaking the game.",
"UniqueID": "SMAPI.ErrorHandler",
"EntryDll": "ErrorHandler.dll",
"MinimumApiVersion": "3.14.6"
"MinimumApiVersion": "3.14.7"
}
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.14.6",
"Version": "3.14.7",
"Description": "Automatically backs up all your saves once per day into its folder.",
"UniqueID": "SMAPI.SaveBackup",
"EntryDll": "SaveBackup.dll",
"MinimumApiVersion": "3.14.6"
"MinimumApiVersion": "3.14.7"
}
11 changes: 10 additions & 1 deletion src/SMAPI.Toolkit/Framework/ModData/ModWarning.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ public enum ModWarning
AccessesFilesystem = 128,

/// <summary>Uses .NET APIs for shell or process access.</summary>
AccessesShell = 256
AccessesShell = 256,

/// <summary>References the legacy <c>System.Configuration.ConfigurationManager</c> assembly and doesn't include a copy in the mod folder, so it'll break in SMAPI 4.0.0.</summary>
DetectedLegacyConfigurationDll = 512,

/// <summary>References the legacy <c>System.Runtime.Caching</c> assembly and doesn't include a copy in the mod folder, so it'll break in SMAPI 4.0.0.</summary>
DetectedLegacyCachingDll = 1024,

/// <summary>References the legacy <c>System.Security.Permissions</c> assembly and doesn't include a copy in the mod folder, so it'll break in SMAPI 4.0.0.</summary>
DetectedLegacyPermissionsDll = 2048
}
}
2 changes: 1 addition & 1 deletion src/SMAPI/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal static class EarlyConstants
internal static int? LogScreenId { get; set; }

/// <summary>SMAPI's current raw semantic version.</summary>
internal static string RawApiVersion = "3.14.6";
internal static string RawApiVersion = "3.14.7";
}

/// <summary>Contains SMAPI's constants and assumptions.</summary>
Expand Down
4 changes: 4 additions & 0 deletions src/SMAPI/Framework/IModMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ internal interface IModMetadata : IModInfo
/// <param name="warning">The warning to set.</param>
IModMetadata SetWarning(ModWarning warning);

/// <summary>Remove a warning flag for the mod.</summary>
/// <param name="warning">The warning to remove.</param>
IModMetadata RemoveWarning(ModWarning warning);

/// <summary>Set the mod instance.</summary>
/// <param name="mod">The mod instance to set.</param>
/// <param name="translations">The translations for this mod (if loaded).</param>
Expand Down
38 changes: 38 additions & 0 deletions src/SMAPI/Framework/ModLoading/AssemblyLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,29 @@ select name
this.AssemblyDefinitionResolver.Add(assembly.Definition);
}

// special case: clear legacy-DLL warnings if the mod bundles a copy
if (mod.Warnings.HasFlag(ModWarning.DetectedLegacyCachingDll))
{
if (File.Exists(Path.Combine(mod.DirectoryPath, "System.Runtime.Caching.dll")))
mod.RemoveWarning(ModWarning.DetectedLegacyCachingDll);
else
{
// remove duplicate warnings (System.Runtime.Caching.dll references these)
mod.RemoveWarning(ModWarning.DetectedLegacyConfigurationDll);
mod.RemoveWarning(ModWarning.DetectedLegacyPermissionsDll);
}
}
if (mod.Warnings.HasFlag(ModWarning.DetectedLegacyConfigurationDll))
{
if (File.Exists(Path.Combine(mod.DirectoryPath, "System.Configuration.ConfigurationManager.dll")))
mod.RemoveWarning(ModWarning.DetectedLegacyConfigurationDll);
}
if (mod.Warnings.HasFlag(ModWarning.DetectedLegacyPermissionsDll))
{
if (File.Exists(Path.Combine(mod.DirectoryPath, "System.Security.Permissions.dll")))
mod.RemoveWarning(ModWarning.DetectedLegacyPermissionsDll);
}

// throw if incompatibilities detected
if (!assumeCompatible && mod.Warnings.HasFlag(ModWarning.BrokenCodeLoaded))
throw new IncompatibleInstructionException();
Expand Down Expand Up @@ -429,6 +452,21 @@ private void ProcessInstructionHandleResult(IModMetadata mod, IInstructionHandle
mod.SetWarning(ModWarning.AccessesShell);
break;

case InstructionHandleResult.DetectedLegacyCachingDll:
template = $"{logPrefix}Detected reference to System.Runtime.Caching.dll, which will be removed in SMAPI 4.0.0.";
mod.SetWarning(ModWarning.DetectedLegacyCachingDll);
break;

case InstructionHandleResult.DetectedLegacyConfigurationDll:
template = $"{logPrefix}Detected reference to System.Configuration.ConfigurationManager.dll, which will be removed in SMAPI 4.0.0.";
mod.SetWarning(ModWarning.DetectedLegacyConfigurationDll);
break;

case InstructionHandleResult.DetectedLegacyPermissionsDll:
template = $"{logPrefix}Detected reference to System.Security.Permissions.dll, which will be removed in SMAPI 4.0.0.";
mod.SetWarning(ModWarning.DetectedLegacyPermissionsDll);
break;

case InstructionHandleResult.None:
break;

Expand Down
49 changes: 49 additions & 0 deletions src/SMAPI/Framework/ModLoading/Finders/LegacyAssemblyFinder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using Mono.Cecil;
using StardewModdingAPI.Framework.ModLoading.Framework;

namespace StardewModdingAPI.Framework.ModLoading.Finders
{
/// <summary>Detects assembly references which will break in SMAPI 4.0.0.</summary>
internal class LegacyAssemblyFinder : BaseInstructionHandler
{
/*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>
public LegacyAssemblyFinder()
: base(defaultPhrase: "legacy assembly references") { }


/// <inheritdoc />
public override bool Handle(ModuleDefinition module)
{
foreach (AssemblyNameReference assembly in module.AssemblyReferences)
{
InstructionHandleResult flag = this.GetFlag(assembly);
if (flag is InstructionHandleResult.None)
continue;

this.MarkFlag(flag);
}

return false;
}


/*********
** Private methods
*********/
/// <summary>Get the instruction handle flag for the given assembly reference, if any.</summary>
/// <param name="assemblyRef">The assembly reference.</param>
private InstructionHandleResult GetFlag(AssemblyNameReference assemblyRef)
{
return assemblyRef.Name switch
{
"System.Configuration.ConfigurationManager" => InstructionHandleResult.DetectedLegacyConfigurationDll,
"System.Runtime.Caching" => InstructionHandleResult.DetectedLegacyCachingDll,
"System.Security.Permission" => InstructionHandleResult.DetectedLegacyPermissionsDll,
_ => InstructionHandleResult.None
};
}
}
}
11 changes: 10 additions & 1 deletion src/SMAPI/Framework/ModLoading/InstructionHandleResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ internal enum InstructionHandleResult
DetectedFilesystemAccess,

/// <summary>The instruction accesses the OS shell or processes directly.</summary>
DetectedShellAccess
DetectedShellAccess,

/// <summary>The module references the legacy <c>System.Configuration.ConfigurationManager</c> assembly and doesn't include a copy in the mod folder, so it'll break in SMAPI 4.0.0.</summary>
DetectedLegacyConfigurationDll,

/// <summary>The module references the legacy <c>System.Runtime.Caching</c> assembly and doesn't include a copy in the mod folder, so it'll break in SMAPI 4.0.0.</summary>
DetectedLegacyCachingDll,

/// <summary>The module references the legacy <c>System.Security.Permissions</c> assembly and doesn't include a copy in the mod folder, so it'll break in SMAPI 4.0.0.</summary>
DetectedLegacyPermissionsDll
}
}
7 changes: 7 additions & 0 deletions src/SMAPI/Framework/ModLoading/ModMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ public IModMetadata SetWarning(ModWarning warning)
return this;
}

/// <inheritdoc />
public IModMetadata RemoveWarning(ModWarning warning)
{
this.ActualWarnings &= ~warning;
return this;
}

/// <inheritdoc />
public IModMetadata SetMod(IMod mod, TranslationHelper translations)
{
Expand Down
30 changes: 0 additions & 30 deletions src/SMAPI/Framework/Reflection/CacheEntry.cs

This file was deleted.

Loading

0 comments on commit e10147e

Please sign in to comment.