-
Notifications
You must be signed in to change notification settings - Fork 183
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
Auto add builder factories for nested built_collection classes #1254
Comments
I added the following code for auto-generation. Is it correct to use it like this?
|
Yes, it's necessary to add builder factories manually in some cases. It's true that you could add fields as in your second post so the builder factories get generated for you, but then you will end up with a very weird class :) ... maybe you could put all such fields in a single class that you don't use, as a more convenient way to add builder factories. Sorry that this part of |
I was considering using built_value for a project, but this is a big deal to me. The amount of boilerplate can be huge and hard to write. |
@pierremrtn I understand that concern. For a current project (which internally uses For the case where we now want to deal with e.g. extension on SerializersBuilder {
/* Adds support for values of type `BuiltMap<Key, BuiltList<Value>>` */
void addMapOfList<Key, Value>() {
addBuilderFactory(
FullType(BuiltMap, [
FullType(Key),
FullType(
BuiltList,
[FullType(Value)],
)
]),
() => new MapBuilder<Key, BuiltList<Value>>(),
);
addBuilderFactory(
FullType(BuiltList, [FullType(Value)]),
() => new ListBuilder<Value>(),
);
}
} With that we only have to call Maybe this helps anyone else to work around this problem quickly until it's supported via code generation. |
When using BuiltMap nesting, is it not automatically created?
automatically generated below
however, the below needs to be added manually.
It won't work unless you add it manually in the code above. So you have to add it manually, but it works.
Is there a way to automatically generate it?
The text was updated successfully, but these errors were encountered: