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.
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
Map incoming and outgoing requests #3314
Map incoming and outgoing requests #3314
Changes from 7 commits
433471a
b7a547a
084f781
2e1f8a5
bd04d21
6177945
d97230d
08f9b94
494d4d1
8f00557
ee81379
4558556
08a1cda
22c61a6
caeaf22
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to "execute" the update? I mean, is
ToList()
required? And if we want to actually do the change, is it worth to have the interface less generic? I don't like patterns where we put everythingIEnumerable
to then lways cast down to concrete list/array, that's just causing trouble.Comment applies to most impl in this class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would love to do that this way, but the object contract is public, and the only thing I can do without changing it, is making this work in a terrible side-effectful way.
The select here will work just fine, ToList forces enumeration, but I changed it to use tolist and foreach in all places to make it more obvious that we do something that has side effects.
We don't cast down to anything here, I don't see where this would fail. Care to give an example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When saying "casting down", I meant that I have often see codebases where you have something like:
So at the end we keep creating list while we already have one at first.
Maybe an explicit
foreach
gives a better clarity on "side-effect"?Not sure to get it, you are adding the
IPathConverter
interface in this PR, so you could tweak it the way you want. Am I missing something?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is "casting" up imho, IEnumerable is higher in the inheritance tree than List. But yeah, what you show is stupid design that is trying to be overly generic, and uses IEnumerable without using the lazy nature of it. I am not trying to do that here, I just use the types that are incoming in the request so I can go from
var serialized = Serializer.Serialize(dto)
tovar serialized = Serializer.Serialize(_pathConverter.Update(dto))
.As for the side-effects, I am updating dtos that have a non-default constructor and non-settable properties, so I can't just create a new one with the updated data. I would love that, but instead I am forced to use side-effects to change the values in the incoming data (in most cases). Without that I would have to change the public api of those dtos, so they allow me to recreate them.