summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/SMAPI/Framework/Commands/HarmonySummaryCommand.cs33
-rw-r--r--src/SMAPI/Framework/Patching/GamePatcher.cs2
2 files changed, 18 insertions, 17 deletions
diff --git a/src/SMAPI/Framework/Commands/HarmonySummaryCommand.cs b/src/SMAPI/Framework/Commands/HarmonySummaryCommand.cs
index bc8f4aa2..08233feb 100644
--- a/src/SMAPI/Framework/Commands/HarmonySummaryCommand.cs
+++ b/src/SMAPI/Framework/Commands/HarmonySummaryCommand.cs
@@ -28,7 +28,7 @@ namespace StardewModdingAPI.Framework.Commands
/// <param name="monitor">Writes messages to the console.</param>
public void HandleCommand(string[] args, IMonitor monitor)
{
- SearchResult[] matches = this.FilterPatches(args).OrderBy(p => p.Method).ToArray();
+ SearchResult[] matches = this.FilterPatches(args).OrderBy(p => p.MethodName).ToArray();
StringBuilder result = new StringBuilder();
@@ -40,18 +40,19 @@ namespace StardewModdingAPI.Framework.Commands
result.AppendLine();
foreach (var match in matches)
{
- result.AppendLine($" {match.Method}");
- foreach (var ownerGroup in match.PatchTypesByOwner)
+ result.AppendLine($" {match.MethodName}");
+ foreach (var ownerGroup in match.PatchTypesByOwner.OrderBy(p => p.Key))
{
var sortedTypes = ownerGroup.Value
.OrderBy(p => p switch { PatchType.Prefix => 0, PatchType.Postfix => 1, PatchType.Finalizer => 2, PatchType.Transpiler => 3, _ => 4 });
result.AppendLine($" - {ownerGroup.Key} ({string.Join(", ", sortedTypes).ToLower()})");
}
+ result.AppendLine();
}
}
- monitor.Log(result.ToString(), LogLevel.Info);
+ monitor.Log(result.ToString().TrimEnd(), LogLevel.Info);
}
@@ -63,15 +64,12 @@ namespace StardewModdingAPI.Framework.Commands
private IEnumerable<SearchResult> FilterPatches(string[] searchTerms)
{
bool hasSearch = searchTerms.Any();
- bool IsMatch(string target) => searchTerms.Any(search => target != null && target.IndexOf(search, StringComparison.OrdinalIgnoreCase) > -1);
+ bool IsMatch(string target) => !hasSearch || searchTerms.Any(search => target != null && target.IndexOf(search, StringComparison.OrdinalIgnoreCase) > -1);
foreach (var patch in this.GetAllPatches())
{
- if (!hasSearch)
- yield return patch;
-
// matches entire patch
- if (IsMatch(patch.Method))
+ if (IsMatch(patch.MethodDescription))
{
yield return patch;
continue;
@@ -95,7 +93,6 @@ namespace StardewModdingAPI.Framework.Commands
foreach (MethodBase method in Harmony.GetAllPatchedMethods())
{
// get metadata for method
- string methodLabel = method.FullDescription();
HarmonyLib.Patches patchInfo = Harmony.GetPatchInfo(method);
IDictionary<PatchType, IReadOnlyCollection<Patch>> patchGroups = new Dictionary<PatchType, IReadOnlyCollection<Patch>>
{
@@ -118,7 +115,7 @@ namespace StardewModdingAPI.Framework.Commands
}
// create search result
- yield return new SearchResult(methodLabel, typesByOwner);
+ yield return new SearchResult(method, typesByOwner);
}
}
@@ -144,8 +141,11 @@ namespace StardewModdingAPI.Framework.Commands
/*********
** Accessors
*********/
- /// <summary>A detailed human-readable label for the patched method.</summary>
- public string Method { get; }
+ /// <summary>A simple human-readable name for the patched method.</summary>
+ public string MethodName { get; }
+
+ /// <summary>A detailed description for the patched method.</summary>
+ public string MethodDescription { get; }
/// <summary>The patch types by the Harmony instance ID that added them.</summary>
public IDictionary<string, ISet<PatchType>> PatchTypesByOwner { get; }
@@ -155,11 +155,12 @@ namespace StardewModdingAPI.Framework.Commands
** Public methods
*********/
/// <summary>Construct an instance.</summary>
- /// <param name="method">A detailed human-readable label for the patched method.</param>
+ /// <param name="method">The patched method.</param>
/// <param name="patchTypesByOwner">The patch types by the Harmony instance ID that added them.</param>
- public SearchResult(string method, IDictionary<string, ISet<PatchType>> patchTypesByOwner)
+ public SearchResult(MethodBase method, IDictionary<string, ISet<PatchType>> patchTypesByOwner)
{
- this.Method = method;
+ this.MethodName = $"{method.DeclaringType?.FullName}.{method.Name}";
+ this.MethodDescription = method.FullDescription();
this.PatchTypesByOwner = patchTypesByOwner;
}
}
diff --git a/src/SMAPI/Framework/Patching/GamePatcher.cs b/src/SMAPI/Framework/Patching/GamePatcher.cs
index cdb54453..dcad285a 100644
--- a/src/SMAPI/Framework/Patching/GamePatcher.cs
+++ b/src/SMAPI/Framework/Patching/GamePatcher.cs
@@ -27,7 +27,7 @@ namespace StardewModdingAPI.Framework.Patching
/// <param name="patches">The patches to apply.</param>
public void Apply(params IHarmonyPatch[] patches)
{
- Harmony harmony = new Harmony("io.smapi");
+ Harmony harmony = new Harmony("SMAPI");
foreach (IHarmonyPatch patch in patches)
{
try