GenMac 0.0.4

There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global GenMac --version 0.0.4
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local GenMac --version 0.0.4
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=GenMac&version=0.0.4
                    
nuke :add-package GenMac --version 0.0.4
                    

GenMac

CLI driven code generator.

Installation

dotnet tool install --global GenMac

Universal Syntax for Generating C# Models.

genmac csp.model <dataType>:<attribute-name>:<required>:<label>

Syntax for C# attributes

For String Attribute

string:<attribute-name>:<required>:<label:optional>:<length:optional>:<default:optional>:<minlength:optional>:<maxlength:optional>

A Title attribute of type string can look like this.

string:title:required:Title:40:NA:3:40

This will generate an attribute like below.

[Required()]
[Display(Name = "Title")]
[StringLength(40)]
[MinLength(3)]
[MaxLength(40)]
public string Title { get; set; } = "NA";

For Integer Attribute

int:<attribute-name>:<required>:<label:optional>:<default:optional>:<minvalue:optional>:<maxvalue:optional>

A Count attribute of type integer can look like this.

int:count:required:Count:10:5:50

This will generate an attribute like below.

[Required()]
[Display(Name = "Count")]
[Range(5, 50)]
public int Count { get; set; }  = 10;

For Has Many (Relation) Attribute

hasmany:<attribute-name>:<label:optional>

Establishing a "has many" relation can be done like this.

hasmany:locations:Locations

This will generate an attribute like below.

[Display(Name = "Locations")]
public virtual List<Location> Locations { get; set; } = new List<Location>();

For Belongs To (Relation) Attribute

belongsto:<entity-name>:<attribute-name>:<label:optional>

A foreign key referencing another table can be done like this.

belongsto:organization:organization-id:Organization

This will generate an attribute like below.

[Display(Name = "Organization")]
[ForeignKey("OrganizationId")]
public int OrganizationId { get; set; }
[Display(Name = "Organization")]
public virtual Organization? Organization { get; set; }

For Boolean Attribute

bool:<attribute-name>:<required>:<label:optional>:<default:optional>

Something like an "Is Archived" attribute og type bool can look like this.

bool:is-archived:req:"Is Archived":false

This will generate an attribute like below.

[Required()]
[Display(Name = "IsArchived")]
public bool IsArchived { get; set; }  = false;

For DateTime Attribute

datetime:<attribute-name>:<required>:<label:optional>:<default:optional>

Something like a Created On attribute of type datetinme can look like this.

datetime:created-on:req:CreatedOn:12,3,2022

This will generate an attribute like below.

[Required()]
[Display(Name = "CreatedOn")]
public DateTime CreatedOn { get; set; }  = new DateTime(12,3,2005);

Usage Example

genmac csp.model models sample string:title string:desc:required:Description:40:NA:3:40 int:count:required:Count:10:5:50 hasmany:locations:Locations belongsto:organization:organization-id:Organization bool:is-archived:req:"Is Archived":false datetime:created-on:req:CreatedOn

Status

New data types anf flags coming soon.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
0.0.8 140 6/18/2024
0.0.7 111 6/13/2024
0.0.6 313 3/14/2023
0.0.5 269 3/13/2023
0.0.4 292 3/12/2023
0.0.3 310 3/12/2023
0.0.2 330 3/12/2023
0.0.1 276 3/12/2023