Skip to main content

Dependencies

Module dependencies define the relationships between Intent Architect modules and ensure that required functionality is available during code generation.

What are Module Dependencies?

Dependencies specify:
  • Required Modules - Other modules that must be installed
  • Version Constraints - Minimum and maximum compatible versions
  • NuGet Packages - .NET packages added to generated projects
  • Transitive Dependencies - Dependencies of dependencies
Dependencies ensure modules work together correctly and all required code generation capabilities are available.

Declaring Dependencies

Modules declare dependencies in their .imodspec file:
<dependencies>
  <dependency id="Intent.Application.DependencyInjection" version="4.1.8" />
  <dependency id="Intent.Application.DependencyInjection.MediatR" version="3.6.0" />
  <dependency id="Intent.Common" version="3.8.0" />
  <dependency id="Intent.Common.CSharp" version="3.9.4" />
  <dependency id="Intent.Common.Types" version="3.4.0" />
  <dependency id="Intent.Metadata.Security" version="1.0.0" />
  <dependency id="Intent.Metadata.WebApi" version="4.5.5" />
  <dependency id="Intent.Modelers.Domain" version="3.4.4" />
  <dependency id="Intent.Modelers.Services" version="4.0.0" />
  <dependency id="Intent.Modelers.Services.CQRS" version="4.1.1" />
  <dependency id="Intent.OutputManager.RoslynWeaver" version="4.9.10" />
</dependencies>
id
string
required
The unique identifier of the required module
version
string
required
Minimum version required (can be a version range)

Dependency Categories

Intent Architect modules typically depend on several categories of modules:
Common Infrastructure
  • Intent.Common - Core interfaces and utilities
  • Intent.Common.CSharp - C# code generation helpers
  • Intent.Common.Types - Common type definitions
  • Intent.OutputManager.RoslynWeaver - Code merging engine
Almost every module depends on these core modules.

Version Constraints

Version constraints follow semantic versioning:
<!-- Exact version -->
<dependency id="Intent.Common" version="3.8.0" />

<!-- Minimum version (commonly used) -->
<dependency id="Intent.Common.CSharp" version="3.9.4" />

<!-- Version range -->
<dependency id="Intent.AspNetCore" version="[6.0.0, 7.0.0)" />

Version Range Syntax

[1.0.0, 2.0.0]  # 1.0.0 <= version <= 2.0.0
Most modules use minimum version constraints (e.g., version="3.8.0") which means “3.8.0 or higher”.

Real-World Dependency Example

Here’s the complete dependency tree for Intent.AspNetCore.Controllers:
<package>
  <id>Intent.AspNetCore.Controllers</id>
  <version>7.1.8</version>
  
  <dependencies>
    <!-- Core infrastructure -->
    <dependency id="Intent.AspNetCore" version="6.0.8" />
    <dependency id="Intent.Common" version="3.9.0" />
    <dependency id="Intent.Common.CSharp" version="3.9.5" />
    <dependency id="Intent.Common.Types" version="3.4.0" />
    
    <!-- Metadata access -->
    <dependency id="Intent.Metadata.WebApi" version="4.7.1" />
    <dependency id="Intent.Modelers.Services" version="3.8.2" />
    
    <!-- Code weaving -->
    <dependency id="Intent.OutputManager.RoslynWeaver" version="4.5.1" />
  </dependencies>
</package>
This creates a dependency chain:
1

Intent.AspNetCore.Controllers

Top-level module that generates controller classes
2

Intent.AspNetCore

Provides ASP.NET Core infrastructure setup (Program.cs, Startup, etc.)
3

Intent.Common.CSharp

Provides CSharpFile builder API and utilities
4

Intent.Common

Provides base interfaces and core functionality

Interoperability vs Dependencies

Intent Architect distinguishes between dependencies (required) and interoperability (suggested):

Dependencies (Required)

<dependencies>
  <dependency id="Intent.Application.DependencyInjection" version="4.1.8" />
</dependencies>
  • Must be installed for the module to work
  • Intent Architect enforces installation
  • Provides templates, metadata, or utilities the module needs

Interoperability (Optional)

<interoperability>
  <detect id="Intent.Application.MediatR">
    <install>
      <package id="Intent.AspNetCore.Controllers.Dispatch.MediatR" version="6.1.2" />
    </install>
  </detect>
</interoperability>
  • Suggested when compatible modules are detected
  • User can choose to install or skip
  • Enhances functionality when used together
Use dependencies for required functionality. Use interoperability for optional integrations.

Dependency Resolution

Intent Architect resolves dependencies using these rules:
Modules explicitly listed in <dependencies> are installed first
Dependencies of dependencies are installed automatically
If multiple modules depend on the same module with different versions, the highest compatible version is selected
If version constraints conflict, Intent Architect reports an error

NuGet Dependencies

Modules also manage NuGet package dependencies for generated code:
internal static void Configure(ICSharpFileBuilderTemplate template, CommandModel model)
{
    // Add NuGet package to generated project
    template.AddNugetDependency(NugetPackages.MediatR(template.OutputTarget));
}
Common NuGet packages:
template.AddNugetDependency(NugetPackages.MediatR(outputTarget));
// Adds: MediatR package to .csproj
NuGet dependencies are added to the generated .csproj files, not to the Intent Architect module itself.

Factory Extensions and Dependencies

Factory extensions allow modules to extend other modules’ templates:
[IntentManaged(Mode.Fully, Body = Mode.Merge)]
public class BinaryContentFilterExtension : FactoryExtensionBase
{
    public override string Id => "Intent.AspNetCore.Controllers.BinaryContentFilterExtension";

    protected override void OnBeforeTemplateExecution(IApplication application)
    {
        // Find template from another module
        var templates = application.FindTemplateInstances<ICSharpFileBuilderTemplate>(
            TemplateDependency.OnTemplate("Distribution.SwashbuckleConfiguration"));
        
        foreach (var template in templates)
        {
            // Modify the template's output
            var @class = template.CSharpFile.Classes.First();
            var configBlock = GetConfigureSwaggerOptionsBlock(@class);
            configBlock.AddStatement($"options.OperationFilter<BinaryContentFilter>();");
        }
    }
}
Factory extensions create an implicit dependency on the modules they extend. Document these in your module’s README.

Dependency Best Practices

Minimize Dependencies

Only depend on modules you actually need. Fewer dependencies = simpler installation.

Use Minimum Versions

Specify the lowest version that provides required functionality.

Avoid Exact Versions

Allow patch and minor updates unless you have specific compatibility requirements.

Document Dependencies

Explain why each dependency is needed in your module’s documentation.

Checking Dependencies

Intent Architect provides tools to inspect dependencies:
1

Module Manager

View all installed modules and their versions in the Intent Architect UI
2

Dependency Graph

Visualize the dependency tree to understand module relationships
3

Update Notifications

Intent Architect notifies when module updates are available

Common Dependency Patterns

Application Layer Pattern

<dependencies>
  <!-- Core infrastructure -->
  <dependency id="Intent.Common.CSharp" version="3.9.0" />
  
  <!-- DI container -->
  <dependency id="Intent.Application.DependencyInjection" version="4.1.8" />
  
  <!-- Application pattern (CQRS with MediatR) -->
  <dependency id="Intent.Application.MediatR" version="4.5.0" />
  
  <!-- DTOs -->
  <dependency id="Intent.Application.Dtos" version="4.5.0" />
  
  <!-- Validation -->
  <dependency id="Intent.Application.FluentValidation" version="3.9.0" />
</dependencies>

Infrastructure Layer Pattern

<dependencies>
  <!-- Core infrastructure -->
  <dependency id="Intent.Common.CSharp" version="3.9.0" />
  
  <!-- DI container -->
  <dependency id="Intent.Infrastructure.DependencyInjection" version="4.1.2" />
  
  <!-- Data access -->
  <dependency id="Intent.EntityFrameworkCore" version="5.0.0" />
  
  <!-- Repositories -->
  <dependency id="Intent.Entities.Repositories.Api" version="5.0.4" />
</dependencies>

API Layer Pattern

<dependencies>
  <!-- Core infrastructure -->
  <dependency id="Intent.Common.CSharp" version="3.9.0" />
  
  <!-- ASP.NET Core -->
  <dependency id="Intent.AspNetCore" version="6.0.8" />
  
  <!-- Controllers -->
  <dependency id="Intent.AspNetCore.Controllers" version="7.1.8" />
  
  <!-- OpenAPI -->
  <dependency id="Intent.AspNetCore.Swashbuckle" version="5.1.1" />
  
  <!-- Dispatch to application layer -->
  <dependency id="Intent.AspNetCore.Controllers.Dispatch.MediatR" version="6.1.2" />
</dependencies>

Troubleshooting Dependencies

Problem: Two modules require incompatible versions of the same dependency.Solution: Update modules to compatible versions, or check if newer versions resolve the conflict.
Problem: Module fails to load due to missing dependency.Solution: Install the missing module via the Intent Architect module manager.
Problem: Module A depends on B, which depends on A.Solution: Refactor to extract shared functionality into a third module.
Problem: Module depends on an old version with known issues.Solution: Update the module’s .imodspec to require a newer version.

Next Steps

Modules

Learn about module structure and packaging

Templates

Understand how templates work together

Metadata

Explore metadata dependencies

Build docs developers (and LLMs) love