-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Improve read-only collection/dictionary support #822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
A couple of observations:
|
(of course, if that's what we already do for lists, then it becomes more doable/consistent; is that the driver here?) |
Yep, I remove it because it's started failing, actually, it stops throwing an exception, and yes it looks like a breaking change but, existing behavior looks strange:
If I understand correctly, the same behavior already implemented in EnumerableSerializer even property is defined as IEnumerable (which can't be writable by definition) require ICollection implementation which is used to bypath actual property type. And deleted test just demonstrate this behavior. Actually, all I want is just to have the ability to define an immutable interface without nullable collections, because null and empty collections are the same especially in the case of protobuf encoding, but with a second much easy to live. |
For some reason, I can guess some functionality around merging buffers? The current implementation tries to fill provided default property value even its default value is a read-only collection ignoring property setter existence. And you are right best solution will be to recreate the whole collection as it's done in ImmutableXXX implementations but in this case, we will have even more breaking changes (deleted test will definitely fail). |
Indeed, if the enumerable ones already work that way, it makes it less
jarring... I need to think on the implications of various options here
…On Sun, 8 Aug 2021, 20:31 AlexMihalev, ***@***.***> wrote:
For some reason, I can guess some functionality around merging buffers?
The current implementation tries to fill provided default property value
even its default value is a read-only collection ignoring property setter
existence. And you are right best solution will be to recreate the whole
collection as it's done in ImmutableXXX implementations but in this case,
we will have even more breaking changes (deleted test will definitely fail).
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#822 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAEHMHSJYKGLQ6AAW3ZM4TT33LRZANCNFSM5BYU6AYA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email>
.
|
Any update on this? |
I steel think that ability to support data model with read-only properties can be very valuable especially keeping in mind the latest C# features like records and nullability checks, for example:
And I understand that the proposed solution will effectively break backward compatibility in some, I think, questionable cases (you can see deleted test), so I will not be upset at all if you reject this pull request.