Skip to content

Commit e10147e

Browse files
committed
Merge branch 'develop' into stable
2 parents 0209e70 + 1cded44 commit e10147e

File tree

21 files changed

+297
-103
lines changed

21 files changed

+297
-103
lines changed

build/common.targets

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22
<PropertyGroup>
33
<!--set general build properties -->
4-
<Version>3.14.6</Version>
4+
<Version>3.14.7</Version>
55
<Product>SMAPI</Product>
66
<LangVersion>latest</LangVersion>
77
<AssemblySearchPaths>$(AssemblySearchPaths);{GAC}</AssemblySearchPaths>
@@ -69,8 +69,10 @@
6969
<Copy SourceFiles="$(TargetDir)\MonoMod.Common.dll" DestinationFolder="$(GamePath)\smapi-internal" />
7070

7171
<!-- .NET dependencies -->
72-
<Copy SourceFiles="$(TargetDir)\System.Configuration.ConfigurationManager.dll" DestinationFolder="$(GamePath)\smapi-internal" />
7372
<Copy SourceFiles="$(TargetDir)\System.Management.dll" DestinationFolder="$(GamePath)\smapi-internal" Condition="$(OS) == 'Windows_NT'" />
73+
74+
<!-- Legacy .NET dependencies (remove in SMAPI 4.0.0) -->
75+
<Copy SourceFiles="$(TargetDir)\System.Configuration.ConfigurationManager.dll" DestinationFolder="$(GamePath)\smapi-internal" />
7476
<Copy SourceFiles="$(TargetDir)\System.Runtime.Caching.dll" DestinationFolder="$(GamePath)\smapi-internal" />
7577
<Copy SourceFiles="$(TargetDir)\System.Security.Permissions.dll" DestinationFolder="$(GamePath)\smapi-internal" />
7678
</Target>

build/unix/prepare-install-package.sh

+5-4
Original file line numberDiff line numberDiff line change
@@ -142,19 +142,20 @@ for folder in ${folders[@]}; do
142142
cp "$smapiBin/SMAPI.metadata.json" "$bundlePath/smapi-internal/metadata.json"
143143
if [ $folder == "linux" ] || [ $folder == "macOS" ]; then
144144
cp "$installAssets/unix-launcher.sh" "$bundlePath"
145-
cp "$smapiBin/System.Runtime.Caching.dll" "$bundlePath/smapi-internal"
146145
else
147146
cp "$installAssets/windows-exe-config.xml" "$bundlePath/StardewModdingAPI.exe.config"
148147
fi
149148

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

154+
# copy legacy .NET dependencies (remove in SMAPI 4.0.0)
155+
cp "$smapiBin/System.Configuration.ConfigurationManager.dll" "$bundlePath/smapi-internal"
156+
cp "$smapiBin/System.Runtime.Caching.dll" "$bundlePath/smapi-internal"
157+
cp "$smapiBin/System.Security.Permissions.dll" "$bundlePath/smapi-internal"
158+
158159
# copy bundled mods
159160
for modName in ${bundleModNames[@]}; do
160161
fromPath="src/SMAPI.Mods.$modName/bin/$buildConfig/$runtime/publish"

build/windows/prepare-install-package.ps1

