System.Composition.Convention 10.0.0-rc.2.25502.107

About

System.Composition.Convention is part of the Managed Extensibility Framework (MEF) 2.0, a composition library for .NET that enables dependency injection through attributes or conventions.

This package simplifies the process of applying consistent patterns for part exports, imports, and metadata by using convention-based configurations. It is useful for scenarios where you want to avoid repetitive attribute-based decoration and instead define conventions for registering types in your composition container.

Key Features

  • Configure exports, imports, and metadata for parts using conventions rather than attributes.
  • Allows defining conventions through a fluent API, making configuration more flexible and readable.

How to Use

Configure parts for composition without using attributes.

using System.Composition.Convention;
using System.Composition.Hosting;

var conventions = new ConventionBuilder();

// Apply conventions: any class that implements ILogger will be exported as ILogger
conventions
    .ForTypesDerivedFrom<ILogger>()
    .Export<ILogger>();

var configuration = new ContainerConfiguration()
    .WithPart<FileLogger>(conventions)
    .WithPart<ConsoleLogger>(conventions);

using CompositionHost container = configuration.CreateContainer();
    
var loggers = container.GetExports<ILogger>();

foreach (var logger in loggers)
{
    logger.Log("Hello, World!");
}
// FileLogger: Hello, World!
// ConsoleLogger: Hello, World!

public interface ILogger
{
    void Log(string message);
}

public class FileLogger : ILogger
{
    public void Log(string message) => Console.WriteLine($"FileLogger: {message}");
}

public class ConsoleLogger : ILogger
{
    public void Log(string message) => Console.WriteLine($"ConsoleLogger: {message}");
}

Main Types

The main types provided by this library are:

  • System.Composition.Convention.ConventionBuilder
  • System.Composition.Convention.PartConventionBuilder
  • System.Composition.Convention.ParameterImportConventionBuilder

Additional Documentation

Feedback & Contributing

System.Composition.Convention is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.

Showing the top 20 packages that depend on System.Composition.Convention.

Packages Downloads
Microsoft.VisualStudio.SDK
Visual Studio SDK meta-package. Reference this to get references to most other Visual Studio extensibility packages.
20
Microsoft.VisualStudio.SDK
Visual Studio SDK meta-package. Reference this to get references to most other Visual Studio extensibility packages.
17
Microsoft.VisualStudio.Utilities
A member of the Visual Studio SDK
16
Microsoft.VisualStudio.Utilities
A member of the Visual Studio SDK
15
Microsoft.VisualStudio.Shell.Framework
A member of the Visual Studio SDK
15
Microsoft.VisualStudio.SDK
Visual Studio SDK meta-package. Reference this to get references to most other Visual Studio extensibility packages.
15
Microsoft.VisualStudio.Shell.15.0
A member of the Visual Studio SDK
15
Microsoft.VisualStudio.Utilities
A member of the Visual Studio SDK
14
Microsoft.VisualStudio.Shell.Framework
A member of the Visual Studio SDK
14
Microsoft.VisualStudio.Utilities
A member of the Visual Studio SDK
13
Microsoft.VisualStudio.SDK
Visual Studio SDK meta-package. Reference this to get references to most other Visual Studio extensibility packages.
13
Microsoft.VisualStudio.Utilities
A member of the Visual Studio SDK
12
Microsoft.VisualStudio.SDK
Visual Studio SDK meta-package. Reference this to get references to most other Visual Studio extensibility packages.
12

https://go.microsoft.com/fwlink/?LinkID=799421

.NET Framework 4.6.2

.NET 8.0

.NET 9.0

.NET 10.0

.NET Standard 2.0

Version Downloads Last updated
10.0.1 1 12/16/2025
10.0.0 1 11/17/2025
10.0.0-rc.2.25502.107 2 10/21/2025
10.0.0-rc.1.25451.107 3 9/15/2025
10.0.0-preview.7.25380.108 6 8/18/2025
10.0.0-preview.6.25358.103 6 7/28/2025
10.0.0-preview.5.25277.114 3 6/12/2025
10.0.0-preview.4.25258.110 4 6/14/2025
10.0.0-preview.3.25171.5 1 6/13/2025
10.0.0-preview.2.25163.2 2 6/14/2025
10.0.0-preview.1.25080.5 3 6/14/2025
9.0.11 1 11/18/2025
9.0.10 2 10/22/2025
9.0.9 3 9/16/2025
9.0.8 4 8/12/2025
9.0.7 5 7/29/2025
9.0.6 3 6/13/2025
9.0.5 4 6/10/2025
9.0.4 3 6/13/2025
9.0.3 2 6/18/2025
9.0.2 3 6/14/2025
9.0.1 4 6/13/2025
9.0.0 3 6/14/2025
9.0.0-rc.2.24473.5 3 6/14/2025
9.0.0-rc.1.24431.7 7 6/14/2025
9.0.0-preview.7.24405.7 8 6/14/2025
9.0.0-preview.6.24327.7 4 6/14/2025
9.0.0-preview.5.24306.7 5 6/14/2025
9.0.0-preview.4.24266.19 3 6/14/2025
9.0.0-preview.3.24172.9 3 6/14/2025
9.0.0-preview.2.24128.5 1 6/14/2025
9.0.0-preview.1.24080.9 1 6/14/2025
8.0.0 8 6/8/2025
8.0.0-rc.2.23479.6 7 6/14/2025
8.0.0-rc.1.23419.4 7 6/14/2025
8.0.0-preview.7.23375.6 8 6/13/2025
8.0.0-preview.6.23329.7 7 6/13/2025
8.0.0-preview.5.23280.8 7 6/14/2025
8.0.0-preview.4.23259.5 6 6/14/2025
8.0.0-preview.3.23174.8 7 6/13/2025
8.0.0-preview.2.23128.3 28 6/14/2025
8.0.0-preview.1.23110.8 6 6/16/2025
7.0.0 8 6/14/2025
7.0.0-rc.2.22472.3 8 6/14/2025
7.0.0-rc.1.22426.10 7 6/14/2025
7.0.0-preview.7.22375.6 6 6/14/2025
7.0.0-preview.6.22324.4 8 6/14/2025
7.0.0-preview.5.22301.12 8 6/14/2025
7.0.0-preview.4.22229.4 7 6/14/2025
7.0.0-preview.3.22175.4 5 6/14/2025
7.0.0-preview.2.22152.2 7 6/14/2025
7.0.0-preview.1.22076.8 7 6/14/2025
6.0.0 7 6/14/2025
6.0.0-rc.2.21480.5 7 6/14/2025
6.0.0-rc.1.21451.13 6 6/14/2025
6.0.0-preview.7.21377.19 6 6/14/2025
6.0.0-preview.6.21352.12 5 6/13/2025
6.0.0-preview.5.21301.5 8 6/14/2025
6.0.0-preview.4.21253.7 5 6/14/2025
6.0.0-preview.3.21201.4 4 7/29/2025
6.0.0-preview.2.21154.6 6 6/13/2025
6.0.0-preview.1.21102.12 7 6/14/2025
5.0.1 8 6/14/2025
5.0.0 7 6/13/2025
5.0.0-rc.2.20475.5 6 6/14/2025
5.0.0-rc.1.20451.14 6 6/7/2025
5.0.0-preview.8.20407.11 8 6/13/2025
5.0.0-preview.7.20364.11 7 6/14/2025
5.0.0-preview.6.20305.6 7 6/14/2025
5.0.0-preview.5.20278.1 7 6/14/2025
5.0.0-preview.4.20251.6 7 6/14/2025
5.0.0-preview.3.20214.6 6 6/14/2025
5.0.0-preview.2.20160.6 6 6/13/2025
5.0.0-preview.1.20120.5 8 6/13/2025
1.4.1 6 6/13/2025
1.4.0 8 6/13/2025
1.4.0-preview3.19551.4 6 6/13/2025
1.4.0-preview2.19523.17 6 6/17/2025
1.4.0-preview1.19504.10 6 6/14/2025
1.3.0 8 6/14/2025
1.3.0-rc1.19456.4 8 6/13/2025
1.3.0-preview9.19421.4 6 6/14/2025
1.3.0-preview9.19416.11 7 6/13/2025
1.3.0-preview8.19405.3 8 6/13/2025
1.3.0-preview7.19362.9 7 6/14/2025
1.3.0-preview6.19303.8 6 6/13/2025
1.3.0-preview6.19264.9 6 6/13/2025
1.3.0-preview5.19224.8 8 6/14/2025
1.3.0-preview4.19212.13 8 6/13/2025
1.3.0-preview3.19128.7 6 6/14/2025
1.3.0-preview.19073.11 7 6/14/2025
1.3.0-preview.18571.3 6 6/14/2025
1.2.0 9 6/13/2025
1.2.0-rc1 7 6/13/2025
1.2.0-preview2-26406-04 7 6/14/2025
1.2.0-preview1-26216-02 6 6/14/2025
1.1.0 7 6/13/2025
1.1.0-preview2-25405-01 6 6/13/2025
1.1.0-preview1-25305-02 7 6/14/2025
1.0.31 8 6/13/2025
1.0.31-preview1-24530-04 7 6/14/2025