microsoft / microsoft/typespec

[Bug]: Protobuf emitter creates duplicate nested messages when `withVisibilityFilter` is used

Open
#6,280 0 comments 0 reactions 0 assignees View on GitHub
bug emitter:protobuf triaged:core
Dominant language
Java
Stars
5.9k
Forks
394
Avg merge
1d 23h
Merged PRs (30d)
104

Description

### Describe the bug

Every time `withVisibilityFilter` is used Protobuf generates new messages for the nested messages, instead of reusing the existing ones.

There is also a separate issue here where different visibilities should actually generate several nested messages which would have correct visibility fields, but in those cases the messages should have a different name to differentiate them.

### Reproduction

In the provided example I would expect 3 variations of `Foo` message to be created - `Foo`, `FooCreate` and `FooUpdate`. Instead, 4 messages are created, all named `Foo`.

https://typespec.io/playground/?c=aW1wb3J0ICJAdHlwZXNwZWMvcHJvdG9idWYiOwoKdXNpbmcgVHlwZVNwZWMuUMcbOwoKQHBhY2thZ2UKbmFtZXNwYWNlIE1haW47Cgptb2RlbCBGb28gewogIEBmaWVsZCgxKSBAdmlzaWJpbGl0eShMaWZlY3ljbGUuQ3JlYXRlKSBhOiBzdHJpbmc7yjUy2DVVcGTFNWLKNX0KCkB3aXRoVskwRmlsdGVyKCN7IGFueTogI1vQdV0gfSnnAK5CYXIx7wCvZm9vOuQAxt9b31vFWzLfW99b7gD2zlsz21s%3D&e=%40typespec%2Fprotobuf&options=%7B%7D

### Checklist

- [x] Follow our [Code of Conduct](https://github.com/microsoft/typespec/blob/main/CODE_OF_CONDUCT.md)
- [x] Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
- [x] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/Microsoft/typespec/discussions).
- [x] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.