+5-4
Original file line numberDiff line numberDiff line change
@@ -162,20 +162,21 @@ foreach ($folder in $folders) {
162162
cp "$smapiBin/SMAPI.metadata.json" "$bundlePath/smapi-internal/metadata.json"
163163
if ($folder -eq "linux" -or $folder -eq "macOS") {
164164
cp "$installAssets/unix-launcher.sh" "$bundlePath"
165-
cp "$smapiBin/System.Runtime.Caching.dll" "$bundlePath/smapi-internal"
166165
}
167166
else {
168167
cp "$installAssets/windows-exe-config.xml" "$bundlePath/StardewModdingAPI.exe.config"
169168
}
170169

171170
# copy .NET dependencies
172-
cp "$smapiBin/System.Configuration.ConfigurationManager.dll" "$bundlePath/smapi-internal"
173-
cp "$smapiBin/System.Runtime.Caching.dll" "$bundlePath/smapi-internal"
174-
cp "$smapiBin/System.Security.Permissions.dll" "$bundlePath/smapi-internal"
175171
if ($folder -eq "windows") {
176172
cp "$smapiBin/System.Management.dll" "$bundlePath/smapi-internal"
177173
}
178174

175+
# copy legacy .NET dependencies (remove in SMAPI 4.0.0)
176+
cp "$smapiBin/System.Configuration.ConfigurationManager.dll" "$bundlePath/smapi-internal"
177+
cp "$smapiBin/System.Runtime.Caching.dll" "$bundlePath/smapi-internal"
178+
cp "$smapiBin/System.Security.Permissions.dll" "$bundlePath/smapi-internal"
179+
179180
# copy bundled mods
180181
foreach ($modName in $bundleModNames) {
181182
$fromPath = "src/SMAPI.Mods.$modName/bin/$buildConfig/$runtime/publish"

docs/release-notes.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
[README](README.md)
22

33
# Release notes
4+
## 3.14.7
5+
Released 01 June 2022 for Stardew Valley 1.5.6 or later.
6+
7+
* For players:
8+
* Optimized reflection cache to reduce frame skips for some players.
9+
* For mod authors:
10+
* Removed `runtimeconfig.json` setting which impacted hot reload support.
11+
412
## 3.14.6
513
Released 27 May 2022 for Stardew Valley 1.5.6 or later.
614

src/SMAPI.Installer/assets/runtimeconfig.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
}
1010
],
1111
"configProperties": {
12-
"System.Runtime.TieredCompilation": false,
13-
"System.Reflection.Metadata.MetadataUpdater.IsSupported": false
12+
// disable tiered runtime JIT: https://github.com/dotnet/runtime/blob/main/docs/design/features/tiered-compilation.md
13+
// This is disabled by the base game, and causes issues with Harmony patches.
14+
"System.Runtime.TieredCompilation": false
1415
}
1516
}
1617
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"Name": "Console Commands",
33
"Author": "SMAPI",
4-
"Version": "3.14.6",
4+
"Version": "3.14.7",
55
"Description": "Adds SMAPI console commands that let you manipulate the game.",
66
"UniqueID": "SMAPI.ConsoleCommands",
77
"EntryDll": "ConsoleCommands.dll",
8-
"MinimumApiVersion": "3.14.6"
8+
"MinimumApiVersion": "3.14.7"
99
}
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"Name": "Error Handler",
33
"Author": "SMAPI",
4-
"Version": "3.14.6",
4+
"Version": "3.14.7",
55
"Description": "Handles some common vanilla errors to log more useful info or avoid breaking the game.",
66
"UniqueID": "SMAPI.ErrorHandler",
77
"EntryDll": "ErrorHandler.dll",
8-
"MinimumApiVersion": "3.14.6"
8+
"MinimumApiVersion": "3.14.7"
99
}
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"Name": "Save Backup",
33
"Author": "SMAPI",
4-
"Version": "3.14.6",
4+
"Version": "3.14.7",
55
"Description": "Automatically backs up all your saves once per day into its folder.",
66
"UniqueID": "SMAPI.SaveBackup",
77
"EntryDll": "SaveBackup.dll",
8-
"MinimumApiVersion": "3.14.6"
8+
"MinimumApiVersion": "3.14.7"
99
}

src/SMAPI.Toolkit/Framework/ModData/ModWarning.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ public enum ModWarning
3535
AccessesFilesystem = 128,
3636

3737
/// <summary>Uses .NET APIs for shell or process access.</summary>
38-
AccessesShell = 256
38+
AccessesShell = 256,
39+
40+
/// <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>
41+
DetectedLegacyConfigurationDll = 512,
42+
43+
/// <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>
44+
DetectedLegacyCachingDll = 1024,
45+
46+
/// <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>
47+
DetectedLegacyPermissionsDll = 2048
3948
}
4049
}

src/SMAPI/Constants.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ internal static class EarlyConstants
5050
internal static int? LogScreenId { get; set; }
5151

5252
/// <summary>SMAPI's current raw semantic version.</summary>
53-
internal static string RawApiVersion = "3.14.6";
53+
internal static string RawApiVersion = "3.14.7";
5454
}
5555

5656
/// <summary>Contains SMAPI's constants and assumptions.</summary>

src/SMAPI/Framework/IModMetadata.cs

+4
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ internal interface IModMetadata : IModInfo
8888
/// <param name="warning">The warning to set.</param>
8989
IModMetadata SetWarning(ModWarning warning);
9090

91+
/// <summary>Remove a warning flag for the mod.</summary>
92+
/// <param name="warning">The warning to remove.</param>
93+
IModMetadata RemoveWarning(ModWarning warning);
94+
9195
/// <summary>Set the mod instance.</summary>
9296
/// <param name="mod">The mod instance to set.</param>
9397
/// <param name="translations">The translations for this mod (if loaded).</param>

src/SMAPI/Framework/ModLoading/AssemblyLoader.cs

+38
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,29 @@ select name
163163
this.AssemblyDefinitionResolver.Add(assembly.Definition);
164164
}
165165

