-
Notifications
You must be signed in to change notification settings - Fork 457
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configuration Schema generator (#1383)
Adds a tool that automatically generates ConfigurationSchema.json files for components. To use the tool, a component adds an assembly attribute. For example: ```C# [assembly: ConfigurationSchema("Aspire:Azure:Storage:Blobs", typeof(AzureStorageBlobsSettings))] [assembly: ConfigurationSchema("Aspire:Azure:Storage:Blobs:ClientOptions", typeof(BlobClientOptions), exclusionPaths: ["Default"])] [assembly: LoggingCategories("Azure", "Azure.Core", "Azure.Identity")] ``` ### ConfigurationSchemaAttribute * The first parameter is the config section path where the type is loaded from. * The second parameter is the Type that is bound at that path. * ExclusionPaths - (optional) The config sections to exclude from the ConfigurationSchema. This is useful if there are properties you don't want to publicize in the config schema. ### LoggingCategoriesAttribute * The list of log categories produced by the component. These categories will show up under the `Logging` section in appsettings.json This tool works after compilation by scanning the assembly for `ConfigurationSchema` and `LoggingCategories` attributes, and uses Roslyn APIs to inspect all properties of the types. It reuses all the parsing logic from https://github.com/dotnet/runtime/tree/main/src/libraries/Microsoft.Extensions.Configuration.Binder/gen, and using the underlying model objects, generates a JSON schema using System.Text.Json.Nodes APIs. I've copied the necessary code from dotnet/runtime into the `RuntimeSource` folder for now. This code doesn't need to be reviewed since it is a straight copy from dotnet/runtime. After this PR goes through, we will set up an automatic "sync" action that will update this code anytime changes in the dotnet/runtime code is updated. Fix #1146
- Loading branch information
Showing
56 changed files
with
4,683 additions
and
62 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,11 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Aspire.Azure.Storage.Blobs; | ||
using Aspire; | ||
using Azure.Storage.Blobs; | ||
|
||
[assembly: ConfigurationSchema("Aspire:Azure:Storage:Blobs", typeof(AzureStorageBlobsSettings))] | ||
[assembly: ConfigurationSchema("Aspire:Azure:Storage:Blobs:ClientOptions", typeof(BlobClientOptions), exclusionPaths: ["Default"])] | ||
|
||
[assembly: LoggingCategories("Azure", "Azure.Core", "Azure.Identity")] |
This file contains 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 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 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,15 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Aspire.MySqlConnector; | ||
using Aspire; | ||
|
||
[assembly: ConfigurationSchema("Aspire:MySqlConnector", typeof(MySqlConnectorSettings))] | ||
|
||
[assembly: LoggingCategories( | ||
"MySqlConnector", | ||
"MySqlConnector.ConnectionPool", | ||
"MySqlConnector.MySqlBulkCopy", | ||
"MySqlConnector.MySqlCommand", | ||
"MySqlConnector.MySqlConnection", | ||
"MySqlConnector.MySqlDataSource")] |
Oops, something went wrong.