RSCG – Gobie
| name | Gobie |
| nuget | https://www.nuget.org/packages/Gobie/ |
| link | https://github.com/GobieGenerator/Gobie/ |
| author | Mike Conrad |
templating for classes,fields …
This is how you can use Gobie .
The code that you start with is
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Gobie" Version="0.5.0-alpha" />
</ItemGroup>
<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GX</CompilerGeneratedFilesOutputPath>
</PropertyGroup>
</Project>
The code that you will use is
using GobieDemo; Person p = new(); p.Name = "Andrei "; //this comes from Gobie template p.Id = 1;
using Gobie;
namespace GobieDemo;
[ClassGenAddId()]
partial class Person
{
public string? Name { get; set; }
}
using Gobie;
namespace GobieDemo;
[GobieGeneratorName("ClassGenAddId")]
public sealed class ClassGenAddId : GobieClassGenerator
{
[GobieFileTemplate("ID")]
private const string LogString = @"
using System;
namespace {{ClassNamespace}};
partial class {{ClassName}}
{
public int Id { get; set; }
}
";
}
The code that is generated is
namespace GobieDemo
{
public partial class Person
{
}
}
using System;
namespace GobieDemo;
partial class Person
{
public int Id { get; set; }
}
namespace Gobie
{
/// <summary> This attribute will cause the generator defined by this thing here to
/// run <see cref = "Gobie.ClassGenAddId"/> to run. </summary>
public sealed class ClassGenAddIdAttribute : global::Gobie.GobieClassGeneratorAttribute
{
public ClassGenAddIdAttribute()
{
}
}
}
Code and pdf at
https://ignatandrei.github.io/RSCG_Examples/v2/docs/Gobie
Leave a Reply