steffbeckers / code-generator

.NET based code generator. Configure projects and generate boilerplate code with T4 templates, based on a simple JSON representation of domain models.
https://steffbeckers.eu/projects/code-generator
2 stars 1 forks source link

What license is this project using? #3

Open juicebyjustin opened 3 years ago

juicebyjustin commented 3 years ago

This is a very interesting project. I'm interesting in learning more about it.

  1. What license is this project using?
  2. What exactly does it do?

From what I can tell this generated a web API and an Angular frontend application using the ABP.io standard practices. I see there are models defined in code-gen-config.json.

steffbeckers commented 3 years ago

Still need to configure the license on the project, but I currently see this project as some dev tool which is free and open source.

steffbeckers commented 3 years ago

The main idea of the app is generating boilerplate code based on models using templates. Currently the code generation is always done by running the dotnet run command for the CodeGen project. The other CodeGen.API and CodeGen.FrontEnd projects are experimental.

You can configure the CodeGen project in the appsettings.json. Here you can choose which template to generate.

I would recommend using the Standalone setting, when false, the CodeGen project is supposed to listen to API call's, which is still experimental.

In the CodeGen/Templates/Projects folder you can define any type of project template you want, ABPWebAPI doesn't have any template files yet. A better example is the WebAPI project folder. In this folder you'll find .tt (T4 template) files which are most likely templates to generate C# source files (based on the models).

Each project template has a templatesettings.json configuration file. Extra template specific configuration is configured here. T4 templates configured in the ConfigBasedGenerator array, are generated with the whole code-gen-config.json context (C# object as parameter) and most likely produce 1 file. T4 template configured in the ModelsBasedGenerator array, are generated for each model, which could output multiple files. E.g. an entity class with properties for each model.

When running the CodeGen project, the project template is copied to a _Output folder. Every static file in the project template folder is copied. Afterwards all T4 templates are generated, and the output is also copied to the _Output folder. Which results in a "boilerplate" project. Which also after generating starts running as test.

The project itself is also more like a dev-tool. You'll be updating or adding templates quite frequently, configuring some other steps, adding extra code which need to be generated, finetuning settings and so on.

Feel free to ask help as something might not be clear yet.

juicebyjustin commented 3 years ago

Thanks for the detailed response. I have a .NET background, but I've been playing around with https://scaffoldhub.io/ lately. It has an online model editor, and generates both the angular/react frontend and nodejs backend. Somehow I ran across your project and learned that ABP.io is a thing. It looks like ABP.io provides all the functionality that Scaffoldhub.io provides but for .NET.

Have you played around with the idea of auto generating CRUD components in the frontend based on the data types of properties in the model? Ex: if you have a model defined that contains 3 properties: name, date, and image. The output Angular component will have add/edit components with a textbox for the name, date picker for the date, and image selector for the image.

Oh yea, is this open source?

steffbeckers commented 3 years ago

Oh yea, is this open source?

See my first response.

steffbeckers commented 3 years ago

The commercial version of ABP.io also comes with a ABP Suite tool, which includes code generation. https://docs.abp.io/en/commercial/latest/abp-suite/generating-crud-page

I have also added an Angular project template in het CodeGen project, where I did some testing generation a CRUD ui based on the data model. I think it's possible to include logic in the templates to generate the correct UI control based on the data type of the field/property.

radrad commented 3 years ago

Great project indeed. I howerver adopted this: Telosys Code Generator has a custom DSL language and support for intellisense, highlighting etc. for these editors: https://telosys.org/eclipsePlugin.html

Java based Telosys CLI can generate code based on entities defined in the model and Velocity .vm template language (VTL) is used for looping over attributes in the model Telosys groups .vm templates in a bundle which you can zip and place in a git repo and it can be downloaded locally. See the list of templates created: https://github.com/telosys-templates-v3 Once such bundle is: Telosys templates for C# web MVC application There is one for Angular They have a tutorial here: https://sites.google.com/site/telosystutorial/

I found it more flexible. Templates are matched with entities by using template configuration file: https://github.com/telosys-templates-v3/csharp-web-mvc/blob/master/templates.cfg There is a Telosys tools configuration (one per Telosys project) which allows to set target generation folder and other variables used throughout .vm templates and template configuration file: https://github.com/telosys-tools-bricks/telosys-tools-commons/blob/5eaa9be367d73d5afa4b0c9aa27118101a0ac4df/src/test/resources/telosys-tools.cfg

I am currently working on a abp.io code generator for both front end and backend. I extended this java-based tool to user c# classes using JNI bridge jni4net.j-0.8.8.0 to .net so I can augment code generation with c# code. For example, I am using this method here: https://efg.loresoft.com/en/latest/regeneration/ Basically I am using protected virtual void Merge Output(string fullPath, string outputContent) method in this code: https://github.com/loresoft/EntityFrameworkCore.Generator/blob/65254ef8208f1e1b6c337cf5c4bd087adf710ace/src/EntityFrameworkCore.Generator.Core/Templates/CodeTemplateBase.cs#L16 to merge generated code coming from .vm velocity template parsing and existing code that a developer could have modified, and it works beautifully. I don't have to introduce partial classes and method to handle code re-generation With this code generation, in addition to nice Abp.io CLI, you can make very flexible code re(generation)) system for c#. And build code generation for front end (Something like #region myregion ... #endregion can be invented to allow some customization of generated the front end code.

If any one is interested, I can show you, my progress.