History
Given Entry record type enclosed in History type:
History.cs
using Amadevus.RecordGenerator;
namespace Example
{
public partial class History
{
[Record]
private partial struct Entry
{
public int Id { get; }
public string Name { get; }
public string Details { get; }
}
}
}
Note: Enclosing type as well as record type must be declared partial, if they aren’t RecordGen1000 error is raised (the generated partial won’t compile).
Generates (in /obj
intermediate directory):
History.T9mS2gf-.generated.cs
```csharp // —————————————————————————— //// This code was generated by a tool. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // // ——————————————————————————
using Amadevus.RecordGenerator;
namespace Example { public partial class History { partial struct Entry { [System.CodeDom.Compiler.GeneratedCodeAttribute(“Amadevus.RecordGenerator”, “0.6.0.0”)] public Entry(int id, string name, string details) { this.Id = id; this.Name = name; this.Details = details; OnConstructed(); }
[System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
partial void OnConstructed();
[System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
public Entry Update(int id, string name, string details)
{
return new Entry(id, name, details);
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
public Entry WithId(int value)
{
return Update(value, Name, Details);
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
public Entry WithName(string value)
{
return Update(Id, value, Details);
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
public Entry WithDetails(string value)
{
return Update(Id, Name, value);
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
public override string ToString() => new
{
Id, Name, Details
}
.ToString();
}
partial struct Entry
{
[System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
public Builder ToBuilder()
{
return new Builder{Id = Id, Name = Name, Details = Details};
}
public partial class Builder
{
[System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
public int Id
{
get;
set;
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
public string Name
{
get;
set;
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
public string Details
{
get;
set;
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
public Entry ToImmutable()
{
return new Entry(Id, Name, Details);
}
}
}
partial struct Entry
{
[System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
public void Deconstruct(out int id, out string name, out string details)
{
id = this.Id;
name = this.Name;
details = this.Details;
}
}
} } ```