fix 'unknown mod' deprecation warnings showing wrong stack trace

This commit is contained in:
Jesse Plamondon-Willard 2018-12-31 14:10:25 -05:00
parent 1db640d295
commit e064be0c7b
No known key found for this signature in database
GPG Key ID: 7D7C8097B62033CE
3 changed files with 9 additions and 3 deletions

View File

@ -8,6 +8,7 @@
* For modders:
* Fixed `Constants.SaveFolderName` and `CurrentSavePath` not available during early load stages when using `Specialised.LoadStageChanged` event.
* Fixed `LoadStage.SaveParsed` raised before the parsed save data is available.
* Fixed 'unknown mod' deprecation warnings showing the wrong stack trace.
## 2.10.1
Released 30 December 2018 for Stardew Valley 1.3.32.

View File

@ -62,7 +62,7 @@ namespace StardewModdingAPI.Framework
return;
// queue warning
this.QueuedWarnings.Add(new DeprecationWarning(source, nounPhrase, version, severity));
this.QueuedWarnings.Add(new DeprecationWarning(source, nounPhrase, version, severity, Environment.StackTrace));
}
/// <summary>Print any queued messages.</summary>
@ -79,7 +79,7 @@ namespace StardewModdingAPI.Framework
: $"{warning.ModName ?? "An unknown mod"} uses deprecated code ({warning.NounPhrase} is deprecated since SMAPI {warning.Version}).";
#endif
if (warning.ModName == null)
message += $"{Environment.NewLine}{Environment.StackTrace}";
message += $"{Environment.NewLine}{warning.StackTrace}";
// log message
switch (warning.Level)

View File

@ -18,6 +18,9 @@ namespace StardewModdingAPI.Framework
/// <summary>The deprecation level for the affected code.</summary>
public DeprecationLevel Level { get; }
/// <summary>The stack trace when the deprecation warning was raised.</summary>
public string StackTrace { get; }
/*********
** Public methods
@ -27,12 +30,14 @@ namespace StardewModdingAPI.Framework
/// <param name="nounPhrase">A noun phrase describing what is deprecated.</param>
/// <param name="version">The SMAPI version which deprecated it.</param>
/// <param name="level">The deprecation level for the affected code.</param>
public DeprecationWarning(string modName, string nounPhrase, string version, DeprecationLevel level)
/// <param name="stackTrace">The stack trace when the deprecation warning was raised.</param>
public DeprecationWarning(string modName, string nounPhrase, string version, DeprecationLevel level, string stackTrace)
{
this.ModName = modName;
this.NounPhrase = nounPhrase;
this.Version = version;
this.Level = level;
this.StackTrace = stackTrace;
}
}
}