-
Notifications
You must be signed in to change notification settings - Fork 1
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
Replace runtime reflection with compile-time source generator #8
Merged
Conversation
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
Enable the Trimmable analyzers, decorate reflection-based methods with attributes, and remove or rework incompatible features. * Remove 'AddCommandsFromAssembly' and friends because they are not compatible with trimming. * Remove support for TypeConverter-based parsing of parameter values. * Remove support for reflection-based Parse() and ctor(string) parsing of parameter values, but replace the most common cases with hard-coded default converters.
Move types that model application configuration or state to the new namespace XO.Console.Cli.Model. Types in this namespace may be public, but should not be part of the core consumer-facing API.
Differentiate types by 'Implementation' vs 'Infrastructure' instead of by access modifier.
Make CommandBuilder public, and shuffle around interfaces to remove the torturous default interface implementation of 'AddCommand' and friends.
The code generated by the analyzer project depends on the core library, so it's very difficult to debug generator failures when the core library won't build because the generator's failing! Instead, hand-write a factory implementation for CommandParameters.
Improve declarative configuration to support sub-commands using a scheme similar to the 'click' Python library: apply CommandBranchAttribute to a custom subclass of CommandAttribute, then use the custom attribute class to declare sub-commands. * Add a 'Description' property to CommandAttribute instead of using the built-in DescriptionAttribute. All declarative configuration for a command comes from a single instance of CommandAttribute (or, for sub-commands, a subclass thereof). * CommandAttribute is NOT required for imperative runtime configuration and has no effect on it. No surprises or magic when adding commands at runtime! * Improve source generator feedback and performance.
Use experience from writing the CommandBuilder source generator to improve performance and reliability.
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
Remove some redundant ones, add back in some warmed-up simple jobs, and pass args to the runner.
These ILLink packages get added to the dependency graph when AOT is enabled, and the added version is dependent on the SDK version.
Instead of generating the same builder-pattern code a user would write, construct each ConfiguredCommand directly.
Clarify the generator pipeline and the interaction between each step, improve caching efficiency where possible, and split the code up into separate files for readability. Simplify the code generation logic for declaratively-configured commands.
DescribeParameters returns the complete list of arguments and options for derived parameters types, so the parser needs to keep track of which ones have already been added to the state. Add a string identifying the declaring type and property name to the generated parameters models.
Breaking Changes
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add a new project, XO.Console.Cli.Analyzers, that generates source for both commands and parameters types at compile time. Support declarative configuration of command hierarchies using a scheme similar to the 'click' Python library.
TODO
CommandParametersFactory
if there are no types definedAddCommandApp(this IServiceCollection services)