Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,4 @@ app_data/
/src/VirtoCommerce.Platform.DistributedLock/VirtoCommerce.Platform.DistributedLock.xml
/src/VirtoCommerce.Platform.Modules/VirtoCommerce.Platform.Modules.xml
/src/VirtoCommerce.Platform.Security/VirtoCommerce.Platform.Security.xml
/.claude/settings.local.json
637 changes: 637 additions & 0 deletions docs/modularity.md

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions module.ignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
Azure.Core.dll
Azure.Data.AppConfiguration.dll
Azure.Identity.dll
Azure.Messaging.EventGrid.dll
Azure.Messaging.EventGrid.SystemEvents.dll
Azure.Security.KeyVault.Secrets.dll
Dapper.dll
DnsClient.dll
Expand Down Expand Up @@ -31,7 +28,6 @@ Microsoft.AspNetCore.SignalR.Client.Core.dll
Microsoft.AspNetCore.SignalR.Client.dll
Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson.dll
Microsoft.AspNetCore.SignalR.StackExchangeRedis.dll
Microsoft.Azure.AppConfiguration.AspNetCore.dll
Microsoft.Azure.SignalR.Common.dll
Microsoft.Azure.SignalR.dll
Microsoft.Azure.SignalR.Protocols.dll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
using System.Collections.Generic;
using System.IO;

#pragma warning disable VC0014 // Type is obsolete
namespace VirtoCommerce.Platform.Core.Modularity
{
/// <summary>
/// Loads modules from an arbitrary location on the filesystem. This type loader is only called if
/// <see cref="ModuleInfo"/> classes have a Ref parameter that starts with "file://".
/// Loads modules from an arbitrary location on the filesystem. This type loader is only called if
/// <see cref="ModuleInfo"/> classes have a Ref parameter that starts with "file://".
/// This class is only used on the Desktop version of the Prism Library.
/// </summary>
[Obsolete("Use ModuleAssemblyLoader static class instead.", DiagnosticId = "VC0014", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions")]
public class FileModuleTypeLoader : IModuleTypeLoader, IDisposable
{
private const string _fileSchema = "file://";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System;
using System.Reflection;

namespace VirtoCommerce.Platform.Core.Modularity
{
/// <summary>
/// Interface for classes that are responsible for resolving and loading assembly files.
/// Interface for classes that are responsible for resolving and loading assembly files.
/// </summary>
[Obsolete("Use ModuleAssemblyLoader static class instead.", DiagnosticId = "VC0014", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions")]
public interface IAssemblyResolver
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System;

namespace VirtoCommerce.Platform.Core.Modularity
{
[Obsolete("Use ModuleDiscovery class instead.", DiagnosticId = "VC0014", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions")]
public interface IExternalModuleCatalog : IModuleCatalog
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System;
using Microsoft.AspNetCore.Builder;

namespace VirtoCommerce.Platform.Core.Modularity
{
/// <summary>
/// Declares a service which initializes the modules into the application.
/// </summary>
[Obsolete("Use ModuleRunner static class instead.", DiagnosticId = "VC0014", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions")]
public interface IModuleInitializer
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace VirtoCommerce.Platform.Core.Modularity
{
[Obsolete("Use ModulePackageInstaller and ModuleDiscovery classes instead.", DiagnosticId = "VC0014", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions")]
public interface IModuleInstaller
{
void Install(IEnumerable<ManifestModuleInfo> modules, IProgress<ProgressMessage> progress);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace VirtoCommerce.Platform.Core.Modularity
/// <summary>
/// Defines the interface for the service that will retrieve and initialize the application's modules.
/// </summary>
[Obsolete("Use ModuleRunner static class instead.", DiagnosticId = "VC0014", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions")]
public interface IModuleManager
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace VirtoCommerce.Platform.Core.Modularity
/// <summary>
/// Defines the interface for moduleTypeLoaders
/// </summary>
[Obsolete("Use ModuleAssemblyLoader static class instead.", DiagnosticId = "VC0014", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions")]
public interface IModuleTypeLoader
{
/// <summary>
Expand Down
47 changes: 47 additions & 0 deletions src/VirtoCommerce.Platform.Core/Modularity/IPlatformStartup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace VirtoCommerce.Platform.Core.Modularity;

/// <summary>
/// Allows modules to participate in platform startup phases before the standard IModule lifecycle.
/// Implementations are discovered via the startupType element in module.manifest.
/// </summary>
public interface IPlatformStartup
{
/// <summary>
/// Execution priority. Lower values run first.
/// Use <see cref="StartupPriority"/> constants.
/// </summary>
int Priority => StartupPriority.Default;

/// <summary>
/// Determines when <see cref="Configure"/> is called in the pipeline.
/// </summary>
PipelinePhase Phase => PipelinePhase.Initialization;

/// <summary>
/// Called during Program.cs ConfigureAppConfiguration phase.
/// Use to add configuration sources (e.g., Azure App Configuration).
/// </summary>
void ConfigureAppConfiguration(IConfigurationBuilder builder, IHostEnvironment env) { }

/// <summary>
/// Called during Program.cs ConfigureServices phase.
/// Use to register host-level services.
/// </summary>
void ConfigureHostServices(IServiceCollection services, IConfiguration config) { }

/// <summary>
/// Called during Startup.ConfigureServices after modules are loaded.
/// Use for application-level service registration.
/// </summary>
void ConfigureServices(IServiceCollection services, IConfiguration config) { }

/// <summary>
/// Called during Startup.Configure at the position determined by <see cref="Phase"/>.
/// </summary>
void Configure(IApplicationBuilder app, IConfiguration config) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public ManifestModuleInfo()

public ICollection<ManifestAppInfo> Apps { get; } = new List<ManifestAppInfo>();

public string StartupType { get; set; }

public virtual ManifestModuleInfo LoadFromManifest(ModuleManifest manifest)
{
if (manifest == null)
Expand Down Expand Up @@ -93,6 +95,7 @@ public virtual ManifestModuleInfo LoadFromManifest(ModuleManifest manifest)
Tags = manifest.Tags;
Identity = new ModuleIdentity(Id, Version, Optional);
ModuleType = manifest.ModuleType;
StartupType = manifest.StartupType;

if (manifest.Groups != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void Load()
/// <summary>
/// Reload catalog
/// </summary>
public void Reload()
public virtual void Reload()
{
this.isLoaded = false;
this.Items.Clear();
Expand Down
3 changes: 3 additions & 0 deletions src/VirtoCommerce.Platform.Core/Modularity/ModuleManifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public class ModuleManifest
[XmlElement("moduleType")]
public string ModuleType { get; set; }

[XmlElement("startupType")]
public string StartupType { get; set; }

[XmlArray("dependencies")]
[XmlArrayItem("dependency")]
public ManifestDependency[] Dependencies { get; set; }
Expand Down
25 changes: 25 additions & 0 deletions src/VirtoCommerce.Platform.Core/Modularity/PipelinePhase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace VirtoCommerce.Platform.Core.Modularity;

/// <summary>
/// Determines when IPlatformStartup.Configure() is called in the middleware pipeline.
/// </summary>
public enum PipelinePhase
{
/// <summary>
/// Before routing and authentication middleware.
/// For configuration refresh, custom request preprocessing.
/// </summary>
EarlyMiddleware = 0,

/// <summary>
/// Within ExecuteSynchronized block, after platform migrations but before IModule.PostInitialize.
/// For infrastructure requiring database readiness (e.g., Hangfire).
/// </summary>
Initialization = 1,

/// <summary>
/// After endpoints are mapped and modules are post-initialized.
/// For middleware needing all endpoints visible (e.g., Swagger).
/// </summary>
LateMiddleware = 2
}
20 changes: 20 additions & 0 deletions src/VirtoCommerce.Platform.Core/Modularity/StartupPriority.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace VirtoCommerce.Platform.Core.Modularity;

/// <summary>
/// Well-known priority constants for IPlatformStartup ordering.
/// Lower values execute first.
/// </summary>
public static class StartupPriority
{
/// <summary>Configuration sources load first.</summary>
public const int ConfigurationSource = -1000;

/// <summary>Infrastructure services like logging and caching.</summary>
public const int Infrastructure = -500;

/// <summary>Default priority for module startup types.</summary>
public const int Default = 0;

/// <summary>Services depending on other modules.</summary>
public const int Late = 500;
}
Loading
Loading