Person

Simple person record with different properties (builtin types like string, System type DateTime, type parameter TDetails).

Given:

Person.cs

using System;
using Amadevus.RecordGenerator;

namespace Example
{
    [Record(Features.Default | Features.Equality)]
    public sealed partial class Person<TDetails>
    {
        public string FirstName { get; }

        public string LastName { get; }

        public string Address { get; }

        public DateTime Birthday { get; }

        public TDetails Details { get; }
    }
}

Generates (in /obj intermediate directory):

Person.xBtil6W2.generated.cs ```cs // —————————————————————————— // // 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 System; using Amadevus.RecordGenerator;

namespace Example { partial class Person { [System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")] public Person(string firstName, string lastName, string address, DateTime birthday, TDetails details) { this.FirstName = firstName; this.LastName = lastName; this.Address = address; this.Birthday = birthday; 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 Person<TDetails> Update(string firstName, string lastName, string address, DateTime birthday, TDetails details)
    {
        return new Person<TDetails>(firstName, lastName, address, birthday, details);
    }

    [System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
    public Person<TDetails> WithFirstName(string value)
    {
        return Update(value, LastName, Address, Birthday, Details);
    }

    [System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
    public Person<TDetails> WithLastName(string value)
    {
        return Update(FirstName, value, Address, Birthday, Details);
    }

    [System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
    public Person<TDetails> WithAddress(string value)
    {
        return Update(FirstName, LastName, value, Birthday, Details);
    }

    [System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
    public Person<TDetails> WithBirthday(DateTime value)
    {
        return Update(FirstName, LastName, Address, value, Details);
    }

    [System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
    public Person<TDetails> WithDetails(TDetails value)
    {
        return Update(FirstName, LastName, Address, Birthday, value);
    }

    [System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
    public override string ToString() => new
    {
    FirstName, LastName, Address, Birthday, Details
    }

    .ToString();
}

partial class Person<TDetails>
{
    [System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
    public Builder ToBuilder()
    {
        return new Builder{FirstName = FirstName, LastName = LastName, Address = Address, Birthday = Birthday, Details = Details};
    }

    public partial class Builder
    {
        [System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
        public string FirstName
        {
            get;
            set;
        }

        [System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
        public string LastName
        {
            get;
            set;
        }

        [System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
        public string Address
        {
            get;
            set;
        }

        [System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
        public DateTime Birthday
        {
            get;
            set;
        }

        [System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
        public TDetails Details
        {
            get;
            set;
        }

        [System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
        public Person<TDetails> ToImmutable()
        {
            return new Person<TDetails>(FirstName, LastName, Address, Birthday, Details);
        }
    }
}

partial class Person<TDetails>
{
    [System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
    public void Deconstruct(out string firstName, out string lastName, out string address, out DateTime birthday, out TDetails details)
    {
        firstName = this.FirstName;
        lastName = this.LastName;
        address = this.Address;
        birthday = this.Birthday;
        details = this.Details;
    }
}

partial class Person<TDetails>
{
    [System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
    public override bool Equals(object obj)
    {
        return obj is Person<TDetails> other && this.Equals(other);
    }

    [System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
    public override int GetHashCode()
    {
        unchecked
        {
            var hashCode = 2085527896;
            hashCode = hashCode * -1521134295 + System.Collections.Generic.EqualityComparer<string>.Default.GetHashCode(FirstName);
            hashCode = hashCode * -1521134295 + System.Collections.Generic.EqualityComparer<string>.Default.GetHashCode(LastName);
            hashCode = hashCode * -1521134295 + System.Collections.Generic.EqualityComparer<string>.Default.GetHashCode(Address);
            hashCode = hashCode * -1521134295 + System.Collections.Generic.EqualityComparer<DateTime>.Default.GetHashCode(Birthday);
            hashCode = hashCode * -1521134295 + System.Collections.Generic.EqualityComparer<TDetails>.Default.GetHashCode(Details);
            return hashCode;
        }
    }
}

partial class Person<TDetails> : System.IEquatable<Person<TDetails>>
{
    [System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
    public bool Equals(Person<TDetails> other)
    {
        return ReferenceEquals(this, other) || other != null && FirstName == other.FirstName && LastName == other.LastName && Address == other.Address && System.Collections.Generic.EqualityComparer<DateTime>.Default.Equals(Birthday, other.Birthday) && System.Collections.Generic.EqualityComparer<TDetails>.Default.Equals(Details, other.Details);
    }
}

partial class Person<TDetails>
{
    [System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
    public static bool operator ==(Person<TDetails> left, Person<TDetails> right)
    {
        return System.Collections.Generic.EqualityComparer<Person<TDetails>>.Default.Equals(left, right);
    }

    [System.CodeDom.Compiler.GeneratedCodeAttribute("Amadevus.RecordGenerator", "0.6.0.0")]
    public static bool operator !=(Person<TDetails> left, Person<TDetails> right)
    {
        return !(left == right);
    }
} } ```