Skip to content
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

Add support for Protobuf RepeatedField collections #31

Open
leus opened this issue Apr 27, 2023 · 4 comments
Open

Add support for Protobuf RepeatedField collections #31

leus opened this issue Apr 27, 2023 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@leus
Copy link

leus commented Apr 27, 2023

Protobuf generated entities seem to work well with BuilderGenerator but collections don't get generated. Protobuf collections are of type RepeatedField which are read-only properties that implement IEnumerable.

@leus
Copy link
Author

leus commented Apr 27, 2023

Looking into the code, one could argue that it's worth adding support for read-only collections leveraging something like Add() or AddRange() in the implementation template.

@MelGrubb
Copy link
Owner

MelGrubb commented May 2, 2023

Hmm. The trouble with IEnumerable is that it doesn't have Add or AddRange. You need ICollection to get those. I took a quick glance, though, and it looks like it inherits from IList, which would have those. The more general problem is knowing exactly which type of collection to generate. I'll need to think about that.

@leus
Copy link
Author

leus commented May 2, 2023

Yeah, I think you are right supporting IEnumerable is tricky (enumerator functions, backed fields, etc.) but ICollection shouldn't be hard (just use AddRange and forget about it).

@MelGrubb
Copy link
Owner

MelGrubb commented May 3, 2023

Expanding collection support is on my list, but I'm not sure when it'll get done. I think it will require more reflection than what the code is doing now. It will need to be intelligent about whether to just clear the collection or to replace it completely, depending on the properties of the collection itself. What if the class has a settable collection and it's empty. If you've told the builder to put something in the collection, it will have to be smart enough to set it to an appropriate type and then fill it. I like that the library is useful to others, and I'm starting to suspect that it's going to grow into a much larger project than it is. As such, I'm trying to tackle some optimizations first before moving forward. I'll keep this here so that I don't lose track, though.

@MelGrubb MelGrubb self-assigned this Jun 25, 2023
@MelGrubb MelGrubb added the enhancement New feature or request label Jun 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants