blob: 773809075aa9a48ae78d09f1eab96ab2aa44ee1f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#if SMAPI_DEPRECATED
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
};
}
}
}
#endif
|