From bef9c4abf047ec25fd864112d3a8e6071b4aa59b Mon Sep 17 00:00:00 2001 From: Buyaa Namnan Date: Thu, 12 Sep 2024 13:23:03 -0700 Subject: [PATCH] [release/9.0] Backport some PACKAGE.md files (#107724) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Provide System.Composition package readme (#106443) * Provide System.Composition package readme * Fix empty lines * Provide System.Composition.AttributedModel package readme (#106781) * Provide System.Composition.AttributedModel package readme * Improve after feedback * Set correct PackageDescription * Provide System.Composition.Convention package readme (#106782) * Provide System.Composition.Convention package readme * Improve after feedback * Provide System.Composition.Hosting package readme (#106783) * Provide System.Composition.Hosting package readme * Improve after feedback * Provide System.Composition.Runtime package readme (#106784) * Provide System.Composition.Runtime package readme * Improve after feedback * Provide System.Composition.TypedParts package readme (#106785) * Provide System.Composition.TypedParts package readme * Improve after feedback * Provide System.CodeDom package readme (#107372) * Provide System.CodeDom package readme * Add remark about Roslyn/.NET Compiler SDK * Update src/libraries/System.CodeDom/src/PACKAGE.md --------- Co-authored-by: Buyaa Namnan --------- Co-authored-by: Michaƫl Hompus --- src/libraries/System.CodeDom/src/PACKAGE.md | 127 ++++++++++++++++ .../System.CodeDom/src/System.CodeDom.csproj | 10 +- .../src/PACKAGE.md | 140 ++++++++++++++++++ .../System.Composition.AttributedModel.csproj | 9 +- .../src/PACKAGE.md | 97 ++++++++++++ .../src/System.Composition.Convention.csproj | 11 +- .../System.Composition.Hosting/src/PACKAGE.md | 80 ++++++++++ .../src/System.Composition.Hosting.csproj | 7 +- .../System.Composition.Runtime/src/PACKAGE.md | 87 +++++++++++ .../src/System.Composition.Runtime.csproj | 7 +- .../src/PACKAGE.md | 88 +++++++++++ .../src/System.Composition.TypedParts.csproj | 8 +- .../System.Composition/src/PACKAGE.md | 77 ++++++++++ .../src/System.Composition.csproj | 13 +- 14 files changed, 703 insertions(+), 58 deletions(-) create mode 100644 src/libraries/System.CodeDom/src/PACKAGE.md create mode 100644 src/libraries/System.Composition.AttributedModel/src/PACKAGE.md create mode 100644 src/libraries/System.Composition.Convention/src/PACKAGE.md create mode 100644 src/libraries/System.Composition.Hosting/src/PACKAGE.md create mode 100644 src/libraries/System.Composition.Runtime/src/PACKAGE.md create mode 100644 src/libraries/System.Composition.TypedParts/src/PACKAGE.md create mode 100644 src/libraries/System.Composition/src/PACKAGE.md diff --git a/src/libraries/System.CodeDom/src/PACKAGE.md b/src/libraries/System.CodeDom/src/PACKAGE.md new file mode 100644 index 0000000000000..2785a3e5888a3 --- /dev/null +++ b/src/libraries/System.CodeDom/src/PACKAGE.md @@ -0,0 +1,127 @@ +## About + + + +Provides functionality for dynamically generating and compiling source code using the Code Document Object Model (CodeDOM). + +It allows developers to represent code in a language-agnostic format and then generate code in multiple languages, such as C# and VB.NET. +The primary use cases include creating dynamic code generation tools, runtime code generation, and facilitating code analysis or transformation. + +For a new modern development consider using the [.NET Compiler Platform SDK](https://learn.microsoft.com/dotnet/csharp/roslyn-sdk/), in particular [Roslyn source generators](https://learn.microsoft.com/dotnet/csharp/roslyn-sdk/source-generators-overview#get-started-with-source-generators). + +## Key Features + + + +* Write code using a common object model that can be translated into multiple programming languages. +* Generate and compile code at runtime based on the CodeDOM. + +## How to Use + + + +Generating and compiling C# code: + +```csharp +using System.CodeDom; +using System.CodeDom.Compiler; +using Microsoft.CSharp; + +// Create a new CodeCompileUnit to hold the code +var compileUnit = new CodeCompileUnit(); + +// Create a namespace +var codeNamespace = new CodeNamespace("MyNamespace"); +compileUnit.Namespaces.Add(codeNamespace); + +// Create a class +var classDeclaration = new CodeTypeDeclaration("MyClass") +{ + IsClass = true +}; +codeNamespace.Types.Add(classDeclaration); + +// Add a simple method to the class +var method = new CodeMemberMethod +{ + Name = "HelloWorld", + ReturnType = new CodeTypeReference(typeof(void)), +}; +classDeclaration.Members.Add(method); + +var methodInvocation = new CodeMethodInvokeExpression(new CodeTypeReferenceExpression("Console"), + "WriteLine", + new CodePrimitiveExpression("Hello, World!")); +method.Statements.Add(methodInvocation); + +// Generate C# code from the CodeDOM structure +CodeDomProvider provider = new CSharpCodeProvider(); + +using (var writer = new StringWriter()) +{ + var codeGenereationOptions = new CodeGeneratorOptions() + { + BlankLinesBetweenMembers = false, + IndentString = " ", + }; + + provider.GenerateCodeFromCompileUnit(compileUnit, writer, codeGenereationOptions); + Console.WriteLine(writer.GetStringBuilder().ToString()); +} +``` + +This example generates: + +```csharp +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace MyNamespace { + + public class MyClass { + private void HelloWorld() { + Console.WriteLine("Hello, World!"); + } + } +} +``` + +## Main Types + + + +The main types provided by this library are: + +* `System.CodeDom.CodeObject` +* `System.CodeDom.CodeCompileUnit` +* `System.CodeDom.CodeNamespace` +* `System.CodeDom.CodeTypeDeclaration` +* `System.CodeDom.CodeMemberMethod` +* `System.CodeDom.CodeTypeReference` +* `System.CodeDom.CodeMethodInvokeExpression` +* `System.CodeDom.CodeTypeReferenceExpression` +* `System.CodeDom.CodePrimitiveExpression` +* `System.CodeDom.Compiler.CodeDomProvider` +* `System.CodeDom.Compiler.CodeGeneratorOptions` +* `Microsoft.CSharp.CSharpCodeProvider` +* `Microsoft.VisualBasic.VBCodeProvider` + +## Additional Documentation + + + +* [API documentation](https://learn.microsoft.com/dotnet/api/system.codedom) +* [Compile and generate dynamic source code](https://learn.microsoft.com/dotnet/framework/reflection-and-codedom/dynamic-source-code-generation-and-compilation) + +## Feedback & Contributing + + + +System.CodeDom 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.CodeDom/src/System.CodeDom.csproj b/src/libraries/System.CodeDom/src/System.CodeDom.csproj index a987278ff0539..76ba0e1a9d3f6 100644 --- a/src/libraries/System.CodeDom/src/System.CodeDom.csproj +++ b/src/libraries/System.CodeDom/src/System.CodeDom.csproj @@ -6,19 +6,11 @@ false false true - Provides types that can be used to model the structure of a source code document and to output source code for that model in a supported language. - -Commonly Used Types: -System.CodeDom.CodeObject -System.CodeDom.Compiler.CodeDomProvider -Microsoft.CSharp.CSharpCodeProvider -Microsoft.VisualBasic.VBCodeProvider + Provides types that can be used to model the structure of a source code document and to output source code for that model in C# or Visual Basic. disable $(NoWarn);nullable - - false diff --git a/src/libraries/System.Composition.AttributedModel/src/PACKAGE.md b/src/libraries/System.Composition.AttributedModel/src/PACKAGE.md new file mode 100644 index 0000000000000..57bbc8bf0329b --- /dev/null +++ b/src/libraries/System.Composition.AttributedModel/src/PACKAGE.md @@ -0,0 +1,140 @@ +## About + + + +`System.Composition.AttributedModel` 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 the foundational attributes that allow you to declare parts for composition, such as imports, exports, and metadata. +It is used to mark classes, properties, methods, and constructors for MEF's discovery and composition process. + +## Key Features + + + +* Provides attributes for declaring composable parts, importing dependencies, metadata, and creating shared or non-shared parts + +## How to Use + + + +Mark classes for export and import using attributes. + +```csharp +using System.Composition; +using System.Composition.Hosting; + +var configuration = new ContainerConfiguration() + .WithPart() + .WithPart(); + +using CompositionHost container = configuration.CreateContainer(); + +Application app = container.GetExport(); +app.Service.Execute(); +// Service is running! + +[Export] +public class Application +{ + [Import] + public Service Service { get; set; } +} + +[Export] +public class Service +{ + public void Execute() => Console.WriteLine("Service is running!"); +} +``` + +Metadata can be used to differentiate between multiple exports of the same contract. + +```csharp +using System.Composition; +using System.Composition.Hosting; + +ContainerConfiguration configuration = new ContainerConfiguration() + .WithPart() + .WithPart() + .WithPart(); + +using CompositionHost container = configuration.CreateContainer(); + +Application app = container.GetExport(); +app.Run(); +// Using FileLogger to log. +// FileLogger: Hello, World! +// Using ConsoleLogger to log. +// ConsoleLogger: Hello, World! + +public interface ILogger +{ + void Log(string message); +} + +[Export(typeof(ILogger))] +[ExportMetadata("Name", "FileLogger")] +public class FileLogger : ILogger +{ + public void Log(string message) => Console.WriteLine($"FileLogger: {message}"); +} + +[Export(typeof(ILogger))] +[ExportMetadata("Name", "ConsoleLogger")] +public class ConsoleLogger : ILogger +{ + public void Log(string message) => Console.WriteLine($"ConsoleLogger: {message}"); +} + +[Export] +public class Application +{ + [ImportMany] + public required IEnumerable>> Loggers { get; set; } + + public void Run() + { + foreach (var logger in Loggers) + { + var name = logger.Metadata["Name"]; + + Console.WriteLine($"Using {name} to log."); + logger.Value.Log("Hello, World!"); + } + } +} +``` + +## Main Types + + + +The main types provided by this library are: + +* `System.Composition.ExportAttribute` +* `System.Composition.ImportAttribute` +* `System.Composition.ExportMetadataAttribute` + +## Additional Documentation + + + +* [API documentation](https://learn.microsoft.com/dotnet/api/system.composition) +* [Managed Extensibility Framework (MEF)](https://learn.microsoft.com/dotnet/framework/mef/) + +## Related Packages + + + +* [System.Composition](https://www.nuget.org/packages/System.Composition) +* [System.Composition.Convention](https://www.nuget.org/packages/System.Composition.Convention) +* [System.Composition.Hosting](https://www.nuget.org/packages/System.Composition.Hosting) +* [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.AttributedModel 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.AttributedModel/src/System.Composition.AttributedModel.csproj b/src/libraries/System.Composition.AttributedModel/src/System.Composition.AttributedModel.csproj index 21e5bd32d21de..44856544cf5dd 100644 --- a/src/libraries/System.Composition.AttributedModel/src/System.Composition.AttributedModel.csproj +++ b/src/libraries/System.Composition.AttributedModel/src/System.Composition.AttributedModel.csproj @@ -5,17 +5,10 @@ Microsoft false true - Provides common attributes used by System.Composition types. - -Commonly Used Types: -System.Composition.ExportAttribute -System.Composition.ImportAttribute -System.Composition.Convention.AttributedModelProvider + Provides the foundational attributes that allow you to declare parts for composition, such as imports, exports, and metadata with the Managed Extensibility Framework (MEF). disable $(NoWarn);nullable - - false diff --git a/src/libraries/System.Composition.Convention/src/PACKAGE.md b/src/libraries/System.Composition.Convention/src/PACKAGE.md new file mode 100644 index 0000000000000..4f6e1fdc2358c --- /dev/null +++ b/src/libraries/System.Composition.Convention/src/PACKAGE.md @@ -0,0 +1,97 @@ +## 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. + +```csharp +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() + .Export(); + +var configuration = new ContainerConfiguration() + .WithPart(conventions) + .WithPart(conventions); + +using CompositionHost container = configuration.CreateContainer(); + +var loggers = container.GetExports(); + +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 + + + +* [API documentation](https://learn.microsoft.com/dotnet/api/system.composition.convention) +* [Managed Extensibility Framework (MEF)](https://learn.microsoft.com/dotnet/framework/mef/) + +## Related Packages + + + +* [System.Composition](https://www.nuget.org/packages/System.Composition) +* [System.Composition.AttributedModel](https://www.nuget.org/packages/System.Composition.AttributedModel) +* [System.Composition.Hosting](https://www.nuget.org/packages/System.Composition.Hosting) +* [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.Convention 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.Convention/src/System.Composition.Convention.csproj b/src/libraries/System.Composition.Convention/src/System.Composition.Convention.csproj index 8e1f44ee3df72..2544944eec76e 100644 --- a/src/libraries/System.Composition.Convention/src/System.Composition.Convention.csproj +++ b/src/libraries/System.Composition.Convention/src/System.Composition.Convention.csproj @@ -6,19 +6,10 @@ Microsoft false true - Provides types that support using Managed Extensibility Framework with a convention-based configuration model. - -Commonly Used Types: -System.Composition.Convention.ConventionBuilder -System.Composition.Convention.ExportConventionBuilder -System.Composition.Convention.ImportConventionBuilder -System.Composition.Convention.PartConventionBuilder -System.Composition.Convention.ParameterImportConventionBuilder + Provides types that support using Managed Extensibility Framework (MEF) with a convention-based configuration model. disable $(NoWarn);nullable - - false 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 0000000000000..9f5556e7a4d7b --- /dev/null +++ b/src/libraries/System.Composition.Hosting/src/PACKAGE.md @@ -0,0 +1,80 @@ +## 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 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. + +## 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](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) +* [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 cd017f48b6939..18d027e8ad14b 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 diff --git a/src/libraries/System.Composition.Runtime/src/PACKAGE.md b/src/libraries/System.Composition.Runtime/src/PACKAGE.md new file mode 100644 index 0000000000000..177bb8026881e --- /dev/null +++ b/src/libraries/System.Composition.Runtime/src/PACKAGE.md @@ -0,0 +1,87 @@ +## About + + + +`System.Composition.Runtime` 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 enables the discovery and composition of parts in applications using MEF 2.0. +It offers the runtime implementation needed for managing composable parts, resolving dependencies, and dynamically wiring components together. + +## Key Features + + + +* Facilitates runtime discovery and composition of parts. + +## How to Use + + + +Resolve dependencies on the fly and can be useful for dynamically loaded components or plugins. + +```csharp +using System.Composition; +using System.Composition.Hosting; + +var configuration = new ContainerConfiguration() + .WithPart(); + +using CompositionHost container = configuration.CreateContainer(); + +var consumer = new Consumer(container); +consumer.Execute(); +// Service is running. + +public interface IService +{ + void Run(); +} + +[Export(typeof(IService))] +public class Service : IService +{ + public void Run() => Console.WriteLine("Service is running."); +} + +public class Consumer(CompositionContext context) +{ + public void Execute() + { + // Use the context to resolve the service + var service = context.GetExport(); + service.Run(); + } +} +``` + +## Main Types + + + +The main type provided by this library is: + +* `System.Composition.CompositionContext` + +## Additional Documentation + + + +* [API documentation](https://learn.microsoft.com/dotnet/api/system.composition.compositioncontext) +* [Managed Extensibility Framework (MEF)](https://learn.microsoft.com/dotnet/framework/mef/) + +## Related Packages + + + +* [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.Hosting](https://www.nuget.org/packages/System.Composition.Hosting) +* [System.Composition.TypedParts](https://www.nuget.org/packages/System.Composition.TypedParts) + +## Feedback & Contributing + + + +System.Composition.Runtime 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.Runtime/src/System.Composition.Runtime.csproj b/src/libraries/System.Composition.Runtime/src/System.Composition.Runtime.csproj index 57ee9457ea35b..93ef06e572afe 100644 --- a/src/libraries/System.Composition.Runtime/src/System.Composition.Runtime.csproj +++ b/src/libraries/System.Composition.Runtime/src/System.Composition.Runtime.csproj @@ -7,15 +7,10 @@ Microsoft false true - Contains runtime components of the Managed Extensibility Framework. - -Commonly Used Types: -System.Composition.CompositionContext + Contains runtime components of the Managed Extensibility Framework (MEF). disable $(NoWarn);nullable - - false diff --git a/src/libraries/System.Composition.TypedParts/src/PACKAGE.md b/src/libraries/System.Composition.TypedParts/src/PACKAGE.md new file mode 100644 index 0000000000000..de02f4525c866 --- /dev/null +++ b/src/libraries/System.Composition.TypedParts/src/PACKAGE.md @@ -0,0 +1,88 @@ +## About + + + +`System.Composition.TypedParts` is part of the Managed Extensibility Framework (MEF) 2.0, a composition library for .NET that enables dependency injection through attributes or conventions. + +Provides `ContainerConfiguration` and some extension methods for the Managed Extensibility Framework (MEF). + +## Key Features + + + +* Provides container configuration. + +## How to Use + + + +Register parts from an entire assembly. + +```csharp +using System.Composition; +using System.Composition.Hosting; +using System.Reflection; + +// Register all parts from the current assembly +var configuration = new ContainerConfiguration() + .WithAssembly(Assembly.GetExecutingAssembly()); + +using CompositionHost container = configuration.CreateContainer(); + +var handlers = container.GetExports(); +foreach (var handler in handlers) +{ + handler.Handle(); +} +// HandlerA is handling. +// HandlerB is handling. + +public interface IHandler +{ + void Handle(); +} + +[Export(typeof(IHandler))] +public class HandlerA : IHandler +{ + public void Handle() => Console.WriteLine("HandlerA is handling."); +} + +[Export(typeof(IHandler))] +public class HandlerB : IHandler +{ + public void Handle() => Console.WriteLine("HandlerB is handling."); +} +``` + +## Main Types + + + +The main types provided by this library are: + +* `System.Composition.Hosting.ContainerConfiguration` +* `System.Composition.CompositionContextExtensions` + +## Additional Documentation + + + +* [Managed Extensibility Framework (MEF)](https://learn.microsoft.com/dotnet/framework/mef/) + +## Related Packages + + + +* [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.Hosting](https://www.nuget.org/packages/System.Composition.Hosting) +* [System.Composition.Runtime](https://www.nuget.org/packages/System.Composition.Runtime) + +## Feedback & Contributing + + + +System.Composition.TypedParts 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.TypedParts/src/System.Composition.TypedParts.csproj b/src/libraries/System.Composition.TypedParts/src/System.Composition.TypedParts.csproj index 4e82792a39994..3a2874d9d3f0b 100644 --- a/src/libraries/System.Composition.TypedParts/src/System.Composition.TypedParts.csproj +++ b/src/libraries/System.Composition.TypedParts/src/System.Composition.TypedParts.csproj @@ -8,16 +8,10 @@ Microsoft false true - Provides some extension methods for the Managed Extensibility Framework. - -Commonly Used Types: -System.Composition.CompositionContextExtensions -System.Composition.Hosting.ContainerConfiguration + Provides container configuration and some extension methods for the Managed Extensibility Framework (MEF). disable $(NoWarn);nullable - - false diff --git a/src/libraries/System.Composition/src/PACKAGE.md b/src/libraries/System.Composition/src/PACKAGE.md new file mode 100644 index 0000000000000..d6378b7ed0d56 --- /dev/null +++ b/src/libraries/System.Composition/src/PACKAGE.md @@ -0,0 +1,77 @@ +## About + + + +Provides the Managed Extensibility Framework (MEF) 2.0, a lightweight, attribute-driven Dependency Injection (DI) container. + +MEF simplifies the composition of applications by allowing components to be loosely coupled and dynamically discovered. +This package supports the development of modular and maintainable applications by enabling parts to be composed at runtime. + +## Key Features + + + +* Components are discovered and composed using attributes. +* Provides dependency injection capabilities for loosely coupled modules. + +## How to Use + + + +Running code from a discovered component. + +```csharp +using System.Composition; +using System.Composition.Hosting; + +var configuration = new ContainerConfiguration().WithPart(); + +using var container = configuration.CreateContainer(); + +var service = container.GetExport(); +service.Execute(); +// Output: Service is running! + +[Export] +public class Service +{ + public void Execute() => Console.WriteLine("Service is running!"); +} +``` + +## Main Types + + + +The main types provided by this library are: + +* `System.Composition.ExportAttribute` +* `System.Composition.ImportAttribute` +* `System.Composition.Convention.ConventionBuilder` +* `System.Composition.Hosting.CompositionHost` +* `System.Composition.CompositionContext` +* `System.Composition.CompositionContextExtensions` + +## Additional Documentation + + + +* [API documentation](https://learn.microsoft.com/dotnet/api/system.composition) +* [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.Hosting](https://www.nuget.org/packages/System.Composition.Hosting) +* [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 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/src/System.Composition.csproj b/src/libraries/System.Composition/src/System.Composition.csproj index 0d0c67320ef72..a360f80b58e2b 100644 --- a/src/libraries/System.Composition/src/System.Composition.csproj +++ b/src/libraries/System.Composition/src/System.Composition.csproj @@ -8,21 +8,10 @@ $(NoWarn);NU5128 false - This package provides a version of the Managed Extensibility Framework (MEF) that is lightweight and specifically optimized for high throughput scenarios, such as the web. - -Commonly Used Types: -System.Composition.ExportAttribute -System.Composition.ImportAttribute -System.Composition.Convention.ConventionBuilder -System.Composition.Hosting.CompositionHost -System.Composition.CompositionContext -System.Composition.CompositionContextExtensions - + Provides a version of the Managed Extensibility Framework (MEF) that is lightweight and specifically optimized for high throughput scenarios, such as the web. disable $(NoWarn);nullable - - false