From e32c0cbb875fce3f6e4b4080304c1b5ce6e3be41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Hompus?= Date: Wed, 21 Aug 2024 23:07:54 +0200 Subject: [PATCH 1/2] Provide System.Composition.Hosting package readme --- .../System.Composition.Hosting/src/PACKAGE.md | 79 +++++++++++++++++++ .../src/System.Composition.Hosting.csproj | 7 +- 2 files changed, 80 insertions(+), 6 deletions(-) create mode 100644 src/libraries/System.Composition.Hosting/src/PACKAGE.md diff --git a/src/libraries/System.Composition.Hosting/src/PACKAGE.md b/src/libraries/System.Composition.Hosting/src/PACKAGE.md new file mode 100644 index 00000000000000..736264dc6b8c12 --- /dev/null +++ b/src/libraries/System.Composition.Hosting/src/PACKAGE.md @@ -0,0 +1,79 @@ +## About + + + +`System.Composition.Hosting` is part of the Managed Extensibility Framework (MEF) 2.0, a composition library for .NET that enables dependency injection through attributes. + +This package provides core services for creating composition containers. +It offers tools to configure and manage the composition of parts within your application, facilitating dependency injection and enabling modular architectures. + +## Key Features + + + +* Create and manage composition containers for dynamic dependency injection. + +## How to Use + + + +Create a composition host and compose parts. + +```csharp +using System.Composition; +using System.Composition.Hosting; + +// Create a container configuration +var configuration = new ContainerConfiguration() + .WithPart(); + +// Create the composition host (container) +using CompositionHost container = configuration.CreateContainer(); + +// Get an instance of the service +var service = container.GetExport(); +service.Run(); +// Service is running! + +public interface IService +{ + void Run(); +} + +[Export(typeof(IService))] +public class Service : IService +{ + public void Run() => Console.WriteLine("Service is running!"); +} +``` + +## Main Types + + + +The main type provided by this library is: + +* `System.Composition.CompositionHost` + +## Additional Documentation + + + +* [API documentation](https://learn.microsoft.com/dotnet/api/system.composition.hosting) +* [Managed Extensibility Framework (MEF)](https://learn.microsoft.com/dotnet/framework/mef/) + +## Related Packages + + + +* [System.Composition.AttributedModel](https://www.nuget.org/packages/System.Composition.AttributedModel) +* [System.Composition.Convention](https://www.nuget.org/packages/System.Composition.Convention) +* [System.Composition.Runtime](https://www.nuget.org/packages/System.Composition.Runtime) +* [System.Composition.TypedParts](https://www.nuget.org/packages/System.Composition.TypedParts) + +## Feedback & Contributing + + + +System.Composition.Hosting is released as open source under the [MIT license](https://licenses.nuget.org/MIT). +Bug reports and contributions are welcome at [the GitHub repository](https://github.com/dotnet/runtime). diff --git a/src/libraries/System.Composition.Hosting/src/System.Composition.Hosting.csproj b/src/libraries/System.Composition.Hosting/src/System.Composition.Hosting.csproj index cd017f48b69398..18d027e8ad14bb 100644 --- a/src/libraries/System.Composition.Hosting/src/System.Composition.Hosting.csproj +++ b/src/libraries/System.Composition.Hosting/src/System.Composition.Hosting.csproj @@ -7,15 +7,10 @@ Microsoft false true - Provides Managed Extensibility Framework types that are useful to developers of extensible applications, or hosts. - -Commonly Used Types: -System.Composition.Hosting.CompositionHost + Provides Managed Extensibility Framework (MEF) types that are useful to developers of extensible applications, or hosts. disable $(NoWarn);nullable - - false From 26e543a2e3789f4c18e06a58232667afd4df5803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Hompus?= Date: Mon, 26 Aug 2024 17:59:39 +0200 Subject: [PATCH 2/2] Improve after feedback --- src/libraries/System.Composition.Hosting/src/PACKAGE.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Composition.Hosting/src/PACKAGE.md b/src/libraries/System.Composition.Hosting/src/PACKAGE.md index 736264dc6b8c12..9f5556e7a4d7b7 100644 --- a/src/libraries/System.Composition.Hosting/src/PACKAGE.md +++ b/src/libraries/System.Composition.Hosting/src/PACKAGE.md @@ -2,7 +2,7 @@ -`System.Composition.Hosting` is part of the Managed Extensibility Framework (MEF) 2.0, a composition library for .NET that enables dependency injection through attributes. +`System.Composition.Hosting` 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 provides core services for creating composition containers. It offers tools to configure and manage the composition of parts within your application, facilitating dependency injection and enabling modular architectures. @@ -66,6 +66,7 @@ The main type provided by this library is: +* [System.Composition](https://www.nuget.org/packages/System.Composition) * [System.Composition.AttributedModel](https://www.nuget.org/packages/System.Composition.AttributedModel) * [System.Composition.Convention](https://www.nuget.org/packages/System.Composition.Convention) * [System.Composition.Runtime](https://www.nuget.org/packages/System.Composition.Runtime)