Merged
Conversation
iluvadev
approved these changes
Jan 13, 2023
Owner
iluvadev
left a comment
There was a problem hiding this comment.
Thanks again! Good aportation
- private setters in the lists was an "improvement" to protect the object list, but i was too optimistic and rushed to push it without testing enough. Of course, private getters/setters can not be serialized/deserialized without forcing. Sorry!
- The other changes are good. Let me explain what i was thinking when i coded that:
- There are two functions Remove and Add, that had something like:
public T? Add(T? element)
{
// The function Add logic
}
object? IBasicList.Add(object? element)
=> null; // Why??The function object? IBasicList.Add(object? element) is as private (yes, "as private"):
- The function is not visible outside the object itself: it could do nothing... what i did 👎🏼
- But the object implements
IBasicList- The function is visible when the object is used as
IBasicList
- The function is visible when the object is used as
In principle the object should not be used as the generic interface... But... why? And... the code is suspicious, unclear, unpredictable, and ultimately a potential source of bugs
Good aportation. Thanks a lot. 🥇
I will review the code like this to fix it
Owner
|
I changed bool IBasicList.Contains(object? element)
=> false;To bool IBasicList.Contains(object? element)
=> element is T item && Contains(item);Thanks @mtaku3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi, when I was using ORM for my project, I found out that list of relation and enum isn't working.
Specifically, CollectionList and EnumList.
There are two reasons that it is not working.
CollectionList and EnumList are readonly(setter is private, not public) in auto-generated code. JsonSerializer skips these properties. To include, we need to add
[JsonInclude]attribute to property explicitly.object? IBasicList.Add(object? element)Looks like setter of these properties calls
Set=>UpdateWith=>AddBut FieldBasicList class doesn't have implementation of
object? IBasicList.Add(object? element). (returning null)I added implementation using FieldBasicList.Add. So that element will be added to the inner list properly.
(I added implementation of
object? IBasicList.Remove(object? element)as well because I think it is necessary.)Also, current implementation of
in FieldBasicList class maybe wrong?
I don't fully understand the code so maybe some part are wrong. Sorry for that.