Module Information Interface (IModuleInfo)
namespace OutfitTool.API1
The IModuleInfo interface is a mandatory entry point for any system module. It provides the host with module metadata: its identifier, version, author, and API requirements. The host uses this data to display information in the user interface, check compatibility, and manage module loading.
🔍 Where it's used: The host requests IModuleInfo during the reflection phase (assembly analysis) before creating an instance of ModuleController. This allows displaying module information even if it fails to load.
Interface Definition
public interface IModuleInfo
{
string Name { get; } // Internal module name (for the system)
string DisplayName { get; } // Display name (for the user)
string AssemblyName { get; } // Main assembly name
string Description { get; } // Brief description of functionality
ModuleVersion Version { get; } // Module version
int RequireApiVersion { get; } // Required host API version
string Changes { get; } // List of changes in the current version
string Author { get; } // Author/developer name
string AuthorContacts { get; } // Contact information (email, website)
}
Property Descriptions
- string Name = "mail_agent"
- Internal system name of the module. Used for identification in logs, configuration files, and when referencing the module from code. Must be unique.
snake_caseis recommended. - string DisplayName = "Mail Agent"
- Module name displayed in the user interface. Can contain spaces, capital letters, and special characters.
- string AssemblyName = "MailAgent"
- Name of the main module assembly (without
.dllextension). Must match the file name and, typically, the module directory name. - string Description = "Email processing module"
- Brief description (1-2 sentences) of what the module does. Displayed in the module list on hover or in the module card.
- ModuleVersion Version = new ModuleVersion(0, 1, "alpha")
- Module version using semantic versioning. Contains
Major,Minor, and a text label (e.g., "alpha", "beta", "rc", "release"). More details about the structure are in the section below. - int RequireApiVersion = 1
- Minimum API version the module is compatible with. If the host supports an API version lower than specified, the module will not be loaded. Used to ensure backward compatibility.
- string Changes = "First alpha version. Basic functionality."
- List of changes in the current module version (changelog). Can be multiline. Displayed in the "About Module" window or during updates.
- string Author = "Stolyarov Roman"
- Author name or development company.
- string AuthorContacts = "rshome@mail.ru"
- Contact information for communication (email, website link, Telegram, etc.).
ModuleVersion Class
ModuleVersion is a simple class for representing a module version. It contains three components:
public class ModuleVersion
{
public int Major { get; } // Major version number (incompatible changes)
public int Minor { get; } // Minor version number (new functionality, backward compatible)
public string VersionLabel { get; } // Version label (alpha, beta, rc, release, etc.)
public ModuleVersion(int major, int minor, string versionLabel)
{
Major = major;
Minor = minor;
VersionLabel = versionLabel;
}
// For convenience, you can add an override of ToString()
public override string ToString() => $"{Major}.{Minor}-{VersionLabel}";
}
📌 Recommendation: Follow semantic versioning (SemVer). Increase Major when making changes incompatible with previous versions, Minor when adding backward-compatible functionality. The label helps indicate the development stage.
Implementation Example
Below is a correct example of implementing the interface for the "Mail Agent" module:
namespace MailAgent;
internal class ModuleInfo : IModuleInfo
{
public string Name => "mail_agent";
public string DisplayName => "Mail Agent";
public string AssemblyName => "MailAgent";
public string Description => "Email processing module: attachment downloading, email parsing, integration with mail servers via IMAP/POP3 protocols.";
public ModuleVersion Version => new (0, 1, "alpha");
public string Changes => "First alpha version. Basic functionality: connecting to a mailbox, viewing emails, saving attachments.";
public string Author => "Stolyarov Roman";
public string AuthorContacts => "rshome@mail.ru";
public int RequireApiVersion => 1;
}
Rules and Limitations
- Required: Each module must contain a public class implementing
IModuleInfo. Without this class, the module will not be recognized by the host. - Uniqueness of
Name: The module's system name must be unique within the installation. Prefixes are recommended to avoid conflicts (e.g.,com_company_module). - Caching: The host may cache property values, so it is not recommended to change them at runtime. All properties should return constant values.
RequireApiVersion: Must be an integer. If the module supports multiple API versions (e.g., supports 1 and 2), specify the maximum supported by the main application.
⚠️ Important: The value of AssemblyName must strictly match the assembly file name (without extension). For example, for the file MailAgent.dll, the value should be "MailAgent". Mismatch can lead to loading errors.
Interaction with the Host
The host uses information from IModuleInfo as follows:
- When scanning the
./modulesdirectory, the host finds the assembly and checks for the presence of theModuleInfoclass. - Compares
RequireApiVersionwith the API version supported by the host. If the host version is lower than required, the module is marked as incompatible and not loaded. - Displays
DisplayName,Description,Version, andAuthorin the user interface. - Uses
AssemblyNamefor internal references and dependency resolution. - When errors occur or logging, uses
Nameto identify the message source.