166+
// special case: clear legacy-DLL warnings if the mod bundles a copy
167+
if (mod.Warnings.HasFlag(ModWarning.DetectedLegacyCachingDll))
168+
{
169+
if (File.Exists(Path.Combine(mod.DirectoryPath, "System.Runtime.Caching.dll")))
170+
mod.RemoveWarning(ModWarning.DetectedLegacyCachingDll);
171+
else
172+
{
173+
// remove duplicate warnings (System.Runtime.Caching.dll references these)
174+
mod.RemoveWarning(ModWarning.DetectedLegacyConfigurationDll);
175+
mod.RemoveWarning(ModWarning.DetectedLegacyPermissionsDll);
176+
}
177+
}
178+
if (mod.Warnings.HasFlag(ModWarning.DetectedLegacyConfigurationDll))
179+
{
180+
if (File.Exists(Path.Combine(mod.DirectoryPath, "System.Configuration.ConfigurationManager.dll")))
181+
mod.RemoveWarning(ModWarning.DetectedLegacyConfigurationDll);
182+
}
183+
if (mod.Warnings.HasFlag(ModWarning.DetectedLegacyPermissionsDll))
184+
{
185+
if (File.Exists(Path.Combine(mod.DirectoryPath, "System.Security.Permissions.dll")))
186+
mod.RemoveWarning(ModWarning.DetectedLegacyPermissionsDll);
187+
}
188+
166189
// throw if incompatibilities detected
167190
if (!assumeCompatible && mod.Warnings.HasFlag(ModWarning.BrokenCodeLoaded))
168191
throw new IncompatibleInstructionException();
@@ -429,6 +452,21 @@ private void ProcessInstructionHandleResult(IModMetadata mod, IInstructionHandle
429452
mod.SetWarning(ModWarning.AccessesShell);
430453
break;
431454

455+
case InstructionHandleResult.DetectedLegacyCachingDll:
456+
template = $"{logPrefix}Detected reference to System.Runtime.Caching.dll, which will be removed in SMAPI 4.0.0.";
457+
mod.SetWarning(ModWarning.DetectedLegacyCachingDll);
458+
break;
459+
460+
case InstructionHandleResult.DetectedLegacyConfigurationDll:
461+
template = $"{logPrefix}Detected reference to System.Configuration.ConfigurationManager.dll, which will be removed in SMAPI 4.0.0.";
462+
mod.SetWarning(ModWarning.DetectedLegacyConfigurationDll);
463+
break;
464+
465+
case InstructionHandleResult.DetectedLegacyPermissionsDll:
466+
template = $"{logPrefix}Detected reference to System.Security.Permissions.dll, which will be removed in SMAPI 4.0.0.";
467+
mod.SetWarning(ModWarning.DetectedLegacyPermissionsDll);
468+
break;
469+
432470
case InstructionHandleResult.None:
433471
break;
434472

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using Mono.Cecil;
2+
using StardewModdingAPI.Framework.ModLoading.Framework;
3+
4+
namespace StardewModdingAPI.Framework.ModLoading.Finders
5+
{
6+
/// <summary>Detects assembly references which will break in SMAPI 4.0.0.</summary>
7+
internal class LegacyAssemblyFinder : BaseInstructionHandler
8+
{
9+
/*********
10+
** Public methods
11+
*********/
12+
/// <summary>Construct an instance.</summary>
13+
public LegacyAssemblyFinder()
14+
: base(defaultPhrase: "legacy assembly references") { }
15+
16+
17+
/// <inheritdoc />
18+
public override bool Handle(ModuleDefinition module)
19+
{
20+
foreach (AssemblyNameReference assembly in module.AssemblyReferences)
21+
{
22+
InstructionHandleResult flag = this.GetFlag(assembly);
23+
if (flag is InstructionHandleResult.None)
24+
continue;
25+
26+
this.MarkFlag(flag);
27+
}
28+
29+
return false;
30+
}
31+
32+
33+
/*********
34+
** Private methods
35+
*********/
36+
/// <summary>Get the instruction handle flag for the given assembly reference, if any.</summary>
37+
/// <param name="assemblyRef">The assembly reference.</param>
38+
private InstructionHandleResult GetFlag(AssemblyNameReference assemblyRef)
39+
{
40+
return assemblyRef.Name switch
41+
{
42+
"System.Configuration.ConfigurationManager" => InstructionHandleResult.DetectedLegacyConfigurationDll,
43+
"System.Runtime.Caching" => InstructionHandleResult.DetectedLegacyCachingDll,
44+
"System.Security.Permission" => InstructionHandleResult.DetectedLegacyPermissionsDll,
45+
_ => InstructionHandleResult.None
46+
};
47+
}
48+
}
49+
}

src/SMAPI/Framework/ModLoading/InstructionHandleResult.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ internal enum InstructionHandleResult
3030
DetectedFilesystemAccess,
3131

3232
/// <summary>The instruction accesses the OS shell or processes directly.</summary>
33-
DetectedShellAccess
33+
DetectedShellAccess,
34+
35+
/// <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>
36+
DetectedLegacyConfigurationDll,
37+
38+
/// <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>
39+
DetectedLegacyCachingDll,
40+
41+
/// <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>
42+
DetectedLegacyPermissionsDll
3443
}
3544
}

src/SMAPI/Framework/ModLoading/ModMetadata.cs

+7
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,13 @@ public IModMetadata SetWarning(ModWarning warning)
138138
return this;
139139
}
140140

141+
/// <inheritdoc />
142+
public IModMetadata RemoveWarning(ModWarning warning)
143+
{
144+
this.ActualWarnings &= ~warning;
145+
return this;
146+
}
147+
141148
/// <inheritdoc />
142149
public IModMetadata SetMod(IMod mod, TranslationHelper translations)
143150
{

src/SMAPI/Framework/Reflection/CacheEntry.cs

-30
This file was deleted.

0 commit comments

Comments
 (0)