-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Split library and package Readme #78888
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a9d577f
Split library and package Readme
MSDN-WhiteKnight 944daa0
Fix punctuation
MSDN-WhiteKnight 170adeb
Fix lint issues
MSDN-WhiteKnight fc32b96
Automatically include package readme file if existent
ViktorHofer 1f95da5
Rename README.md to PACKAGE.md
ViktorHofer 1b0a89e
Move PACKAGE.md into source directory
ViktorHofer ea477be
Reinstate examples in README.md
MSDN-WhiteKnight 053003e
Merge remote-tracking branch 'upstream/main' into package-readme
MSDN-WhiteKnight f091280
Merge branch 'main' into package-readme
ViktorHofer 368609c
Update contributing guidelines
MSDN-WhiteKnight af34dcf
Update docs/coding-guidelines/libraries-packaging.md
ViktorHofer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Split library and package Readme
- Loading branch information
commit a9d577f1f78b848247e70cd5588b439d190704df
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
src/libraries/Microsoft.Extensions.Configuration.Abstractions/PACKAGE.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| ## About | ||
|
|
||
| Provides abstractions of key-value pair based configuration. Interfaces defined in this package are implemented by classes in [Microsoft.Extensions.Configuration](https://www.nuget.org/packages/Microsoft.Extensions.Configuration/) and other configuration packages. | ||
|
|
||
| Commonly used types: | ||
|
|
||
| - [Microsoft.Extensions.Configuration.IConfiguration](https://learn.microsoft.com/dotnet/api/microsoft.extensions.configuration.iconfiguration) | ||
| - [Microsoft.Extensions.Configuration.IConfigurationBuilder](https://learn.microsoft.com/dotnet/api/microsoft.extensions.configuration.iconfigurationbuilder) | ||
| - [Microsoft.Extensions.Configuration.IConfigurationProvider](https://learn.microsoft.com/dotnet/api/microsoft.extensions.configuration.iconfigurationprovider) | ||
| - [Microsoft.Extensions.Configuration.IConfigurationRoot](https://learn.microsoft.com/dotnet/api/microsoft.extensions.configuration.iconfigurationroot) | ||
| - [Microsoft.Extensions.Configuration.IConfigurationSection](https://learn.microsoft.com/dotnet/api/microsoft.extensions.configuration.iconfigurationsection) | ||
|
|
||
| For more information, see the documentation: [Configuration in .NET](https://learn.microsoft.com/dotnet/core/extensions/configuration). | ||
|
|
||
| ## Example | ||
|
|
||
| The example below shows a small code sample using this library and trying out the `ConfigurationKeyName` attribute available since .NET 6: | ||
|
|
||
| ```cs | ||
| public class MyClass | ||
| { | ||
| [ConfigurationKeyName("named_property")] | ||
| public string NamedProperty { get; set; } | ||
| } | ||
| ``` | ||
|
|
||
| Given the simple class above, we can create a dictionary to hold the configuration data and use it as the memory source to build a configuration section: | ||
|
|
||
| ```cs | ||
| var dic = new Dictionary<string, string> | ||
| { | ||
| {"named_property", "value for named property"}, | ||
| }; | ||
|
|
||
| var config = new ConfigurationBuilder() | ||
| .AddInMemoryCollection(dic) | ||
| .Build(); | ||
|
|
||
| var options = config.Get<MyClass>(); | ||
| Console.WriteLine(options.NamedProperty); // returns "value for named property" | ||
| ``` |
40 changes: 2 additions & 38 deletions
40
src/libraries/Microsoft.Extensions.Configuration.Abstractions/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
src/libraries/Microsoft.Extensions.Configuration.Binder/PACKAGE.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| ## About | ||
|
|
||
| Provides the functionality to bind an object to data in configuration providers for [Microsoft.Extensions.Configuration](https://www.nuget.org/packages/Microsoft.Extensions.Configuration/). This package enables you to represent the configuration data as strongly-typed classes defined in the application code. To bind a configuration, use the [Microsoft.Extensions.Configuration.ConfigurationBinder.Get](https://learn.microsoft.com/dotnet/api/microsoft.extensions.configuration.configurationbinder.get) extension method on the `IConfiguration` object. To use this package, you also need to install a package for the [configuration provider](https://learn.microsoft.com/dotnet/core/extensions/configuration#configuration-providers), for example, [Microsoft.Extensions.Configuration.Json](https://www.nuget.org/packages/Microsoft.Extensions.Configuration.Json/) for the JSON provider. | ||
|
|
||
| For more information, see the documentation: [Configuration in .NET](https://learn.microsoft.com/dotnet/core/extensions/configuration). | ||
|
|
||
| ## Example | ||
| The following example shows how to bind a JSON configuration section to .NET objects. | ||
|
|
||
| ```cs | ||
| using System; | ||
| using Microsoft.Extensions.Configuration; | ||
|
|
||
| class Settings | ||
| { | ||
| public string Server { get; set; } | ||
| public string Database { get; set; } | ||
| public Endpoint[] Endpoints { get; set; } | ||
| } | ||
|
|
||
| class Endpoint | ||
| { | ||
| public string IPAddress { get; set; } | ||
| public int Port { get; set; } | ||
| } | ||
|
|
||
| class Program | ||
| { | ||
| static void Main() | ||
| { | ||
| // Build a configuration object from JSON file | ||
| IConfiguration config = new ConfigurationBuilder() | ||
| .AddJsonFile("appsettings.json") | ||
| .Build(); | ||
|
|
||
| // Bind a configuration section to an instance of Settings class | ||
| Settings settings = config.GetSection("Settings").Get<Settings>(); | ||
|
|
||
| // Read simple values | ||
| Console.WriteLine($"Server: {settings.Server}"); | ||
| Console.WriteLine($"Database: {settings.Database}"); | ||
|
|
||
| // Read nested objects | ||
| Console.WriteLine("Endpoints: "); | ||
|
|
||
| foreach (Endpoint endpoint in settings.Endpoints) | ||
| { | ||
| Console.WriteLine($"{endpoint.IPAddress}:{endpoint.Port}"); | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| To run this example, include an `appsettings.json` file with the following content in your project: | ||
|
|
||
| ```json | ||
| { | ||
| "Settings": { | ||
| "Server": "example.com", | ||
| "Database": "Northwind", | ||
| "Endpoints": [ | ||
| { | ||
| "IPAddress": "192.168.0.1", | ||
| "Port": "80" | ||
| }, | ||
| { | ||
| "IPAddress": "192.168.10.1", | ||
| "Port": "8080" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| You can include a configuration file using a code like this in your `.csproj` file: | ||
|
|
||
| ```xml | ||
| <ItemGroup> | ||
| <Content Include="appsettings.json"> | ||
| <CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
| </Content> | ||
| </ItemGroup> | ||
| ``` |
82 changes: 2 additions & 80 deletions
82
src/libraries/Microsoft.Extensions.Configuration.Binder/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,91 +1,13 @@ | ||
| # Microsoft.Extensions.Configuration.Binder | ||
|
|
||
| Provides the functionality to bind an object to data in configuration providers for [Microsoft.Extensions.Configuration](https://www.nuget.org/packages/Microsoft.Extensions.Configuration/). This package enables you to represent the configuration data as strongly-typed classes defined in the application code. To bind a configuration, use the [Microsoft.Extensions.Configuration.ConfigurationBinder.Get](https://learn.microsoft.com/dotnet/api/microsoft.extensions.configuration.configurationbinder.get) extension method on the `IConfiguration` object. To use this package, you also need to install a package for the [configuration provider](https://learn.microsoft.com/dotnet/core/extensions/configuration#configuration-providers), for example, [Microsoft.Extensions.Configuration.Json](https://www.nuget.org/packages/Microsoft.Extensions.Configuration.Json/) for the JSON provider. | ||
| Provides the functionality to bind an object to data in configuration providers for [Microsoft.Extensions.Configuration](https://www.nuget.org/packages/Microsoft.Extensions.Configuration/). | ||
|
|
||
| Documentation can be found at https://learn.microsoft.com/dotnet/core/extensions/configuration | ||
|
|
||
| ## Contribution Bar | ||
| - [x] [We consider new features, new APIs, bug fixes, and performance changes](https://github.com/dotnet/runtime/tree/main/src/libraries#contribution-bar) | ||
| - [x] [We consider new features, new APIs, bug fixes, and performance changes](../README.md#contribution-bar) | ||
|
|
||
| The APIs and functionality are mature, but do get extended occasionally. | ||
|
|
||
| ## Deployment | ||
| [Microsoft.Extensions.Configuration.Binder](https://www.nuget.org/packages/Microsoft.Extensions.Configuration.Binder/) is included in the ASP.NET Core shared framework. The package is deployed as out-of-band (OOB) too and can be referenced into projects directly. | ||
|
|
||
| ## Example | ||
| The following example shows how to bind a JSON configuration section to .NET objects. | ||
|
|
||
| ```cs | ||
| using System; | ||
| using Microsoft.Extensions.Configuration; | ||
|
|
||
| class Settings | ||
| { | ||
| public string Server { get; set; } | ||
| public string Database { get; set; } | ||
| public Endpoint[] Endpoints { get; set; } | ||
| } | ||
|
|
||
| class Endpoint | ||
| { | ||
| public string IPAddress { get; set; } | ||
| public int Port { get; set; } | ||
| } | ||
|
|
||
| class Program | ||
| { | ||
| static void Main() | ||
| { | ||
| // Build a configuration object from JSON file | ||
| IConfiguration config = new ConfigurationBuilder() | ||
| .AddJsonFile("appsettings.json") | ||
| .Build(); | ||
|
|
||
| // Bind a configuration section to an instance of Settings class | ||
| Settings settings = config.GetSection("Settings").Get<Settings>(); | ||
|
|
||
| // Read simple values | ||
| Console.WriteLine($"Server: {settings.Server}"); | ||
| Console.WriteLine($"Database: {settings.Database}"); | ||
|
|
||
| // Read nested objects | ||
| Console.WriteLine("Endpoints: "); | ||
|
|
||
| foreach (Endpoint endpoint in settings.Endpoints) | ||
| { | ||
| Console.WriteLine($"{endpoint.IPAddress}:{endpoint.Port}"); | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| To run this example, include an `appsettings.json` file with the following content in your project: | ||
|
|
||
| ```json | ||
| { | ||
| "Settings": { | ||
| "Server": "example.com", | ||
| "Database": "Northwind", | ||
| "Endpoints": [ | ||
| { | ||
| "IPAddress": "192.168.0.1", | ||
| "Port": "80" | ||
| }, | ||
| { | ||
| "IPAddress": "192.168.10.1", | ||
| "Port": "8080" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| You can include a configuration file using a code like this in your `.csproj` file: | ||
|
|
||
| ```xml | ||
| <ItemGroup> | ||
| <Content Include="appsettings.json"> | ||
| <CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
| </Content> | ||
| </ItemGroup> | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/libraries/Microsoft.Extensions.Configuration.CommandLine/PACKAGE.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| ## About | ||
|
|
||
| Command line configuration provider implementation for [Microsoft.Extensions.Configuration](https://www.nuget.org/packages/Microsoft.Extensions.Configuration/). This package enables you to read configuration parameters from the command line arguments of your application. You can use [CommandLineConfigurationExtensions.AddCommandLine](https://learn.microsoft.com/dotnet/api/microsoft.extensions.configuration.commandlineconfigurationextensions.addcommandline) extension method on `IConfigurationBuilder` to add the command line configuration provider to the configuration builder. | ||
|
|
||
| For more information, see the documentation: [Command-line configuration provider](https://learn.microsoft.com/dotnet/core/extensions/configuration-providers#command-line-configuration-provider). | ||
|
|
||
| ## Example | ||
|
|
||
| The following example shows how to read application configuration from the command line. You can use a command like `dotnet run --InputPath "c:\fizz" --OutputPath "c:\buzz"` to run it. | ||
|
|
||
| ```cs | ||
| using System; | ||
| using Microsoft.Extensions.Configuration; | ||
|
|
||
| class Program | ||
| { | ||
| static void Main(string[] args) | ||
| { | ||
| // Build a configuration object from command line | ||
| IConfiguration config = new ConfigurationBuilder() | ||
| .AddCommandLine(args) | ||
| .Build(); | ||
|
|
||
| // Read configuration values | ||
| Console.WriteLine($"InputPath: {config["InputPath"]}"); | ||
| Console.WriteLine($"OutputPath: {config["OutputPath"]}"); | ||
| } | ||
| } | ||
| ``` |
28 changes: 2 additions & 26 deletions
28
src/libraries/Microsoft.Extensions.Configuration.CommandLine/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,37 +1,13 @@ | ||
| # Microsoft.Extensions.Configuration.CommandLine | ||
|
|
||
| Command line configuration provider implementation for [Microsoft.Extensions.Configuration](https://www.nuget.org/packages/Microsoft.Extensions.Configuration/). This package enables you to read configuration parameters from the command line arguments of your application. You can use [CommandLineConfigurationExtensions.AddCommandLine](https://learn.microsoft.com/dotnet/api/microsoft.extensions.configuration.commandlineconfigurationextensions.addcommandline) extension method on `IConfigurationBuilder` to add the command line configuration provider to the configuration builder. | ||
| Command line configuration provider implementation for [Microsoft.Extensions.Configuration](https://www.nuget.org/packages/Microsoft.Extensions.Configuration/). | ||
|
|
||
| Documentation can be found at https://learn.microsoft.com/dotnet/core/extensions/configuration-providers#command-line-configuration-provider | ||
|
|
||
| ## Contribution Bar | ||
| - [x] [We consider new features, new APIs, bug fixes, and performance changes](https://github.com/dotnet/runtime/tree/main/src/libraries#contribution-bar) | ||
| - [x] [We consider new features, new APIs, bug fixes, and performance changes](../README.md#contribution-bar) | ||
|
|
||
| The APIs and functionality are mature, but do get extended occasionally. | ||
|
|
||
| ## Deployment | ||
| [Microsoft.Extensions.Configuration.CommandLine](https://www.nuget.org/packages/Microsoft.Extensions.Configuration.CommandLine/) is included in the ASP.NET Core shared framework. The package is deployed as out-of-band (OOB) too and can be referenced into projects directly. | ||
|
|
||
| ## Example | ||
|
|
||
| The following example shows how to read application configuration from the command line. You can use a command like `dotnet run --InputPath "c:\fizz" --OutputPath "c:\buzz"` to run it. | ||
|
|
||
| ```cs | ||
| using System; | ||
| using Microsoft.Extensions.Configuration; | ||
|
|
||
| class Program | ||
| { | ||
| static void Main(string[] args) | ||
| { | ||
| // Build a configuration object from command line | ||
| IConfiguration config = new ConfigurationBuilder() | ||
| .AddCommandLine(args) | ||
| .Build(); | ||
|
|
||
| // Read configuration values | ||
| Console.WriteLine($"InputPath: {config["InputPath"]}"); | ||
| Console.WriteLine($"OutputPath: {config["OutputPath"]}"); | ||
| } | ||
| } | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.