Commit 39e3147
committed
Set
With mapped collections, items are added to the collection after they are mapped. With compatible properties, however, the property value is simply set as a reference to the original object. If the property is a collection, there's no evaluation or mapping of the individual items in the collection. As a result, the property must be settable—even though it's a collection, and we don't normally want collection-valued properties to be settable.
Previously, that necessitated the suppression of `CA2227`. With the introduction of `init`, however, we can replace the `set` with `init` to workaround this. Once we target .NET 5, this won't work and we'll need to reintroduce the suppression. But even then, `init` better communicates the expectations for this property. And, in fact, most new view models are actually implemented as `record` types to enforce this.VersionHistory to init only1 parent 62e6d2f commit 39e3147
1 file changed
Lines changed: 1 addition & 2 deletions
Lines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | 23 | | |
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
28 | | - | |
| 27 | + | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
0 commit comments