You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
classPerson{publicstringFirstName{get;init;}publicstringLastName{get;init;}publicPerson(Personcopy){this.FirstName = copy.FirstName;this.LasName = copy.LastName;}}varjohnDoe=new Person {FirstName="John",LastName="Doe"};varjaneDoe=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?
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:
I see the Bond compiler CLI already has a
--readonly-properties
switch for makingprivate 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
The text was updated successfully, but these errors were encountered: