From 947d4545b1326bf6afbfb970d979dafd8ff2eb97 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Tue, 10 Nov 2020 20:11:52 -0500 Subject: fix 'collection was modified' error when using 'harmony summary' command in rare cases --- docs/release-notes.md | 1 + src/SMAPI/Framework/Commands/HarmonySummaryCommand.cs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/release-notes.md b/docs/release-notes.md index 3d131d07..14e5e81b 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -10,6 +10,7 @@ ## Upcoming release * For modders: * Fixed error when heuristically rewriting a property for a type that no longer exists. + * Fixed rare 'collection was modified' error when using 'harmony summary' console command in rare cases. * For the Console Commands mod: * `player_add` can now spawn shirts normally only available during character customization. diff --git a/src/SMAPI/Framework/Commands/HarmonySummaryCommand.cs b/src/SMAPI/Framework/Commands/HarmonySummaryCommand.cs index 8fdd4282..f3731d16 100644 --- a/src/SMAPI/Framework/Commands/HarmonySummaryCommand.cs +++ b/src/SMAPI/Framework/Commands/HarmonySummaryCommand.cs @@ -112,9 +112,9 @@ namespace StardewModdingAPI.Framework.Commands private IEnumerable 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 -- cgit