All Projects → iQuarc → Geco

iQuarc / Geco

Licence: apache-2.0
Simple code generator based on a console project, running on .Net core and using C# interpolated strings

Programming Languages

csharp
926 projects

Projects that are alternatives of or similar to Geco

Efdesigner
Entity Framework visual design surface and code-first code generation for EF6, Core and beyond
Stars: ✭ 256 (+163.92%)
Mutual labels:  code-generation, code-generator
Javaparser
Java 1-15 Parser and Abstract Syntax Tree for Java, including preview features to Java 13
Stars: ✭ 3,972 (+3994.85%)
Mutual labels:  code-generation, code-generator
Xmlschemaclassgenerator
Generate C# classes from XML Schema files
Stars: ✭ 277 (+185.57%)
Mutual labels:  code-generation, code-generator
qm
QM model-based design tool and code generator based on UML state machines
Stars: ✭ 54 (-44.33%)
Mutual labels:  code-generator, code-generation
Dogen
Reference implementation of the MASD Code Generator.
Stars: ✭ 44 (-54.64%)
Mutual labels:  code-generation, code-generator
katapult
Kickstart Rails development!
Stars: ✭ 21 (-78.35%)
Mutual labels:  template-engine, code-generation
Loopy
A code generator for array-based code on CPUs and GPUs
Stars: ✭ 367 (+278.35%)
Mutual labels:  code-generation, code-generator
Kodgen
C++17 parser and code generator
Stars: ✭ 19 (-80.41%)
Mutual labels:  code-generator, code-generation
Colfer
binary serialization format
Stars: ✭ 597 (+515.46%)
Mutual labels:  code-generation, code-generator
Laravel Code Generator
An intelligent code generator for Laravel framework that will save you time! This awesome tool will help you generate resources like views, controllers, routes, migrations, languages and/or form-requests! It is extremely flexible and customizable to cover many on the use cases. It is shipped with cross-browsers compatible template, along with a client-side validation to modernize your application.
Stars: ✭ 485 (+400%)
Mutual labels:  code-generation, code-generator
autogenu-jupyter
An automatic code generator for nonlinear model predictive control (NMPC) and the continuation/GMRES method (C/GMRES) based numerical solvers for NMPC
Stars: ✭ 89 (-8.25%)
Mutual labels:  code-generator, code-generation
Mid
mid is a generic domain-specific language for generating code and documentation
Stars: ✭ 68 (-29.9%)
Mutual labels:  code-generation, code-generator
molicode
molicode
Stars: ✭ 75 (-22.68%)
Mutual labels:  code-generator, code-generation
php-code-generator
PHP code generator library
Stars: ✭ 144 (+48.45%)
Mutual labels:  code-generator, code-generation
nunavut
Generate code from DSDL using PyDSDL and Jinja2
Stars: ✭ 23 (-76.29%)
Mutual labels:  code-generator, code-generation
Fpp
Functional PHP Preprocessor - Generate Immutable Data Types
Stars: ✭ 282 (+190.72%)
Mutual labels:  code-generation, code-generator
php-json-schema-model-generator
Creates (immutable) PHP model classes from JSON-Schema files including all validation rules as PHP code
Stars: ✭ 36 (-62.89%)
Mutual labels:  code-generator, code-generation
copygen
Go generator to copy values from type to type and fields from struct to struct (copier without reflection). Generate any code based on types.
Stars: ✭ 121 (+24.74%)
Mutual labels:  code-generator, code-generation
Codemaker
A idea-plugin for Java/Scala, support custom code template.
Stars: ✭ 440 (+353.61%)
Mutual labels:  code-generation, code-generator
Scala Db Codegen
Scala code/boilerplate generator from a db schema
Stars: ✭ 49 (-49.48%)
Mutual labels:  code-generation, code-generator

Geco, (Ge)nerator (Co)nsole

Simple code generator based on a console project, running on .Net Core and using C# interpolated strings.

Geco runs on .Net Core 3.1. Download and Install

What's the reasoning behind this utility?

One of the most popular code generation tools for Visual Studio over the years was T4 (Text Template Transformation Toolkit), which saw a great deal of success for simple to complex code generation tasks. Scott Hanselman has a nice blog post about it. However, since the advent of .Net Core and .Net going cross platform there is no simple way to generate code or other artifacts that would also work in Visual Studio Code (or other code editors).

This is where the idea for this simple utility came from. Have a small utility for code generation that is debuggable (one of the long standing issues of T4), provides some level of intellisense, can be run at build time, is higly customizable, generic and has an as small as possible footprint.

Installation

Geco can be installed as a Visual Studio Project Template or as dotnet new template.

To install Geco as a dotnet new template run the following command on a console or terminal:

dotnet new -i iQuarc.Geco.CSharp

Then create a new project using the newly installed template:

dotnet new geco

To create a Geco project when installed as a Visual Studio Project template, Select File -> New project select the Geco template.

A more indetail Getting Sstarted with Visual Studio walkthrough can be found on the Wiki: Geting Started

Geco can also be installed as a Git submodule. Geco.Core is the git repository which should be added. The recomendation is to add it to a folder called .Tools

git submodule add https://github.com/iQuarc/Geco.Core.git .Tools

Code Generation examples

Bellow are some snippets from the included code generation tasks that are in the default Geco package.

