Skip to content
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

RFC: rgen transformer #21703

Open
haritha-mohan opened this issue Nov 27, 2024 · 2 comments
Open

RFC: rgen transformer #21703

haritha-mohan opened this issue Nov 27, 2024 · 2 comments
Milestone

Comments

@haritha-mohan
Copy link
Contributor

Objective

The rgen transformer tool is a key component in the transition from using reflection-based code generation as currently used in bgen to the new Roslyn based approach.

The objective of the transformer is to convert the old bindings to a format compatible with the new Roslyn-based code generator. For example, this will include converting interfaces to classes and updating outdated attributes.

Since this will be a 1:1 mapping, this allows for these transformations to be automated- significantly reducing manual intervention, helps to mitigate errors, and will expedite the transition process.

Workflow

rgen transformer will be a .NET command line tool that will load syntax trees from existing files containing the old bindings and perform transformations on the encountered nodes.

The tool will accept the following arguments:

  • Input directory/file path containing outdated bindings
  • Output directory path to write the transformed files out to

The workflow will be as follows:

  • Load the C# files and their corresponding syntax tree representations
  • Parse the syntax trees and categorize the members as interfaces, classes, enums, delegates, etc.
  • Extract the old binding data into an internal model. This leverages some of the work that has already been done by Manuel for the code generator.
  • Convert the old bindings into a format required by the new Roslyn code generator
    • Detailed examples of transformations handled by the tool are outlined in the original RFC: RFC: Migrate bgen to use roslyn instead of the reflection API. #21308 (comment), but at a high level will involve updating several attributes regarding platform availability and nullability, converting interfaces to classes, etc.
    • The transformed data will be stored in a data model representing the new binding format
  • C# files with the new bindings will be written out to the specified output directory

RFC-rgen-transform

Testing

Throughout the development workflow, thorough unit tests will be added to ensure the tool works as expected, integrates well with the existing codebase, and is effective is providing a smooth transition to the new code generator.

Distribution

The tool will be available to download as a .NET global tool via NuGet as dotnet-rgen-transform (or something along those lines, name is subject to change). This ensures the tool will be accessible for both internal developers and external customers.

@rolfbjarne rolfbjarne added this to the Future milestone Nov 28, 2024
@mcumming
Copy link
Contributor

mcumming commented Dec 2, 2024

The tool will accept the following arguments:

Are the arguments positional or named?

@haritha-mohan
Copy link
Contributor Author

The tool will accept the following arguments:

Are the arguments positional or named?

named

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants