Refactoring the ModelsBuilder TextWriter to use Interfaces and DI for more flexibility in how we build our models #17096
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.
Prerequisites
Description
This is based off this discussion 17047
The aim of this pull request is to enable further customization of the TextBuilder for Models generation, generating csharp classes by splitting up the existing implementation into multiple classes and interfaces that are registered for dependency injection.
I have done my best to document the new interfaces. Actual implementation yields indentical models to existing implementation. But by allowing it to run with dependency injection, package developers and others are now able to replace and decorate functionality closer to what they are trying to solve with the TextBuilder.
The new interfaces are:
IBuilderBase which is thought of as a dependency for basically anything related to generate models. (Previously Builder.cs)
ITextBuilder - extracted from the TextBuilder implementation, exposes 2 Generate methods.
ITextBuilderActions - first level down in complexity, exposing methods for writing header, usings, namespaces, class definition, properties etc.
ITextBuilderSubActions - nitty gritty level where you affect individual items of a class, such as attributes written on top of methods and properties, as well as actual property implementation.