-
Notifications
You must be signed in to change notification settings - Fork 393
Look into alternatives to code generators #522
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
Comments
Hello, Another option could be usind CodeDom (https://docs.microsoft.com/en-us/dotnet/framework/reflection-and-codedom/how-to-create-a-class-using-codedom) to generate the classes. The code for class generation could be packed in a dotnet core tools package and the be executed from commandline. |
Thanks @ptr1120, I forgot about that approach. Looking through the samples though, I think maybe it adds a lot of generator complexity and is perhaps better suited for more dynamic code generation. Our needs are quite simple, almost static with just some parameters, and for that purpose I think I would prefer PowerShell or some other string/template-based generators. |
@angularsen, you are right I know CodeDom is very complex. A template-based approach would be also better for supporting other languages like java, or javascript. In the future, it would be nice to have a complete data/model-driven approach where a command-line tool (npm/nuget) allows the generation of the complete code (preferably also the CustomCode) from the UnitDefinitions files. |
Yes exactly, I've been toying with the idea of generating for TypeScript/JavaScript and other languages but I simply haven't had the time and need for it to purse the idea further - but it's completely possible, and as you say this would be simpler to reuse with a template-based generator. |
Related to #410 |
I've tried ScriptCS lately in a different project. Although I like the promise of C# instead of PowerShell and built-in support for nugets with no project files required to run - it fails on a simple but essential thing; there is very poor tooling support as of today. VS Code and JetBrains Rider fail to recognize this variant of C# syntax, so all intellisense and refactoring tools are out the window. In that project, I wound up creating a simple .NET Core console app instead and using With nugets like https://github.com/commandlineparser/commandline, you can get very nice help screens and argument parsers with verbs/commands support. You don't get the nice auto-complete feature PowerShell has for script arguments, and you need a separate folder per "script" since there is a project file and typically some other files too beyond the Update 2019-04-17: |
I took a closer look at Geco, and although I think it has some nice helper code it seems very oriented towards Entity Framework so I'm thinking it might be enough to copy some of the helper code and write our own CLI using Microsoft's new Dragonfruit CLI parser linked above and doing plain old string outputs to files. It should be pretty straight forward. |
PowerShell works, but it's slow and the type system is very limited and can be challenging to work with compared to C#. For instance, parsing JSON into types for intellisense and sharing types between script files does not work very well in Visual Studio, VS Code or Rider.
This issue is just to have a place to dump ideas for improving the code generator, we will only make the jump if it makes considerable improvements over PowerShell.
Geco
Simple code generator based on a console project, running on .Net core and using C# interpolated strings.
https://github.com/iQuarc/Geco
Pros:
ScriptCS(out of favor due to poor tooling support)Write C# apps with a text editor, nuget and the power of Roslyn!
https://github.com/scriptcs/scriptcs
Pros:
.csx
files without any projectsCons:
ScriptCS
on developer PCsStringBuilder
andFile.WriteAllText
The text was updated successfully, but these errors were encountered: