-
Notifications
You must be signed in to change notification settings - Fork 498
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
Configuration Schema generator #1383
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.
<PropertyGroup> | ||
|
||
<GeneratorCommandLine>"$(DotNetTool)" exec $(ConfigurationSchemaGeneratorPath)</GeneratorCommandLine> | ||
<GeneratorCommandLine>$(GeneratorCommandLine) --input "@(IntermediateAssembly)"</GeneratorCommandLine> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't looked at it in a while, but TargetsTriggeredByCompilation is guaranteed to be called after CoreCompile, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whenever CoreCompile runs Csc
, it will <CallTarget Targets="$(TargetsTriggeredByCompilation)"
src/Components/Aspire.Azure.Storage.Blobs/AspireBlobStorageExtensions.cs
Outdated
Show resolved
Hide resolved
}, | ||
"GeoRedundantSecondaryUri": { | ||
"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." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
</Target> | ||
|
||
<Target Name="CompareConfigurationSchema" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct.
Refactor attributes to be more understandable and easier to use.
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 dotnet/aspire#1383. The plan is to keep this in sync using automated PRs to dotnet/aspire when the dotnet/runtime code is updated. (dotnet/aspire#1424). Contributing this fix back so these two code bases can stay in sync.
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
Logging
section in appsettings.jsonThis tool works after compilation by scanning the assembly for
ConfigurationSchema
andLoggingCategories
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.The remaining work to address after the initial PR:
cc @eiriktsarpalis @tarekgh
Fix #1146
Microsoft Reviewers: Open in CodeFlow