Next snippet is from the included Entity Framework Core Reverse model generator EntityFrameworkCoreReverseModelGenerator.cs, which exemplifies part of the code generation:

Geco Preview1

This snippet is from the SQL Seed Scrip Generator SeedDataGenerator.cs, which generates SQL Merge scripts for Seed data:

Geco Preview2

Next screen shot shows Geco running in interactive mode (as a Console App), and the menu that is presented to the user:

Geco Preview3

Description

Geco uses C# 6.0 string interpolation as a template engine for code generation, in order to allow:

  • Easy customization of templates (Simply edit the .cs file)
  • Easy debugging (Place a breakpoint an run)
  • Easy extensibility (Add a new task by creating a new C# class and implement a simple interface IRunnable)

Geco uses task discovery at runtime and each task is configured using Dependency Injection. The generation tasks can be run during build or from interactive mode (Debug Run).

Included generators

The following generator tasks are included in current version.

  • Entity Framework Core 1.1, 2.0 Reverse model generator
  • SQL Seed data script generator (Generates MERGE scripts)
  • SQL Script runner
  • Database cleaner

Customizing

  1. The first customization option involves changing task parameters from appsettings.json configuration file. Each Geco task defines its own set of parameters (see the corresponding Options class):
{
    "ConnectionStrings": {
        "DefaultConnection": "Integrated Security=True;Initial Catalog=AdventureWorks;Data Source=.\\SQLEXPRESS;"
    },
    "RunAtBuildTasks": [
        "Generate EF Core model"
    ],
    "Tasks": [
        {
            "Name": "Generate EF Core model",
            "TaskClass": "Geco.Database.EntityFrameworkCoreReverseModelGenerator",
            "BaseOutputPath": "..\\..\\Generated\\Model\\",
            "OutputToConsole": "false",
            "CleanFilesPattern": "*.cs",
            "Options": {
                "ConnectionName": "DefaultConnection",
                "Namespace": "Model",
                "OneFilePerEntity": true,
                "JsonSerialization": true,
                "GenerateComments": true,
                "UseSqlServer": true,
                "ConfigureWarnings": true,
                "GeneratedCodeAttribute": false,
                "NetCore": true,
                "ContextName":"AdventureworksContext"
            }
        }
    ]
}
  1. By customizing existing templates directly.

  2. By creating new code generation tasks as a C# class which implements the IRunnable interface.

IRunnable is a single method interface containing the Run method:

   /// <summary>
   /// Represents a runable task, for code generation or purposes or others
   /// </summary>
   public interface IRunnable
   {
       /// <summary>
       /// Invoked when this task is executed
       /// </summary>
       void Run();
   }   

or by deriving from one of the helper base classes BaseGenerator or BaseGeneratorWithMetadata.

A code generation class can be accompanied by an Options POCO class to hold customization parameters from appsettings.json

Example:

    public class SeedDataGeneratorOptions
    {
        public string ConnectionName { get; set; }
        public string OutputFileName { get; set; }
        public List<string> Tables { get; } = new List<string>();
        public string TablesRegex { get; set; }
        public List<string> ExcludedTables { get; } = new List<string>();
        public string ExcludedTablesRegex { get; set; }
        public int ItemsPerStatement { get; set; } = 1000;
    }
        /// <summary>
    /// Generates seed scripts with merge statements for (Sql Server)
    /// </summary>
    [Options(typeof(SeedDataGeneratorOptions))]
    public class SeedDataGenerator : BaseGeneratorWithMetadata
    {
    // ...
    }
    

Roadmap

  • ASP.Net MVC Template (scaffolds controllers and views)
  • ASP.Net + Angular scaffolder (scaffolds Web Api and components)
  • SQL Sever to SQL Compact data sync template (Api to synchronize schema compatible SQL Server and SQL Compact databases including Web Api and .Net client methods)

Version History

Version 1.0.9

  • Updated Geco to .Net Core 3.1

Version 1.0.8

  • Fix VS dependency version

Version 1.0.7

  • Add support for VS 2019
  • Add support for Ignored columns in Seed Data generator (Sergiu Damian)
  • Add support in Seed Data Generator to order rows by clustered Index (Sergiu Damian)

Version 1.0.6

  • Update to netcoreapp2.1

Version 1.0.5

  • Fixed pluralization bug
  • Fixed issue with current directory, not being set to bin\
  • Fixed nullable date time not being generated correctly

Version 1.0.4

  • Replaced EnglishInflector with Humanizer based version
  • Improved metadata API to allow easier removal of tables and columns along with dependent objects
  • Improved SeedScriptRunner error message when the seed file does not exist

Version 1.0.3

  • Fix SqlServerMetadataProvider bug with global database triggers
  • Added display of errors in interactive

Version 1.0.2

  • Added constraint delete behavior support
  • Modified logo

Version 1.0.1

  • Changed Entity Framework Core generator to allow multi column foreign keys
  • Fixed MetaData for MaxLength nvarchar and nchar columns
  • Removed tables without primary key from generated model
  • Switched to semver

Version 1.0.0.2

  • Changed user confirmation mechanism
  • Added user confirmation for file cleaning
  • Added more options for color output to console, formattable strings with tuple (value, ConsoleColor) parameters

Version 1.0.0.1

  • First release as a nuget dotnet new template

Version 1.0.0.0-beta

  • Initial Version
  • Contains code generation core functionality and SimpleMetadata model for databases
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].