Configuration Schema generator#1383
Merged
eerhardt merged 21 commits intomicrosoft:mainfrom Dec 15, 2023
Merged
Conversation
Use XDcoument to parse the doc comments. Strip xml elements from summary, strip new lines, and escape invalid chars.
Skip properties that are obsolete, editorbrowsable(never), or not settable. Support Uris.
Fix doc comments on the root objects - use the Type's summary.
…hey don't match. Add an option to update the checked in file.
Remove unnecessary attributes. Ensure Specs folder matches runtime code. Ensure Roslyn and SourceGenerators common folders match runtime code.
Use the Parser from dotnet/runtime and inject more methods into it using the partial class. Mock out the DiagnosticDescriptors because we don't need localization.
joperezr
reviewed
Dec 13, 2023
joperezr
reviewed
Dec 13, 2023
joperezr
reviewed
Dec 13, 2023
joperezr
reviewed
Dec 13, 2023
| <PropertyGroup> | ||
|
|
||
| <GeneratorCommandLine>"$(DotNetTool)" exec $(ConfigurationSchemaGeneratorPath)</GeneratorCommandLine> | ||
| <GeneratorCommandLine>$(GeneratorCommandLine) --input "@(IntermediateAssembly)"</GeneratorCommandLine> |
Member
There was a problem hiding this comment.
Haven't looked at it in a while, but TargetsTriggeredByCompilation is guaranteed to be called after CoreCompile, right?
Member
Author
There was a problem hiding this comment.
Whenever CoreCompile runs Csc, it will <CallTarget Targets="$(TargetsTriggeredByCompilation)"
joperezr
reviewed
Dec 13, 2023
joperezr
reviewed
Dec 13, 2023
src/Components/Aspire.Azure.Storage.Blobs/AspireBlobStorageExtensions.cs
Outdated
Show resolved
Hide resolved
joperezr
reviewed
Dec 13, 2023
| "type": "string", | ||
| "format": "uri", | ||
| "description": "Gets or sets the secondary storage Uri that can be read from for the storage account if the account is enabled for RA-GRS." | ||
| "description": "Gets or sets the secondary storage T:System.Uri that can be read from for the storage account if the\r\n account is enabled for RA-GRS.\r\n \r\n If this property is set, the secondary Uri will be used for GET or HEAD requests during retries.\r\n If the status of the response from the secondary Uri is a 404, then subsequent retries for\r\n the request will not use the secondary Uri again, as this indicates that the resource\r\n may not have propagated there yet. Otherwise, subsequent retries will alternate back and forth\r\n between primary and secondary Uri." |
Member
There was a problem hiding this comment.
Interesting, I'm curious, how does this render in the IDE, I suppose it actually shows the new lines as opposed to having the new line characters printed out?
Member
Author
There was a problem hiding this comment.
joperezr
reviewed
Dec 13, 2023
|
|
||
| </Target> | ||
|
|
||
| <Target Name="CompareConfigurationSchema" |
Contributor
There was a problem hiding this comment.
Is it supposed to be where the logic to verify the json file that is committed in the repos is up to date with the curent code?
sebastienros
approved these changes
Dec 15, 2023
Refactor attributes to be more understandable and easier to use.
This was referenced Dec 15, 2023
stephentoub
pushed a commit
to dotnet/runtime
that referenced
this pull request
Jan 2, 2024
The TypeParseInfo.BinderInvocation is a nullable property. If it happens to be null, these two places will throw a null ref. .NET Aspire is reusing this code to generate JSON schemas for appsettings.json files. See microsoft/aspire#1383. The plan is to keep this in sync using automated PRs to dotnet/aspire when the dotnet/runtime code is updated. (microsoft/aspire#1424). Contributing this fix back so these two code bases can stay in sync.
Merged
1 task
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.

Adds a tool that automatically generates ConfigurationSchema.json files for components.
To use the tool, a component adds an assembly attribute. For example:
ConfigurationSchemaAttribute
LoggingCategoriesAttribute
Loggingsection in appsettings.jsonThis tool works after compilation by scanning the assembly for
ConfigurationSchemaandLoggingCategoriesattributes, 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
RuntimeSourcefolder 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.The remaining work to address after the initial PR:
cc @eiriktsarpalis @tarekgh
Fix #1146
Microsoft Reviewers: Open in CodeFlow