This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Description
C# 9 introduced init properties that allow using object initializers to set readonly properties. This is quite useful for enforcing the copy-on-write pattern for immutable objects:
class Person
{
public string FirstName { get; init; }
public string LastName { get; init; }
public Person(Person copy)
{
this.FirstName = copy.FirstName;
this.LasName = copy.LastName;
}
}
var johnDoe = new Person { FirstName = "John", LastName = "Doe" };
var janeDoe = new Person(johnDoe) { FirstName = "Jane" };
I see the Bond compiler CLI already has a --readonly-properties switch for making private set properties on generated classes, but that is too restrictive for this use case. Is it possible to add a new switch such as --init-properties to allow the above code sample on a Bond-generated class?
Related: #439