Mapper Generator

When developing back-end system, almost 50% development time is wasted at repetitive job of writing CRUD and mapping classes. Most of the time it is wasted at class->properties definition. That’s why I try to develop a Mapper Generator, a tools which can be used to read C# class, parse it with defined structures to resulting class.

Mapper generator is a tools in which it accept C# class definition, parse it into pre-processed model using template, and furthermore will be processed into final result file using template. It is developed using C# .Net Framework 4.5, Winform, Roslyn (Microsoft.CodeAnalysis 1.0.0-rc3), StringTemplate (ST3), and Dynamic Linq Library.

The flow

Defined Sturcture Template

There are 3 general steps of converting the class definition into resulting template. First is to define the structure (template) using structure manager.

The structure configuration

The structure configuration

Here you can define the template in which the class will be converted. The template here are defined using StringTemplate notations. So you can use any of StringTemplate capabilities into the template.

Define the source model

Class model definition put into generator

Class model definition put into generator

Here you must define the source model (C# class) which contains the properties that you want to process. The model later then will be parsed using Roslyn and be converted into preprocessed model.

Pre-Processing

Defined model is processed further using structure template

Defined model is processed further using structure template

The model definition (upper part) can be checked at this screen. The model definition consist of the following hierarchy:

Tree -> Namespace -> Class -> Property

The structure template (at the middle) can be choose to pre-process the model. Then after pushing the “Generate Template” button, it will be converted into pre-processed model at the bottom screen.

This screen also enables you to download the pre-processed model into xml, which will be useful for further external-apps processing.

Generated

Result of generated template

Result of generated template

The generated class will be processed based on pre-processed model.

Project information

I intentionally want this project as open source. So if you think that you want to contribute or fork the base project, feel free to contact me. Feedback are also acceptable.

Github: https://github.com/fendy3002/MapperGenerator

Download Link: https://drive.google.com/folderview?id=0B3YQYa7Pleu8fk5QZktGOXloc1poRGctOExadzZEZU5fRjNtTzJzaTlmODBCY1JiMUJGS0U&usp=sharing

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s