Refactored DEPRECATION_MESSAGE to use an empty string when not needed

This commit is contained in:
Thorsten Sommer 2025-03-23 14:26:47 +01:00
parent 544e9ee561
commit f72eef2b95
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
5 changed files with 10 additions and 8 deletions

View File

@ -1,3 +1,5 @@
require("contentHome")
-- The ID for this plugin: -- The ID for this plugin:
ID = "43065dbc-78d0-45b7-92be-f14c2926e2dc" ID = "43065dbc-78d0-45b7-92be-f14c2926e2dc"
@ -32,7 +34,7 @@ TARGET_GROUPS = { "EVERYONE" }
IS_MAINTAINED = true IS_MAINTAINED = true
-- When the plugin is deprecated, this message will be shown to users: -- When the plugin is deprecated, this message will be shown to users:
DEPRECATION_MESSAGE = nil DEPRECATION_MESSAGE = ""
UI_TEXT_CONTENT = { UI_TEXT_CONTENT = {
HOME = CONTENT_HOME, HOME = CONTENT_HOME,

View File

@ -34,7 +34,7 @@ TARGET_GROUPS = { "EVERYONE" }
IS_MAINTAINED = true IS_MAINTAINED = true
-- When the plugin is deprecated, this message will be shown to users: -- When the plugin is deprecated, this message will be shown to users:
DEPRECATION_MESSAGE = nil DEPRECATION_MESSAGE = ""
UI_TEXT_CONTENT = { UI_TEXT_CONTENT = {
HOME = CONTENT_HOME, HOME = CONTENT_HOME,

View File

@ -60,5 +60,5 @@ public interface IPluginMetadata
/// <summary> /// <summary>
/// The message that should be displayed when the plugin is deprecated. /// The message that should be displayed when the plugin is deprecated.
/// </summary> /// </summary>
public string? DeprecationMessage { get; } public string DeprecationMessage { get; }
} }

View File

@ -48,7 +48,7 @@ public abstract class PluginBase : IPluginMetadata
public bool IsMaintained { get; } public bool IsMaintained { get; }
/// <inheritdoc /> /// <inheritdoc />
public string? DeprecationMessage { get; } public string DeprecationMessage { get; } = string.Empty;
/// <summary> /// <summary>
/// The issues that occurred during the initialization of this plugin. /// The issues that occurred during the initialization of this plugin.
@ -418,12 +418,12 @@ public abstract class PluginBase : IPluginMetadata
/// <param name="message">The error message, when the deprecation message could not be read.</param> /// <param name="message">The error message, when the deprecation message could not be read.</param>
/// <param name="deprecationMessage">The read deprecation message.</param> /// <param name="deprecationMessage">The read deprecation message.</param>
/// <returns>True, when the deprecation message could be read successfully.</returns> /// <returns>True, when the deprecation message could be read successfully.</returns>
private bool TryInitDeprecationMessage(out string message, out string? deprecationMessage) private bool TryInitDeprecationMessage(out string message, out string deprecationMessage)
{ {
if (!this.state.Environment["DEPRECATION_MESSAGE"].TryRead(out deprecationMessage)) if (!this.state.Environment["DEPRECATION_MESSAGE"].TryRead(out deprecationMessage))
{ {
deprecationMessage = null; deprecationMessage = string.Empty;
message = "The field DEPRECATION_MESSAGE does not exist, is not a valid string. This field is optional: use nil to indicate that the plugin is not deprecated."; message = "The field DEPRECATION_MESSAGE does not exist, is not a valid string. This message is optional: use an empty string to indicate that the plugin is not deprecated.";
return false; return false;
} }

View File

@ -38,7 +38,7 @@ public sealed class PluginMetadata(PluginBase plugin) : IPluginMetadata
public bool IsMaintained { get; } = plugin.IsMaintained; public bool IsMaintained { get; } = plugin.IsMaintained;
/// <inheritdoc /> /// <inheritdoc />
public string? DeprecationMessage { get; } = plugin.DeprecationMessage; public string DeprecationMessage { get; } = plugin.DeprecationMessage;
#endregion #endregion
} }