Skip to content

Conversation

@osa1
Copy link
Member

@osa1 osa1 commented Oct 29, 2025

PbList and PbMap can't be constructed by the users properly, because the
constructor arguments are private:

  • PbList element check function
  • PbMap key and value field type arguments

Internally we had just one PbMap constructor call (with random field type
arguments) which we replaced with {}, and a few PbList constructor calls
(without a check function) which we replaced with [].

To prevent confusion and incorrect uses of these types, hide the constructors.

Some of the PbList element validation tests are removed: they would need to
be moved to protoc_plugin/test as we no longer have access to PbList
constructors (but we can get PbLists from messages), but the tests are also
duplicates of the tests in protoc_plugin/test/validate_fail_test.dart. So
removed them instead.

@github-actions
Copy link

github-actions bot commented Oct 29, 2025

Package publishing

Package Version Status Publish tag (post-merge)
package:protobuf 6.0.0 ready to publish protobuf-v6.0.0
package:protoc_plugin 24.0.0 ready to publish protoc_plugin-v24.0.0

Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

returnsNormally,
reason: 'could not add min Int64 to a PbList',
);
});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed because we no longer have access to PbList. We could test these using generated messages (by moving the test to protoc_plugin/test), but we already test the same things in https://github.com/google/protobuf.dart/blob/master/protoc_plugin/test/validate_fail_test.dart so these are also redundant.

@osa1
Copy link
Member Author

osa1 commented Oct 30, 2025

(Waiting to test this internally after cl/825440440)

@osa1 osa1 changed the title Hide PbList and PbMap constructors, remove createRepeated Hide PbList and PbMap constructors Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants