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
***[v1.2.1]** Now supports generating ToBuilder() and a better OptParam implementation.
6
7
***[v1.2.0]** Now supports generating builders.
7
8
***[v1.2.0]** WithParam class is now called OptParam.
8
9
***[v1.1.5]** Added a PreConstructor option to write code such as atributtes before generated constructors.
@@ -40,7 +41,11 @@ It will automatically generate for you in a separate partial class file the foll
40
41
```c#
41
42
varbuilder=newPerson.Builder().With(firstName: "John").With(lastName: "Doe"); // fluid way
42
43
builder.Age=21; // or via properties
44
+
// that can be read back
45
+
stringfirstName=builder.FirstName; // "John"
46
+
varlastName=builder.LastName.Value; // "Doe"
43
47
PersonjohnDoe=b.Build();
48
+
varjaneDoe=johnDoe.ToBuilder().With(firstName: "Jane", age: 20).Build(); // back and forth
44
49
```
45
50
46
51
## How do I start?
@@ -93,7 +98,8 @@ You sure can, just add to the ImmutableClass attribute something like this:
93
98
ImmutableClassOptions.ExcludeToString|// do not generate a ToString() method
94
99
ImmutableClassOptions.ExcludeWith|// do not generate a With() method
95
100
ImmutableClassOptions.ExcludeConstructor|// do not generate a constructor
96
-
ImmutableClassOptions.ExcludeBuilder|// do not generate a builder (usually used alongside ExcludeConstructor)
101
+
ImmutableClassOptions.ExcludeBuilder|// do not generate a builder or ImmutableToBuilder() - implies ExcludeToBuilder (usually used alongside ExcludeConstructor)
102
+
ImmutableClassOptions.ExcludeToBuilder|// do not generate a builder or ToBuilder() method
Note that even if you exclude for example the `Equals()` method implementation you can still use them internally by invoking the `private bool ImmutableEquals(...)` implementation. This is done in case you might want to write your own `Equals()` yet still use the generated one as a base.
@@ -285,12 +291,21 @@ partial class Person : IEquatable<Person> {
0 commit comments