GenMac 0.0.5
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet tool install --global GenMac --version 0.0.5
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
dotnet tool install --local GenMac --version 0.0.5
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=GenMac&version=0.0.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
nuke :add-package GenMac --version 0.0.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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 | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. 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.