├── .github ├── codecov.yml ├── dependabot.yml └── workflows │ ├── ci.yml │ └── release.yml ├── .gitignore ├── .gitmodules ├── CHANGELOG.md ├── Cargo.lock ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md ├── README.tpl ├── generate-readme.ps1 ├── prost-reflect-build ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT └── src │ ├── lib.rs │ └── test.proto ├── prost-reflect-conformance-tests ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── build.rs ├── failure_list.txt ├── src │ ├── lib.rs │ └── main.rs ├── tests │ └── conformance.rs └── text_format_failure_list.txt ├── prost-reflect-derive ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── src │ └── lib.rs └── tests │ ├── attr_unknown_field.rs │ ├── attr_unknown_field.stderr │ ├── basic.rs │ ├── enum.stderr │ ├── file_descriptor_set.bin │ ├── file_descriptor_set.rs │ ├── ignore_enum.rs │ ├── missing_attr.rs │ ├── missing_attr.stderr │ ├── missing_name.rs │ ├── missing_name.stderr │ ├── multiple_attr.rs │ └── tests.rs ├── prost-reflect-tests ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── benches │ └── decode.rs ├── build.rs ├── proptest-regressions │ ├── json.txt │ ├── lib.txt │ └── text_format.txt └── src │ ├── arbitrary.rs │ ├── decode.rs │ ├── desc.proto │ ├── desc.rs │ ├── desc2.proto │ ├── desc_no_package.proto │ ├── ext.proto │ ├── imports.proto │ ├── json.rs │ ├── lib.rs │ ├── options.proto │ ├── test.proto │ ├── test2.proto │ └── text_format.rs ├── prost-reflect ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── doc │ ├── decoding.md │ ├── file_descriptor_set.bin │ ├── intro.md │ ├── json.md │ └── reflect.md ├── proptest-regressions │ └── dynamic │ │ └── serde │ │ └── case.txt ├── src │ ├── descriptor │ │ ├── api.rs │ │ ├── build │ │ │ ├── mod.rs │ │ │ ├── names.rs │ │ │ ├── options.rs │ │ │ ├── resolve.rs │ │ │ └── visit.rs │ │ ├── error.rs │ │ ├── global.rs │ │ ├── mod.rs │ │ ├── tag.rs │ │ ├── tests.rs │ │ └── types.rs │ ├── doctest.proto │ ├── dynamic │ │ ├── fields.rs │ │ ├── message.rs │ │ ├── mod.rs │ │ ├── serde │ │ │ ├── case.rs │ │ │ ├── de │ │ │ │ ├── kind.rs │ │ │ │ ├── mod.rs │ │ │ │ └── wkt.rs │ │ │ ├── mod.rs │ │ │ └── ser │ │ │ │ ├── mod.rs │ │ │ │ └── wkt.rs │ │ ├── text_format │ │ │ ├── format.rs │ │ │ ├── mod.rs │ │ │ └── parse │ │ │ │ ├── error.rs │ │ │ │ ├── lex.rs │ │ │ │ └── mod.rs │ │ └── unknown.rs │ ├── file_descriptor_set.bin │ ├── lib.rs │ └── reflect │ │ ├── mod.rs │ │ └── wkt.rs └── tests │ ├── data │ ├── dependency_not_imported.yml │ ├── dependency_resolution_transitive.yml │ ├── dependency_resolution_transitive2.yml │ ├── dependency_resolution_transitive3.yml │ ├── enum_default1.yml │ ├── enum_default2.yml │ ├── enum_default3.yml │ ├── enum_duplicate_number1.yml │ ├── enum_duplicate_number2.yml │ ├── enum_duplicate_number3.yml │ ├── enum_field_invalid_default1.yml │ ├── enum_field_invalid_default2.yml │ ├── enum_field_invalid_default3.yml │ ├── enum_field_invalid_default4.yml │ ├── enum_field_invalid_default5.yml │ ├── enum_field_invalid_default6.yml │ ├── enum_field_invalid_default7.yml │ ├── enum_field_invalid_default8.yml │ ├── enum_field_invalid_default9.yml │ ├── enum_reserved_range_overlap_with_value1.yml │ ├── enum_reserved_range_overlap_with_value2.yml │ ├── enum_reserved_range_overlap_with_value3.yml │ ├── extend_field_number_not_in_extensions1.yml │ ├── extend_field_number_not_in_extensions2.yml │ ├── extend_group_field.yml │ ├── field_default_invalid_type1.yml │ ├── field_default_invalid_type2.yml │ ├── field_default_invalid_type3.yml │ ├── field_default_value1.yml │ ├── field_default_value2.yml │ ├── field_set_json_name.yml │ ├── generate_group_message_name_conflict.yml │ ├── generate_map_entry_message_name_conflict.yml │ ├── generate_synthetic_oneof_name_conflict.yml │ ├── invalid_message_number1.yml │ ├── invalid_message_number2.yml │ ├── invalid_service_type1.yml │ ├── invalid_service_type2.yml │ ├── invalid_service_type3.yml │ ├── message_field_duplicate_number1.yml │ ├── message_field_duplicate_number2.yml │ ├── message_reserved_range_message_set1.yml │ ├── message_reserved_range_message_set2.yml │ ├── message_reserved_range_overlap_with_field1.yml │ ├── message_reserved_range_overlap_with_field2.yml │ ├── name_collision1.yml │ ├── name_collision2.yml │ ├── name_collision3.yml │ ├── name_collision4.yml │ ├── name_collision5.yml │ ├── name_conflict1.yml │ ├── name_conflict2.yml │ ├── name_conflict3.yml │ ├── name_conflict_field_camel_case1.yml │ ├── name_conflict_field_camel_case2.yml │ ├── name_conflict_field_camel_case3.yml │ ├── name_conflict_in_imported_files.yml │ ├── name_conflict_package1.yml │ ├── name_conflict_package2.yml │ ├── name_conflict_package3.yml │ ├── name_conflict_with_import.yml │ ├── name_resolution1.yml │ ├── name_resolution2.yml │ ├── name_resolution3.yml │ ├── name_resolution4.yml │ ├── name_resolution5.yml │ ├── name_resolution6.yml │ ├── oneof_group_field.yml │ ├── option_already_set.yml │ ├── option_extension_dependency_not_imported.yml │ ├── option_extension_dependency_transitive.yml │ ├── option_extension_invalid_type.yml │ ├── option_extension_wrong_extendee.yml │ ├── option_map_entry_set_explicitly.yml │ ├── option_resolution1.yml │ ├── option_resolution10.yml │ ├── option_resolution11.yml │ ├── option_resolution12.yml │ ├── option_resolution13.yml │ ├── option_resolution14.yml │ ├── option_resolution15.yml │ ├── option_resolution16.yml │ ├── option_resolution17.yml │ ├── option_resolution18.yml │ ├── option_resolution19.yml │ ├── option_resolution2.yml │ ├── option_resolution20.yml │ ├── option_resolution21.yml │ ├── option_resolution22.yml │ ├── option_resolution23.yml │ ├── option_resolution24.yml │ ├── option_resolution3.yml │ ├── option_resolution4.yml │ ├── option_resolution5.yml │ ├── option_resolution6.yml │ ├── option_resolution7.yml │ ├── option_resolution8.yml │ ├── option_resolution9.yml │ ├── option_unknown_extension.yml │ └── option_unknown_field.yml │ ├── main.rs │ └── snapshots │ ├── main__dependency_not_imported.snap │ ├── main__dependency_resolution_transitive.snap │ ├── main__dependency_resolution_transitive2.snap │ ├── main__dependency_resolution_transitive3.snap │ ├── main__enum_default1.snap │ ├── main__enum_default2.snap │ ├── main__enum_default3.snap │ ├── main__enum_duplicate_number1.snap │ ├── main__enum_duplicate_number2.snap │ ├── main__enum_duplicate_number3.snap │ ├── main__enum_field_invalid_default1.snap │ ├── main__enum_field_invalid_default2.snap │ ├── main__enum_field_invalid_default3.snap │ ├── main__enum_field_invalid_default4.snap │ ├── main__enum_field_invalid_default5.snap │ ├── main__enum_field_invalid_default6.snap │ ├── main__enum_field_invalid_default7.snap │ ├── main__enum_field_invalid_default8.snap │ ├── main__enum_field_invalid_default9.snap │ ├── main__enum_reserved_range_overlap_with_value1.snap │ ├── main__enum_reserved_range_overlap_with_value2.snap │ ├── main__enum_reserved_range_overlap_with_value3.snap │ ├── main__extend_field_number_not_in_extensions1.snap │ ├── main__extend_field_number_not_in_extensions2.snap │ ├── main__extend_group_field.snap │ ├── main__field_default_invalid_type1.snap │ ├── main__field_default_invalid_type2.snap │ ├── main__field_default_invalid_type3.snap │ ├── main__field_default_value1.snap │ ├── main__field_default_value2.snap │ ├── main__field_set_json_name.snap │ ├── main__generate_group_message_name_conflict.snap │ ├── main__generate_map_entry_message_name_conflict.snap │ ├── main__generate_synthetic_oneof_name_conflict.snap │ ├── main__invalid_message_number1.snap │ ├── main__invalid_message_number2.snap │ ├── main__invalid_service_type1.snap │ ├── main__invalid_service_type2.snap │ ├── main__invalid_service_type3.snap │ ├── main__message_field_duplicate_number1.snap │ ├── main__message_field_duplicate_number2.snap │ ├── main__message_reserved_range_message_set1.snap │ ├── main__message_reserved_range_message_set2.snap │ ├── main__message_reserved_range_overlap_with_field1.snap │ ├── main__message_reserved_range_overlap_with_field2.snap │ ├── main__name_collision1.snap │ ├── main__name_collision2.snap │ ├── main__name_collision3.snap │ ├── main__name_collision4.snap │ ├── main__name_collision5.snap │ ├── main__name_conflict1.snap │ ├── main__name_conflict2.snap │ ├── main__name_conflict3.snap │ ├── main__name_conflict_field_camel_case1.snap │ ├── main__name_conflict_field_camel_case2.snap │ ├── main__name_conflict_field_camel_case3.snap │ ├── main__name_conflict_in_imported_files.snap │ ├── main__name_conflict_package1.snap │ ├── main__name_conflict_package2.snap │ ├── main__name_conflict_package3.snap │ ├── main__name_conflict_with_import.snap │ ├── main__name_resolution1.snap │ ├── main__name_resolution2.snap │ ├── main__name_resolution3.snap │ ├── main__name_resolution4.snap │ ├── main__name_resolution5.snap │ ├── main__name_resolution6.snap │ ├── main__oneof_group_field.snap │ ├── main__option_already_set.snap │ ├── main__option_extension_dependency_not_imported.snap │ ├── main__option_extension_dependency_transitive.snap │ ├── main__option_extension_invalid_type.snap │ ├── main__option_extension_wrong_extendee.snap │ ├── main__option_map_entry_set_explicitly.snap │ ├── main__option_resolution1.snap │ ├── main__option_resolution10.snap │ ├── main__option_resolution11.snap │ ├── main__option_resolution12.snap │ ├── main__option_resolution13.snap │ ├── main__option_resolution14.snap │ ├── main__option_resolution15.snap │ ├── main__option_resolution16.snap │ ├── main__option_resolution17.snap │ ├── main__option_resolution18.snap │ ├── main__option_resolution19.snap │ ├── main__option_resolution2.snap │ ├── main__option_resolution20.snap │ ├── main__option_resolution21.snap │ ├── main__option_resolution22.snap │ ├── main__option_resolution23.snap │ ├── main__option_resolution24.snap │ ├── main__option_resolution3.snap │ ├── main__option_resolution4.snap │ ├── main__option_resolution5.snap │ ├── main__option_resolution6.snap │ ├── main__option_resolution7.snap │ ├── main__option_resolution8.snap │ ├── main__option_resolution9.snap │ ├── main__option_unknown_extension.snap │ └── main__option_unknown_field.snap ├── release-plz.toml └── rust-toolchain.toml /.github/codecov.yml: -------------------------------------------------------------------------------- 1 | codecov: 2 | require_ci_to_pass: yes 3 | 4 | coverage: 5 | precision: 2 6 | round: down 7 | range: "78...100" 8 | status: 9 | project: 10 | default: 11 | target: auto 12 | informational: true 13 | patch: 14 | default: 15 | target: auto 16 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 2 | version: 2 3 | updates: 4 | - package-ecosystem: cargo 5 | directory: / 6 | schedule: 7 | interval: weekly 8 | groups: 9 | production-dependencies: 10 | dependency-type: production 11 | development-dependencies: 12 | dependency-type: development 13 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - main 5 | pull_request: 6 | branches: 7 | - main 8 | 9 | name: Continuous integration 10 | 11 | jobs: 12 | test: 13 | name: Test Suite 14 | runs-on: ubuntu-latest 15 | strategy: 16 | matrix: 17 | rust: [beta, stable, 1.74.0] 18 | steps: 19 | - uses: actions/checkout@v2 20 | with: 21 | submodules: recursive 22 | - uses: dtolnay/rust-toolchain@v1 23 | with: 24 | toolchain: ${{ matrix.rust }} 25 | # Skip cargo update for MSRV validation build 26 | - run: cargo update 27 | if: ${{ matrix.rust == 'stable' || matrix.rust == 'beta' }} 28 | - name: Get latest CMake and ninja 29 | uses: lukka/get-cmake@latest 30 | - name: Install Protoc 31 | uses: arduino/setup-protoc@v1 32 | with: 33 | repo-token: ${{ secrets.GITHUB_TOKEN }} 34 | - run: cargo test --all-features 35 | 36 | lints: 37 | name: Lints 38 | runs-on: ubuntu-latest 39 | steps: 40 | - uses: actions/checkout@v2 41 | with: 42 | submodules: recursive 43 | - uses: dtolnay/rust-toolchain@v1 44 | with: 45 | toolchain: stable 46 | components: clippy, rustfmt 47 | - name: Get latest CMake and ninja 48 | uses: lukka/get-cmake@latest 49 | - name: Install Protoc 50 | uses: arduino/setup-protoc@v1 51 | with: 52 | repo-token: ${{ secrets.GITHUB_TOKEN }} 53 | - run: cargo fmt --all -- --check 54 | - run: cargo clippy --all -- -D warnings 55 | - run: cargo check 56 | - run: cargo check --package prost-reflect --no-default-features 57 | - run: cargo check --package prost-reflect --no-default-features --features=text-format 58 | - run: cargo check --package prost-reflect --no-default-features --features=serde 59 | - run: cargo check --package prost-reflect --all-features 60 | - name: Check README.md is up-to-date 61 | shell: pwsh 62 | run: | 63 | ./generate-readme.ps1 64 | if (git diff README.md) { 65 | Write-Error "README.md is out-of-date, run generate-readme.ps1 to regenerate it." -ErrorAction Stop 66 | } 67 | 68 | coverage: 69 | name: Coverage 70 | runs-on: ubuntu-latest 71 | container: 72 | image: xd009642/tarpaulin:develop 73 | options: --security-opt seccomp=unconfined 74 | steps: 75 | - uses: actions/checkout@v2 76 | with: 77 | submodules: recursive 78 | - name: Install Protoc 79 | uses: arduino/setup-protoc@v1 80 | with: 81 | repo-token: ${{ secrets.GITHUB_TOKEN }} 82 | - name: Generate code coverage 83 | run: | 84 | cargo tarpaulin --verbose --packages prost-reflect prost-reflect-tests --all-features --timeout 120 --out xml 85 | - name: Upload to codecov.io 86 | uses: codecov/codecov-action@v4 87 | with: 88 | fail_ci_if_error: true 89 | token: ${{ secrets.CODECOV_TOKEN }} 90 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release-plz 2 | 3 | permissions: 4 | pull-requests: write 5 | contents: write 6 | 7 | on: 8 | push: 9 | branches: 10 | - main 11 | 12 | jobs: 13 | 14 | # Release unpublished packages. 15 | release-plz-release: 16 | name: Release-plz release 17 | runs-on: ubuntu-latest 18 | permissions: 19 | contents: write 20 | steps: 21 | - name: Checkout repository 22 | uses: actions/checkout@v4 23 | with: 24 | fetch-depth: 0 25 | - name: Install Rust toolchain 26 | uses: dtolnay/rust-toolchain@stable 27 | - name: Run release-plz 28 | uses: release-plz/action@v0.5 29 | with: 30 | command: release 31 | env: 32 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 33 | CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} 34 | 35 | # Create a PR with the new versions and changelog, preparing the next release. 36 | release-plz-pr: 37 | name: Release-plz PR 38 | runs-on: ubuntu-latest 39 | permissions: 40 | contents: write 41 | pull-requests: write 42 | concurrency: 43 | group: release-plz-${{ github.ref }} 44 | cancel-in-progress: false 45 | steps: 46 | - name: Checkout repository 47 | uses: actions/checkout@v4 48 | with: 49 | fetch-depth: 0 50 | - name: Install Rust toolchain 51 | uses: dtolnay/rust-toolchain@stable 52 | - name: Run release-plz 53 | uses: release-plz/action@v0.5 54 | with: 55 | command: release-pr 56 | env: 57 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 58 | CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} 59 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | **/*.rs.bk 3 | .cargo-ok 4 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "prost-reflect-conformance-tests/protobuf"] 2 | path = prost-reflect-conformance-tests/protobuf 3 | url = https://github.com/protocolbuffers/protobuf 4 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | resolver = "2" 3 | members = [ 4 | "prost-reflect", 5 | "prost-reflect-build", 6 | "prost-reflect-derive", 7 | "prost-reflect-tests", 8 | "prost-reflect-conformance-tests" 9 | ] 10 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any 2 | person obtaining a copy of this software and associated 3 | documentation files (the "Software"), to deal in the 4 | Software without restriction, including without 5 | limitation the rights to use, copy, modify, merge, 6 | publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software 8 | is furnished to do so, subject to the following 9 | conditions: 10 | 11 | The above copyright notice and this permission notice 12 | shall be included in all copies or substantial portions 13 | of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 16 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 17 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 19 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 22 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /README.tpl: -------------------------------------------------------------------------------- 1 | [![crates.io](https://img.shields.io/crates/v/prost-reflect.svg)](https://crates.io/crates/prost-reflect/) 2 | [![docs.rs](https://docs.rs/prost-reflect/badge.svg)](https://docs.rs/prost-reflect/) 3 | [![deps.rs](https://deps.rs/crate/prost-reflect/latest/status.svg)](https://deps.rs/crate/prost-reflect) 4 | ![MSRV](https://img.shields.io/badge/rustc-1.74+-blue.svg) 5 | [![Continuous integration](https://github.com/andrewhickman/prost-reflect/actions/workflows/ci.yml/badge.svg)](https://github.com/andrewhickman/prost-reflect/actions/workflows/ci.yml) 6 | [![codecov.io](https://codecov.io/gh/andrewhickman/prost-reflect/branch/main/graph/badge.svg?token=E2OITYXO7M)](https://codecov.io/gh/andrewhickman/prost-reflect) 7 | ![Apache 2.0 OR MIT licensed](https://img.shields.io/badge/license-Apache2.0%2FMIT-blue.svg) 8 | 9 | # prost-reflect 10 | 11 | A protobuf library extending [`prost`](https://crates.io/crates/prost) with reflection support and dynamic messages. 12 | 13 | ## Usage 14 | 15 | {{intro}} 16 | 17 | ### Example - decoding 18 | 19 | {{decoding}} 20 | 21 | ### Example - JSON mapping 22 | 23 | {{json}} 24 | 25 | ### Example - implementing `ReflectMessage` 26 | 27 | {{reflect}} 28 | 29 | ## Minimum Supported Rust Version 30 | 31 | Rust **1.74** or higher. 32 | 33 | The minimum supported Rust version may be changed in the future, but it will be 34 | done with a minor version bump. 35 | 36 | ## License 37 | 38 | Licensed under either of 39 | 40 | * Apache License, Version 2.0 41 | ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) 42 | * MIT license 43 | ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) 44 | 45 | at your option. 46 | 47 | ## Contribution 48 | 49 | Unless you explicitly state otherwise, any contribution intentionally submitted 50 | for inclusion in the work by you, as defined in the Apache-2.0 license, shall be 51 | dual licensed as above, without any additional terms or conditions. 52 | 53 | [`DescriptorPool`]: https://docs.rs/prost-reflect/latest/prost_reflect/struct.DescriptorPool.html 54 | [`DynamicMessage`]: https://docs.rs/prost-reflect/latest/prost_reflect/struct.DynamicMessage.html 55 | [`MessageDescriptor`]: https://docs.rs/prost-reflect/latest/prost_reflect/struct.MessageDescriptor.html 56 | [`MessageDescriptor`]: https://docs.rs/prost-reflect/latest/prost_reflect/struct.MessageDescriptor.html 57 | [`DynamicMessage::decode`]: https://docs.rs/prost-reflect/latest/prost_reflect/struct.DynamicMessage.html#method.decode 58 | [`ReflectMessage`]: https://docs.rs/prost-reflect/latest/prost_reflect/trait.ReflectMessage.html 59 | 60 | [`Default`]: https://doc.rust-lang.org/stable/core/default/trait.Default.html 61 | [prost::Message]: https://docs.rs/prost/latest/prost/trait.Message.html 62 | [prost_types::FileDescriptorSet]: https://docs.rs/prost-types/latest/prost_types/struct.FileDescriptorSet.html -------------------------------------------------------------------------------- /generate-readme.ps1: -------------------------------------------------------------------------------- 1 | $ErrorActionPreference = "Stop" 2 | 3 | Push-Location $PSScriptRoot 4 | try { 5 | (Get-Content "README.tpl" -Raw) ` 6 | -replace "{{intro}}", (Get-Content "prost-reflect/doc/intro.md" -Raw) ` 7 | -replace "{{decoding}}", (Get-Content "prost-reflect/doc/decoding.md" -Raw) ` 8 | -replace "{{json}}", (Get-Content "prost-reflect/doc/json.md" -Raw) ` 9 | -replace "{{reflect}}", (Get-Content "prost-reflect/doc/reflect.md" -Raw) ` 10 | | Set-Content "README.md" 11 | } 12 | finally { Pop-Location } -------------------------------------------------------------------------------- /prost-reflect-build/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "prost-reflect-build" 3 | description = "A utility function for use with prost-build and prost-reflect to generate ReflectMessage implementations" 4 | keywords = ["protobuf", "serialization", "json"] 5 | categories = ["encoding"] 6 | version = "0.15.2" 7 | authors = ["Andrew Hickman "] 8 | repository = "https://github.com/andrewhickman/prost-reflect" 9 | documentation = "https://docs.rs/prost-reflect-build" 10 | license = "MIT OR Apache-2.0" 11 | readme = "../README.md" 12 | edition = "2021" 13 | rust-version = "1.74.0" 14 | 15 | [features] 16 | default = [] 17 | 18 | [dependencies] 19 | prost-reflect = { path = "../prost-reflect", version = "0.15.3", features = [ 20 | "derive" 21 | ] } 22 | prost-build = "0.13.0" 23 | -------------------------------------------------------------------------------- /prost-reflect-build/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | ../LICENSE-APACHE -------------------------------------------------------------------------------- /prost-reflect-build/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | ../LICENSE-MIT -------------------------------------------------------------------------------- /prost-reflect-build/src/test.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package my.test; 4 | 5 | message TestMessage { 6 | int32 int32_value = 1; 7 | message NestedMessage { 8 | int64 int64_value = 1; 9 | } 10 | 11 | NestedMessage nested_message = 2; 12 | AnotherMessage another_message = 3; 13 | } 14 | 15 | message AnotherMessage { 16 | string string_value = 1; 17 | } -------------------------------------------------------------------------------- /prost-reflect-conformance-tests/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "prost-reflect-conformance-tests" 3 | description = "Protobuf test runner for prost-reflect." 4 | version = "0.0.0" 5 | authors = ["Andrew Hickman "] 6 | license = "MIT OR Apache-2.0" 7 | edition = "2021" 8 | publish = false 9 | build = "build.rs" 10 | 11 | [[bin]] 12 | name = "prost-reflect-conformance-tests" 13 | test = false 14 | doctest = false 15 | 16 | [lib] 17 | test = false 18 | doctest = false 19 | 20 | [dependencies] 21 | prost = "0.13.0" 22 | prost-types = "0.13.0" 23 | prost-reflect = { path = "../prost-reflect", features = ["serde", "text-format"] } 24 | env_logger = "0.10.0" 25 | serde_json = { version = "1.0.106", features = ["float_roundtrip"] } 26 | serde = "1.0.190" 27 | once_cell = "1.9.0" 28 | 29 | [dev-dependencies] 30 | 31 | [build-dependencies] 32 | cmake = "0.1.54" 33 | anyhow = "1.0.97" 34 | prost-build = "0.13.0" 35 | tempfile = "3.19.1" 36 | -------------------------------------------------------------------------------- /prost-reflect-conformance-tests/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | ../LICENSE-APACHE -------------------------------------------------------------------------------- /prost-reflect-conformance-tests/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | ../LICENSE-MIT -------------------------------------------------------------------------------- /prost-reflect-conformance-tests/build.rs: -------------------------------------------------------------------------------- 1 | // This build script is based on the script here: https://github.com/tokio-rs/prost/blob/master/protobuf/build.rs 2 | 3 | use std::env; 4 | use std::fs; 5 | use std::path::{Path, PathBuf}; 6 | use std::process::Command; 7 | 8 | use anyhow::{Context, Result}; 9 | 10 | fn main() -> Result<()> { 11 | let out_dir = 12 | &PathBuf::from(env::var("OUT_DIR").expect("OUT_DIR environment variable not set")); 13 | 14 | let src_dir = PathBuf::from("protobuf"); 15 | if !src_dir.join("cmake").exists() { 16 | anyhow::bail!( 17 | "protobuf sources are not checked out; Try `git submodule update --init --recursive`" 18 | ) 19 | } 20 | 21 | let version = git_describe(&src_dir)?; 22 | let protobuf_dir = &out_dir.join(format!("protobuf-{}", version)); 23 | 24 | if !protobuf_dir.exists() { 25 | let build_dir = &out_dir.join(format!("build-protobuf-{}", version)); 26 | fs::create_dir_all(build_dir).expect("failed to create build directory"); 27 | 28 | let tempdir = tempfile::Builder::new() 29 | .prefix("protobuf") 30 | .tempdir_in(out_dir) 31 | .expect("failed to create temporary directory"); 32 | 33 | let prefix_dir = &tempdir.path().join("prefix"); 34 | fs::create_dir(prefix_dir).expect("failed to create prefix directory"); 35 | install_protoc_and_conformance_test_runner(&src_dir, build_dir, prefix_dir)?; 36 | fs::rename(prefix_dir, protobuf_dir).context("failed to move protobuf dir")?; 37 | } 38 | 39 | let protoc_executable = protobuf_dir.join("bin").join("protoc"); 40 | 41 | let conformance_proto_dir = src_dir.join("conformance"); 42 | prost_build::Config::new() 43 | .protoc_executable(&protoc_executable) 44 | .compile_protos( 45 | &[conformance_proto_dir.join("conformance.proto")], 46 | &[conformance_proto_dir], 47 | ) 48 | .unwrap(); 49 | 50 | let proto_dir = src_dir.join("src"); 51 | 52 | // Generate BTreeMap fields for all messages. This forces encoded output to be consistent, so 53 | // that encode/decode roundtrips can use encoded output for comparison. Otherwise trying to 54 | // compare based on the Rust PartialEq implementations is difficult, due to presence of NaN 55 | // values. 56 | prost_build::Config::new() 57 | .protoc_executable(&protoc_executable) 58 | .btree_map(["."]) 59 | .file_descriptor_set_path(out_dir.join("test_messages.bin")) 60 | .compile_protos( 61 | &[ 62 | proto_dir.join("google/protobuf/test_messages_proto2.proto"), 63 | proto_dir.join("google/protobuf/test_messages_proto3.proto"), 64 | proto_dir.join("google/protobuf/unittest.proto"), 65 | ], 66 | &[proto_dir], 67 | ) 68 | .unwrap(); 69 | 70 | // Emit an environment variable with the path to the build so that it can be located in the 71 | // main crate. 72 | println!("cargo:rustc-env=PROTOBUF={}", protobuf_dir.display()); 73 | Ok(()) 74 | } 75 | 76 | fn git_describe(src_dir: &Path) -> Result { 77 | let output = Command::new("git") 78 | .arg("describe") 79 | .arg("--tags") 80 | .arg("--always") 81 | .current_dir(src_dir) 82 | .output() 83 | .context("Unable to describe protobuf git repo")?; 84 | if !output.status.success() { 85 | anyhow::bail!( 86 | "Unable to describe protobuf git repo: {}", 87 | String::from_utf8_lossy(&output.stderr) 88 | ); 89 | } 90 | let stdout = String::from_utf8_lossy(&output.stdout); 91 | Ok(stdout.trim().to_string()) 92 | } 93 | 94 | fn install_protoc_and_conformance_test_runner( 95 | src_dir: &Path, 96 | build_dir: &Path, 97 | prefix_dir: &Path, 98 | ) -> Result<()> { 99 | // The protobuf conformance test runner does not support Windows [1]. 100 | // [1]: https://github.com/protocolbuffers/protobuf/tree/master/conformance#portability 101 | let build_conformance = !cfg!(windows); 102 | 103 | // Build and install protoc, the protobuf libraries, and the conformance test runner. 104 | cmake::Config::new(src_dir) 105 | .define("CMAKE_CXX_STANDARD", "14") 106 | .define("ABSL_PROPAGATE_CXX_STD", "ON") 107 | .define("CMAKE_INSTALL_PREFIX", prefix_dir) 108 | .define( 109 | "protobuf_BUILD_CONFORMANCE", 110 | if build_conformance { "ON" } else { "OFF" }, 111 | ) 112 | .define("protobuf_BUILD_TESTS", "OFF") 113 | .out_dir(build_dir) 114 | .build(); 115 | 116 | if build_conformance { 117 | // Install the conformance-test-runner binary, since it isn't done automatically. 118 | fs::copy( 119 | build_dir.join("build").join("conformance_test_runner"), 120 | prefix_dir.join("bin").join("conformance-test-runner"), 121 | ) 122 | .context("failed to copy conformance-test-runner")?; 123 | } 124 | 125 | Ok(()) 126 | } 127 | -------------------------------------------------------------------------------- /prost-reflect-conformance-tests/failure_list.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andrewhickman/prost-reflect/826a3178981c2f30bb496f3a32a41f53e45003b4/prost-reflect-conformance-tests/failure_list.txt -------------------------------------------------------------------------------- /prost-reflect-conformance-tests/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod conformance { 2 | use std::path::Path; 3 | 4 | pub fn test_runner() -> &'static Path { 5 | Path::new(concat!(env!("PROTOBUF"), "/bin/conformance-test-runner")) 6 | } 7 | 8 | include!(concat!(env!("OUT_DIR"), "/conformance.rs")); 9 | } 10 | 11 | pub mod test_messages { 12 | pub mod proto2 { 13 | include!(concat!( 14 | env!("OUT_DIR"), 15 | "/protobuf_test_messages.proto2.rs" 16 | )); 17 | } 18 | pub mod proto3 { 19 | include!(concat!( 20 | env!("OUT_DIR"), 21 | "/protobuf_test_messages.proto3.rs" 22 | )); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /prost-reflect-conformance-tests/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::io::{self, Read, Write}; 2 | 3 | use once_cell::sync::Lazy; 4 | use prost::{ 5 | bytes::{Buf, BufMut}, 6 | Message, 7 | }; 8 | use prost_reflect::{text_format, DescriptorPool, DeserializeOptions, DynamicMessage}; 9 | 10 | use prost_reflect_conformance_tests::conformance::{ 11 | conformance_request, conformance_response, ConformanceRequest, ConformanceResponse, 12 | TestCategory, WireFormat, 13 | }; 14 | 15 | const TEST_MESSAGES_DESCRIPTOR_POOL_SET_BYTES: &[u8] = 16 | include_bytes!(concat!(env!("OUT_DIR"), "/test_messages.bin")); 17 | 18 | static TEST_MESSAGES_DESCRIPTOR_POOL: Lazy = 19 | Lazy::new(|| DescriptorPool::decode(TEST_MESSAGES_DESCRIPTOR_POOL_SET_BYTES).unwrap()); 20 | 21 | fn main() -> io::Result<()> { 22 | env_logger::init(); 23 | let mut bytes = vec![0; 4]; 24 | 25 | loop { 26 | bytes.resize(4, 0); 27 | 28 | if io::stdin().read_exact(&mut bytes).is_err() { 29 | // No more test cases. 30 | return Ok(()); 31 | } 32 | 33 | let len = bytes.as_slice().get_u32_le() as usize; 34 | 35 | bytes.resize(len, 0); 36 | io::stdin().read_exact(&mut bytes)?; 37 | 38 | let result = match ConformanceRequest::decode(&*bytes) { 39 | Ok(request) => handle_request(request), 40 | Err(error) => conformance_response::Result::ParseError(format!("{:?}", error)), 41 | }; 42 | 43 | let response = ConformanceResponse { 44 | result: Some(result), 45 | }; 46 | 47 | let len = response.encoded_len(); 48 | bytes.clear(); 49 | bytes.put_u32_le(len as u32); 50 | response.encode(&mut bytes)?; 51 | assert_eq!(len + 4, bytes.len()); 52 | 53 | let mut stdout = io::stdout(); 54 | stdout.lock().write_all(&bytes)?; 55 | stdout.flush()?; 56 | } 57 | } 58 | 59 | fn handle_request(request: ConformanceRequest) -> conformance_response::Result { 60 | let message_desc = 61 | match TEST_MESSAGES_DESCRIPTOR_POOL.get_message_by_name(&request.message_type) { 62 | Some(message_desc) => message_desc, 63 | None => { 64 | return conformance_response::Result::ParseError(format!( 65 | "unknown message type: {}", 66 | request.message_type 67 | )); 68 | } 69 | }; 70 | 71 | let mut json_deserialize_options = DeserializeOptions::new(); 72 | 73 | match request.test_category() { 74 | TestCategory::UnspecifiedTest => (), 75 | TestCategory::BinaryTest => (), 76 | TestCategory::JsonTest => (), 77 | TestCategory::TextFormatTest => (), 78 | TestCategory::JsonIgnoreUnknownParsingTest => { 79 | json_deserialize_options = json_deserialize_options.deny_unknown_fields(false); 80 | } 81 | TestCategory::JspbTest => { 82 | return conformance_response::Result::Skipped("unsupported test category".to_string()) 83 | } 84 | } 85 | 86 | let output = request.requested_output_format(); 87 | let dynamic_message = match request.payload { 88 | None => return conformance_response::Result::ParseError("no payload".to_string()), 89 | Some(conformance_request::Payload::ProtobufPayload(buf)) => { 90 | let mut dynamic_message = DynamicMessage::new(message_desc); 91 | match dynamic_message.merge(buf.as_ref()) { 92 | Ok(()) => (), 93 | Err(error) => return conformance_response::Result::ParseError(error.to_string()), 94 | } 95 | dynamic_message 96 | } 97 | Some(conformance_request::Payload::JsonPayload(json)) => { 98 | let mut deserializer = serde_json::de::Deserializer::from_str(&json); 99 | match DynamicMessage::deserialize_with_options( 100 | message_desc, 101 | &mut deserializer, 102 | &json_deserialize_options, 103 | ) { 104 | Ok(message) => message, 105 | Err(error) => return conformance_response::Result::ParseError(error.to_string()), 106 | } 107 | } 108 | Some(conformance_request::Payload::JspbPayload(_)) => { 109 | return conformance_response::Result::Skipped( 110 | "jspb payload is not supported".to_string(), 111 | ); 112 | } 113 | Some(conformance_request::Payload::TextPayload(text)) => { 114 | match DynamicMessage::parse_text_format(message_desc, &text) { 115 | Ok(message) => message, 116 | Err(error) => return conformance_response::Result::ParseError(error.to_string()), 117 | } 118 | } 119 | }; 120 | 121 | match output { 122 | WireFormat::Unspecified => { 123 | conformance_response::Result::ParseError("output format unspecified".to_string()) 124 | } 125 | WireFormat::Jspb => { 126 | conformance_response::Result::Skipped("JSPB output is not supported".to_string()) 127 | } 128 | WireFormat::TextFormat => { 129 | let options = text_format::FormatOptions::new() 130 | .skip_unknown_fields(!request.print_unknown_fields); 131 | conformance_response::Result::TextPayload( 132 | dynamic_message.to_text_format_with_options(&options), 133 | ) 134 | } 135 | WireFormat::Json => match serde_json::to_string(&dynamic_message) { 136 | Ok(s) => conformance_response::Result::JsonPayload(s), 137 | Err(err) => conformance_response::Result::SerializeError(err.to_string()), 138 | }, 139 | WireFormat::Protobuf => { 140 | conformance_response::Result::ProtobufPayload(dynamic_message.encode_to_vec()) 141 | } 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /prost-reflect-conformance-tests/tests/conformance.rs: -------------------------------------------------------------------------------- 1 | #![cfg(not(target_os = "windows"))] 2 | 3 | use std::env; 4 | use std::process::Command; 5 | 6 | use prost_reflect_conformance_tests::conformance; 7 | 8 | /// Runs the protobuf conformance test. This must be done in an integration test 9 | /// so that Cargo will build the proto-conformance binary. 10 | #[test] 11 | fn test_conformance() { 12 | // Get the path to the proto-conformance binary. Adapted from 13 | // https://github.com/rust-lang/cargo/blob/19fdb308cdbb25faf4f1e25a71351d8d603fa447/tests/cargotest/support/mod.rs#L306. 14 | let proto_conformance = env::current_exe() 15 | .map(|mut path| { 16 | path.pop(); 17 | if path.ends_with("deps") { 18 | path.pop(); 19 | } 20 | path.join("prost-reflect-conformance-tests") 21 | }) 22 | .unwrap(); 23 | 24 | let status = Command::new(conformance::test_runner()) 25 | .arg("--enforce_recommended") 26 | .arg("--failure_list") 27 | .arg("failure_list.txt") 28 | .arg("--text_format_failure_list") 29 | .arg("text_format_failure_list.txt") 30 | .arg(proto_conformance) 31 | .status() 32 | .expect("failed to execute conformance-test-runner"); 33 | 34 | assert!(status.success(), "proto conformance test failed"); 35 | } 36 | -------------------------------------------------------------------------------- /prost-reflect-conformance-tests/text_format_failure_list.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andrewhickman/prost-reflect/826a3178981c2f30bb496f3a32a41f53e45003b4/prost-reflect-conformance-tests/text_format_failure_list.txt -------------------------------------------------------------------------------- /prost-reflect-derive/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "prost-reflect-derive" 3 | description = "A derive macro for prost-reflect to generate ReflectMessage implementations" 4 | keywords = ["protobuf", "serialization", "json"] 5 | categories = ["encoding"] 6 | version = "0.15.1" 7 | authors = ["Andrew Hickman "] 8 | repository = "https://github.com/andrewhickman/prost-reflect" 9 | documentation = "https://docs.rs/prost-reflect-derive" 10 | license = "MIT OR Apache-2.0" 11 | readme = "../README.md" 12 | edition = "2021" 13 | rust-version = "1.74.0" 14 | autotests = false 15 | 16 | [lib] 17 | proc-macro = true 18 | doctest = false 19 | test = false 20 | 21 | [[test]] 22 | name = "tests" 23 | path = "tests/tests.rs" 24 | 25 | [dependencies] 26 | proc-macro2 = "1.0.36" 27 | quote = "1.0.14" 28 | syn = "2.0.32" 29 | 30 | [dev-dependencies] 31 | once_cell = "1.13.0" 32 | prost = "0.13.0" 33 | prost-reflect = { path = "../prost-reflect", features = ["derive"] } 34 | trybuild = "1.0.84" 35 | -------------------------------------------------------------------------------- /prost-reflect-derive/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | ../LICENSE-APACHE -------------------------------------------------------------------------------- /prost-reflect-derive/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | ../LICENSE-MIT -------------------------------------------------------------------------------- /prost-reflect-derive/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! This crate provides the [`ReflectMessage`](https://docs.rs/prost-reflect/latest/prost_reflect/derive.ReflectMessage.html) derive macro 2 | //! 3 | //! For documentation, see the example in the [`prost-reflect` crate docs](https://docs.rs/prost-reflect/latest/prost_reflect/index.html#deriving-reflectmessage). 4 | 5 | use proc_macro::TokenStream; 6 | use proc_macro2::Span; 7 | use quote::{quote, ToTokens}; 8 | use syn::spanned::Spanned; 9 | 10 | /// A derive macro for the [`ReflectMessage`](https://docs.rs/prost-reflect/latest/prost_reflect/trait.ReflectMessage.html) trait. 11 | /// 12 | /// For documentation, see the example in the [`prost-reflect` crate docs](https://docs.rs/prost-reflect/latest/prost_reflect/index.html#deriving-reflectmessage). 13 | #[proc_macro_derive(ReflectMessage, attributes(prost_reflect))] 14 | pub fn reflect_message(input: TokenStream) -> TokenStream { 15 | let input = syn::parse_macro_input!(input as syn::DeriveInput); 16 | 17 | match reflect_message_impl(input) { 18 | Ok(tokens) => tokens.into(), 19 | Err(err) => err.to_compile_error().into(), 20 | } 21 | } 22 | 23 | struct Args { 24 | args_span: Span, 25 | message_name: Option, 26 | descriptor_pool: Option, 27 | file_descriptor_set: Option, 28 | } 29 | 30 | fn reflect_message_impl(input: syn::DeriveInput) -> Result { 31 | match &input.data { 32 | syn::Data::Struct(_) => (), 33 | syn::Data::Enum(_) => return Ok(Default::default()), 34 | syn::Data::Union(_) => return Ok(Default::default()), 35 | }; 36 | 37 | let args = Args::parse(input.ident.span(), &input.attrs)?; 38 | 39 | let name = &input.ident; 40 | let descriptor_pool = args.descriptor_pool()?; 41 | let message_name = args.message_name()?; 42 | 43 | Ok(quote! { 44 | impl ::prost_reflect::ReflectMessage for #name { 45 | fn descriptor(&self) -> ::prost_reflect::MessageDescriptor { 46 | #descriptor_pool 47 | .get_message_by_name(#message_name) 48 | .expect(concat!("descriptor for message type `", #message_name, "` not found")) 49 | } 50 | } 51 | }) 52 | } 53 | 54 | fn is_prost_reflect_attribute(attr: &syn::Attribute) -> bool { 55 | attr.path().is_ident("prost_reflect") 56 | } 57 | 58 | impl Args { 59 | fn parse(input_span: proc_macro2::Span, attrs: &[syn::Attribute]) -> Result { 60 | let reflect_attrs: Vec<_> = attrs 61 | .iter() 62 | .filter(|attr| is_prost_reflect_attribute(attr)) 63 | .collect(); 64 | 65 | if reflect_attrs.is_empty() { 66 | return Err(syn::Error::new( 67 | input_span, 68 | "missing #[prost_reflect] attribute", 69 | )); 70 | } 71 | 72 | let mut args = Args { 73 | args_span: reflect_attrs 74 | .iter() 75 | .map(|a| a.span()) 76 | .reduce(|l, r| l.join(r).unwrap_or(l)) 77 | .unwrap(), 78 | message_name: None, 79 | descriptor_pool: None, 80 | file_descriptor_set: None, 81 | }; 82 | 83 | for attr in reflect_attrs { 84 | attr.parse_nested_meta(|nested| { 85 | if nested.path.is_ident("descriptor_pool") { 86 | args.descriptor_pool = nested.value()?.parse()?; 87 | Ok(()) 88 | } else if nested.path.is_ident("file_descriptor_set_bytes") { 89 | args.file_descriptor_set = nested.value()?.parse()?; 90 | Ok(()) 91 | } else if nested.path.is_ident("message_name") { 92 | args.message_name = nested.value()?.parse()?; 93 | Ok(()) 94 | } else { 95 | Err(syn::Error::new( 96 | nested.path.span(), 97 | "unknown argument (expected 'descriptor_pool', 'file_descriptor_set_bytes' or 'message_name')", 98 | )) 99 | } 100 | })?; 101 | } 102 | 103 | Ok(args) 104 | } 105 | 106 | fn descriptor_pool(&self) -> Result { 107 | if let Some(descriptor_pool) = &self.descriptor_pool { 108 | let expr: syn::Expr = syn::parse_str(&descriptor_pool.value())?; 109 | Ok(expr.to_token_stream()) 110 | } else if let Some(file_descriptor_set) = &self.file_descriptor_set { 111 | let expr: syn::Expr = syn::parse_str(&file_descriptor_set.value())?; 112 | 113 | Ok(quote!({ 114 | static INIT: ::std::sync::Once = ::std::sync::Once::new(); 115 | INIT.call_once(|| ::prost_reflect::DescriptorPool::decode_global_file_descriptor_set(#expr).unwrap()); 116 | ::prost_reflect::DescriptorPool::global() 117 | })) 118 | } else { 119 | Err(syn::Error::new( 120 | self.args_span, 121 | "missing required argument 'descriptor_pool'", 122 | )) 123 | } 124 | } 125 | 126 | fn message_name(&self) -> Result { 127 | if let Some(message_name) = &self.message_name { 128 | Ok(message_name.to_token_stream()) 129 | } else { 130 | Err(syn::Error::new( 131 | self.args_span, 132 | "missing required argument 'message_name'", 133 | )) 134 | } 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /prost-reflect-derive/tests/attr_unknown_field.rs: -------------------------------------------------------------------------------- 1 | use prost_reflect_derive::ReflectMessage; 2 | 3 | #[derive(ReflectMessage)] 4 | #[prost_reflect(foo = 123)] 5 | pub struct MyMessage {} 6 | 7 | fn main() {} 8 | -------------------------------------------------------------------------------- /prost-reflect-derive/tests/attr_unknown_field.stderr: -------------------------------------------------------------------------------- 1 | error: unknown argument (expected 'descriptor_pool', 'file_descriptor_set_bytes' or 'message_name') 2 | --> tests/attr_unknown_field.rs:4:17 3 | | 4 | 4 | #[prost_reflect(foo = 123)] 5 | | ^^^ 6 | -------------------------------------------------------------------------------- /prost-reflect-derive/tests/basic.rs: -------------------------------------------------------------------------------- 1 | use once_cell::sync::Lazy; 2 | use prost::Message; 3 | use prost_reflect::{DescriptorPool, ReflectMessage}; 4 | 5 | static DESCRIPTOR_POOL: Lazy = Lazy::new(|| { 6 | DescriptorPool::decode(include_bytes!("file_descriptor_set.bin").as_ref()).unwrap() 7 | }); 8 | 9 | #[derive(Message, ReflectMessage)] 10 | #[prost_reflect( 11 | descriptor_pool = "DESCRIPTOR_POOL", 12 | message_name = "package.MyMessage" 13 | )] 14 | pub struct MyMessage {} 15 | 16 | fn main() { 17 | assert_eq!(MyMessage {}.descriptor().full_name(), "package.MyMessage"); 18 | } 19 | -------------------------------------------------------------------------------- /prost-reflect-derive/tests/enum.stderr: -------------------------------------------------------------------------------- 1 | error: cannot derive ReflectMessage for enum 2 | --> tests/enum.rs:5:5 3 | | 4 | 5 | pub enum MyMessage {} 5 | | ^^^^ 6 | -------------------------------------------------------------------------------- /prost-reflect-derive/tests/file_descriptor_set.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andrewhickman/prost-reflect/826a3178981c2f30bb496f3a32a41f53e45003b4/prost-reflect-derive/tests/file_descriptor_set.bin -------------------------------------------------------------------------------- /prost-reflect-derive/tests/file_descriptor_set.rs: -------------------------------------------------------------------------------- 1 | use prost::Message; 2 | use prost_reflect::ReflectMessage; 3 | 4 | const FILE_DESCRIPTOR_SET_BYTES: &'static [u8] = include_bytes!("file_descriptor_set.bin"); 5 | 6 | #[derive(Message, ReflectMessage)] 7 | #[prost_reflect(file_descriptor_set_bytes = "FILE_DESCRIPTOR_SET_BYTES")] 8 | #[prost_reflect(message_name = "package.MyMessage")] 9 | pub struct MyNestedMessage {} 10 | 11 | fn main() { 12 | assert_eq!( 13 | MyNestedMessage {}.descriptor().full_name(), 14 | "package.MyMessage" 15 | ); 16 | } 17 | -------------------------------------------------------------------------------- /prost-reflect-derive/tests/ignore_enum.rs: -------------------------------------------------------------------------------- 1 | use prost_reflect_derive::ReflectMessage; 2 | 3 | #[derive(ReflectMessage)] 4 | #[prost_reflect(descriptor_pool = "DESCRIPTOR_POOL", message_name = "msg")] 5 | pub enum MyMessage {} 6 | 7 | fn main() {} 8 | -------------------------------------------------------------------------------- /prost-reflect-derive/tests/missing_attr.rs: -------------------------------------------------------------------------------- 1 | use prost_reflect_derive::ReflectMessage; 2 | 3 | #[derive(ReflectMessage)] 4 | pub struct MyMessage {} 5 | 6 | fn main() {} 7 | -------------------------------------------------------------------------------- /prost-reflect-derive/tests/missing_attr.stderr: -------------------------------------------------------------------------------- 1 | error: missing #[prost_reflect] attribute 2 | --> tests/missing_attr.rs:4:12 3 | | 4 | 4 | pub struct MyMessage {} 5 | | ^^^^^^^^^ 6 | -------------------------------------------------------------------------------- /prost-reflect-derive/tests/missing_name.rs: -------------------------------------------------------------------------------- 1 | use prost_reflect_derive::ReflectMessage; 2 | 3 | #[derive(ReflectMessage)] 4 | #[prost_reflect(descriptor_pool = "DESCRIPTOR_POOL")] 5 | pub struct MyMessage {} 6 | 7 | fn main() {} 8 | -------------------------------------------------------------------------------- /prost-reflect-derive/tests/missing_name.stderr: -------------------------------------------------------------------------------- 1 | error: missing required argument 'message_name' 2 | --> tests/missing_name.rs:4:1 3 | | 4 | 4 | #[prost_reflect(descriptor_pool = "DESCRIPTOR_POOL")] 5 | | ^ 6 | -------------------------------------------------------------------------------- /prost-reflect-derive/tests/multiple_attr.rs: -------------------------------------------------------------------------------- 1 | use once_cell::sync::Lazy; 2 | use prost::Message; 3 | use prost_reflect::{DescriptorPool, ReflectMessage}; 4 | 5 | static DESCRIPTOR_POOL: Lazy = Lazy::new(|| { 6 | DescriptorPool::decode(include_bytes!("file_descriptor_set.bin").as_ref()).unwrap() 7 | }); 8 | 9 | #[derive(Message, ReflectMessage)] 10 | #[prost_reflect(descriptor_pool = "DESCRIPTOR_POOL")] 11 | #[prost_reflect(message_name = "package.MyMessage")] 12 | pub struct MyNestedMessage {} 13 | 14 | fn main() { 15 | assert_eq!( 16 | MyNestedMessage {}.descriptor().full_name(), 17 | "package.MyMessage" 18 | ); 19 | } 20 | -------------------------------------------------------------------------------- /prost-reflect-derive/tests/tests.rs: -------------------------------------------------------------------------------- 1 | #[test] 2 | fn tests() { 3 | let tests = trybuild::TestCases::new(); 4 | 5 | tests.pass("tests/basic.rs"); 6 | tests.pass("tests/ignore_enum.rs"); 7 | tests.pass("tests/multiple_attr.rs"); 8 | tests.pass("tests/file_descriptor_set.rs"); 9 | 10 | tests.compile_fail("tests/attr_unknown_field.rs"); 11 | tests.compile_fail("tests/missing_attr.rs"); 12 | tests.compile_fail("tests/missing_name.rs"); 13 | } 14 | -------------------------------------------------------------------------------- /prost-reflect-tests/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "prost-reflect-tests" 3 | description = "Tests for prost-reflect." 4 | version = "0.0.0" 5 | authors = ["Andrew Hickman "] 6 | license = "MIT OR Apache-2.0" 7 | edition = "2021" 8 | publish = false 9 | build = "build.rs" 10 | 11 | [lib] 12 | doctest = false 13 | 14 | [[bench]] 15 | name = "decode" 16 | harness = false 17 | 18 | [dependencies] 19 | once_cell = "1.9.0" 20 | prost = "0.13.0" 21 | prost-reflect = { path = "../prost-reflect", features = [ 22 | "serde", 23 | "derive", 24 | "text-format" 25 | ] } 26 | prost-types = "0.13.0" 27 | 28 | [dev-dependencies] 29 | proptest = "1.0.0" 30 | proptest-derive = "0.4.0" 31 | serde_json = { version = "1.0.106", features = ["float_roundtrip"] } 32 | serde = "1.0.190" 33 | criterion = "0.4.0" 34 | rayon = "1.5.3" 35 | 36 | [build-dependencies] 37 | prost-reflect-build = { path = "../prost-reflect-build" } 38 | prost-build = "0.13.0" 39 | -------------------------------------------------------------------------------- /prost-reflect-tests/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | ../LICENSE-APACHE -------------------------------------------------------------------------------- /prost-reflect-tests/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | ../LICENSE-MIT -------------------------------------------------------------------------------- /prost-reflect-tests/benches/decode.rs: -------------------------------------------------------------------------------- 1 | use std::{collections::BTreeMap, iter::FromIterator}; 2 | 3 | use criterion::{criterion_group, criterion_main, Criterion}; 4 | use prost::Message; 5 | use prost_reflect::{DynamicMessage, ReflectMessage}; 6 | use prost_reflect_tests::proto::WellKnownTypes; 7 | use rayon::iter::{IntoParallelIterator, ParallelIterator}; 8 | 9 | fn sample_wkt() -> WellKnownTypes { 10 | WellKnownTypes { 11 | timestamp: Some(prost_types::Timestamp { 12 | seconds: 63_108_020, 13 | nanos: 21_000_000, 14 | }), 15 | duration: Some(prost_types::Duration { 16 | seconds: 1, 17 | nanos: 340_012, 18 | }), 19 | r#struct: Some(prost_types::Struct { 20 | fields: BTreeMap::from_iter([ 21 | ( 22 | "number".to_owned(), 23 | prost_types::Value { 24 | kind: Some(prost_types::value::Kind::NumberValue(42.)), 25 | }, 26 | ), 27 | ( 28 | "null".to_owned(), 29 | prost_types::Value { 30 | kind: Some(prost_types::value::Kind::NullValue(0)), 31 | }, 32 | ), 33 | ]), 34 | }), 35 | float: Some(42.1), 36 | double: Some(12.4), 37 | int32: Some(1), 38 | int64: Some(-2), 39 | uint32: Some(3), 40 | uint64: Some(4), 41 | bool: Some(false), 42 | string: Some("hello".to_owned()), 43 | bytes: Some(b"hello".to_vec()), 44 | mask: Some(prost_types::FieldMask { 45 | paths: vec!["field_one".to_owned(), "field_two.b.d".to_owned()], 46 | }), 47 | list: Some(prost_types::ListValue { 48 | values: vec![ 49 | prost_types::Value { 50 | kind: Some(prost_types::value::Kind::StringValue("foo".to_owned())), 51 | }, 52 | prost_types::Value { 53 | kind: Some(prost_types::value::Kind::BoolValue(false)), 54 | }, 55 | ], 56 | }), 57 | null: 0, 58 | empty: Some(()), 59 | } 60 | } 61 | 62 | fn decode_wkt(c: &mut Criterion) { 63 | let value = sample_wkt().transcode_to_dynamic(); 64 | 65 | c.bench_function("decode_wkt", |b| b.iter(|| value.encode_to_vec())); 66 | } 67 | 68 | fn encode_wkt(c: &mut Criterion) { 69 | let value = sample_wkt().encode_to_vec(); 70 | let desc = prost_reflect_tests::test_file_descriptor() 71 | .get_message_by_name("test.WellKnownTypes") 72 | .unwrap(); 73 | 74 | c.bench_function("encode_wkt", |b| { 75 | b.iter(|| DynamicMessage::decode(desc.clone(), value.as_slice())) 76 | }); 77 | } 78 | 79 | fn decode_wkt_multithread(c: &mut Criterion) { 80 | let value = sample_wkt().transcode_to_dynamic(); 81 | 82 | c.bench_function("decode_wkt_multithread", |b| { 83 | b.iter(|| { 84 | (0i32..256) 85 | .into_par_iter() 86 | .for_each(|_| drop(criterion::black_box(value.encode_to_vec()))) 87 | }) 88 | }); 89 | } 90 | 91 | fn encode_wkt_multithread(c: &mut Criterion) { 92 | let value = sample_wkt().encode_to_vec(); 93 | let desc = prost_reflect_tests::test_file_descriptor() 94 | .get_message_by_name("test.WellKnownTypes") 95 | .unwrap(); 96 | 97 | c.bench_function("encode_wkt_multithread", |b| { 98 | b.iter(|| { 99 | (0i32..256).into_par_iter().for_each(|_| { 100 | drop(criterion::black_box(DynamicMessage::decode( 101 | desc.clone(), 102 | value.as_slice(), 103 | ))) 104 | }) 105 | }) 106 | }); 107 | } 108 | 109 | criterion_group! { 110 | name = benches; 111 | config = Criterion::default().sample_size(500); 112 | targets = decode_wkt, encode_wkt, decode_wkt_multithread, encode_wkt_multithread 113 | } 114 | criterion_main!(benches); 115 | -------------------------------------------------------------------------------- /prost-reflect-tests/build.rs: -------------------------------------------------------------------------------- 1 | use std::io; 2 | 3 | fn main() -> io::Result<()> { 4 | let mut config = prost_build::Config::new(); 5 | config 6 | .type_attribute(".test.Scalars", "#[cfg_attr(test, derive(::proptest_derive::Arbitrary))]") 7 | .type_attribute(".test.ScalarArrays", "#[cfg_attr(test, derive(::proptest_derive::Arbitrary))]") 8 | .type_attribute(".test.ComplexType", "#[cfg_attr(test, derive(::proptest_derive::Arbitrary))]") 9 | .type_attribute(".test.WellKnownTypes", "#[cfg_attr(test, derive(::proptest_derive::Arbitrary))]") 10 | .field_attribute( 11 | ".test.WellKnownTypes.timestamp", 12 | "#[cfg_attr(test, proptest(strategy = \"::proptest::option::of(crate::arbitrary::timestamp())\"))]", 13 | ) 14 | .field_attribute( 15 | ".test.WellKnownTypes.duration", 16 | "#[cfg_attr(test, proptest(strategy = \"::proptest::option::of(crate::arbitrary::duration())\"))]", 17 | ) 18 | .field_attribute( 19 | ".test.WellKnownTypes.struct", 20 | "#[cfg_attr(test, proptest(strategy = \"::proptest::option::of(crate::arbitrary::struct_())\"))]", 21 | ) 22 | .field_attribute( 23 | ".test.WellKnownTypes.list", 24 | "#[cfg_attr(test, proptest(strategy = \"::proptest::option::of(crate::arbitrary::list())\"))]", 25 | ) 26 | .field_attribute( 27 | ".test.WellKnownTypes.mask", 28 | "#[cfg_attr(test, proptest(strategy = \"::proptest::option::of(crate::arbitrary::mask())\"))]", 29 | ) 30 | .field_attribute( 31 | ".test.WellKnownTypes.empty", 32 | "#[cfg_attr(test, proptest(strategy = \"::proptest::option::of(::proptest::strategy::Just(()))\"))]", 33 | ) 34 | .field_attribute(".test.WellKnownTypes.null", "#[cfg_attr(test, proptest(value= \"0\"))]"); 35 | 36 | prost_reflect_build::Builder::new() 37 | .file_descriptor_set_bytes("crate::DESCRIPTOR_POOL_BYTES") 38 | .compile_protos_with_config( 39 | config, 40 | &[ 41 | "src/test.proto", 42 | "src/test2.proto", 43 | "src/desc.proto", 44 | "src/desc2.proto", 45 | "src/desc_no_package.proto", 46 | "src/imports.proto", 47 | "src/ext.proto", 48 | "src/options.proto", 49 | ], 50 | &["src/"], 51 | )?; 52 | Ok(()) 53 | } 54 | -------------------------------------------------------------------------------- /prost-reflect-tests/proptest-regressions/lib.txt: -------------------------------------------------------------------------------- 1 | # Seeds for failure cases proptest has generated in the past. It is 2 | # automatically read and these particular cases re-run before any 3 | # novel cases are generated. 4 | # 5 | # It is recommended to check this file in to source control so that 6 | # everyone who runs the test benefits from these saved cases. 7 | cc 90431bfd23e601febb80832e4e0066d5cf068fe261fdd8697fe3c4ebc6e92337 # shrinks to message = WellKnownTypes { timestamp: None, duration: None, r#struct: None, float: None, double: None, int32: None, int64: None, uint32: None, uint64: None, bool: None, string: None, bytes: None, mask: None, list: Some(ListValue { values: [Value { kind: Some(ListValue(ListValue { values: [Value { kind: Some(ListValue(ListValue { values: [Value { kind: Some(NumberValue(NaN)) }] })) }] })) }] }), null: NullValue, empty: None } 8 | cc ca6b3a594f64f3641bae07db2a1187995c9b729f85c1d54d2e759cb441105014 # shrinks to message = WellKnownTypes { timestamp: None, duration: None, r#struct: None, float: None, double: None, int32: None, int64: None, uint32: None, uint64: None, bool: None, string: None, bytes: None, mask: None, list: Some(ListValue { values: [Value { kind: Some(StructValue(Struct { fields: {"": Value { kind: Some(NullValue(NullValue)) }} })) }] }), null: NullValue, empty: None } 9 | cc a3356afcd3b3f7b74cfdd84c778dddeb9ac1174413aaff764a4e93a5c291885c # shrinks to message = ComplexType { string_map: {}, int_map: {}, nested: Some(Scalars { double: 0.0, float: 0.0, int32: 0, int64: 0, uint32: 0, uint64: 0, sint32: 0, sint64: 0, fixed32: 0, fixed64: 0, sfixed32: 0, sfixed64: 0, bool: false, string: "", bytes: [] }), my_enum: [] } 10 | -------------------------------------------------------------------------------- /prost-reflect-tests/src/arbitrary.rs: -------------------------------------------------------------------------------- 1 | use std::time::SystemTime; 2 | use std::{fmt::Write, iter::FromIterator}; 3 | 4 | use proptest::prelude::*; 5 | use prost_types::{value::Kind, Duration, FieldMask, ListValue, Struct, Timestamp, Value}; 6 | 7 | pub fn timestamp() -> impl Strategy { 8 | any::().prop_map(Into::into) 9 | } 10 | 11 | prop_compose! { 12 | pub fn duration()( 13 | seconds in (-315_576_000_000i64..=315_576_000_000), 14 | nanos in (-999_999_999i32..=999_999_999), 15 | ) -> Duration { 16 | let mut duration = Duration { seconds, nanos }; 17 | duration.normalize(); 18 | duration 19 | } 20 | } 21 | 22 | pub fn struct_() -> impl Strategy { 23 | struct_inner(value().boxed()) 24 | } 25 | 26 | pub fn struct_inner(value_strat: BoxedStrategy) -> impl Strategy { 27 | prop::collection::btree_map(any::(), value_strat, 0..4) 28 | .prop_map(|fields| Struct { fields }) 29 | } 30 | 31 | pub fn list() -> impl Strategy { 32 | list_inner(value().boxed()) 33 | } 34 | 35 | pub fn list_inner(value_strat: BoxedStrategy) -> impl Strategy { 36 | prop::collection::vec(value_strat, 0..4).prop_map(|values| ListValue { values }) 37 | } 38 | 39 | fn arb_finite_float() -> impl Strategy { 40 | use prop::num::f64::*; 41 | POSITIVE | NEGATIVE | NORMAL | SUBNORMAL | ZERO 42 | } 43 | 44 | pub fn value() -> impl Strategy { 45 | prop_oneof![ 46 | Just(Kind::NullValue(0)), 47 | arb_finite_float().prop_map(Kind::NumberValue), 48 | any::().prop_map(Kind::StringValue), 49 | prop::bool::ANY.prop_map(Kind::BoolValue), 50 | ] 51 | .prop_map(|kind| Value { kind: Some(kind) }) 52 | .prop_recursive(4, 10, 4, |value| { 53 | prop_oneof![ 54 | list_inner(value.clone()).prop_map(Kind::ListValue), 55 | struct_inner(value).prop_map(Kind::StructValue) 56 | ] 57 | .prop_map(|kind| Value { kind: Some(kind) }) 58 | }) 59 | } 60 | 61 | pub fn mask() -> impl Strategy { 62 | let parts = prop::collection::vec("([a-z]{1,3}_){0,3}[a-z]{1,3}", 1..4); 63 | let paths = prop::collection::vec(parts, 0..4); 64 | paths.prop_map(|paths| FieldMask { 65 | paths: paths 66 | .into_iter() 67 | .map(|parts| { 68 | let mut parts = parts.into_iter(); 69 | let mut path = parts.next().unwrap(); 70 | for part in parts { 71 | write!(path, ".{}", part).unwrap(); 72 | } 73 | path 74 | }) 75 | .collect(), 76 | }) 77 | } 78 | 79 | pub fn json() -> impl Strategy { 80 | fn arb_json_key() -> impl Strategy { 81 | // Use real field names to make the deserialization error test more interesting 82 | prop_oneof![ 83 | 2 => Just("float".to_owned()), 84 | 2 => Just("double".to_owned()), 85 | 2 => Just("int32".to_owned()), 86 | 2 => Just("int64".to_owned()), 87 | 2 => Just("uint32".to_owned()), 88 | 2 => Just("uint64".to_owned()), 89 | 2 => Just("bool".to_owned()), 90 | 2 => Just("string".to_owned()), 91 | 2 => Just("bytes".to_owned()), 92 | 1 => Just("string_map".to_owned()), 93 | 1 => Just("int_map".to_owned()), 94 | 1 => Just("nested".to_owned()), 95 | 1 => Just("my_enum".to_owned()), 96 | 1 => Just("optional_enum".to_owned()), 97 | 1 => Just("timestamp".to_owned()), 98 | 1 => Just("duration".to_owned()), 99 | 1 => Just("struct".to_owned()), 100 | 1 => Just("mask".to_owned()), 101 | 1 => Just("list".to_owned()), 102 | 1 => Just("null".to_owned()), 103 | 1 => Just("empty".to_owned()), 104 | 1 => Just("sint32".to_owned()), 105 | 1 => Just("sint64".to_owned()), 106 | 1 => Just("fixed32".to_owned()), 107 | 1 => Just("fixed64".to_owned()), 108 | 1 => Just("sfixed32".to_owned()), 109 | 1 => Just("sfixed64".to_owned()), 110 | ] 111 | } 112 | 113 | fn arb_json_value() -> impl Strategy { 114 | let leaf = prop_oneof![ 115 | Just(serde_json::Value::Null), 116 | any::().prop_map(serde_json::Value::from), 117 | any::().prop_map(serde_json::Value::from), 118 | ".*".prop_map(serde_json::Value::from), 119 | ]; 120 | leaf.prop_recursive(4, 32, 4, |inner| { 121 | prop_oneof![ 122 | prop::collection::vec(inner.clone(), 0..4).prop_map(serde_json::Value::Array), 123 | prop::collection::hash_map(arb_json_key(), inner, 0..4) 124 | .prop_map(|map| serde_json::Map::from_iter(map).into()), 125 | ] 126 | }) 127 | } 128 | 129 | prop::collection::hash_map(arb_json_key(), arb_json_value(), 0..10) 130 | .prop_map(|map| serde_json::Value::Object(map.into_iter().collect()).to_string()) 131 | } 132 | -------------------------------------------------------------------------------- /prost-reflect-tests/src/desc.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package my.package; 4 | 5 | message MyMessage { 6 | oneof my_oneof { 7 | int32 my_field = 1; 8 | } 9 | 10 | reserved 2, 15, 9 to 11; 11 | reserved "foo", "bar"; 12 | 13 | message MyNestedMessage {} 14 | enum MyNestedEnum { 15 | MY_VALUE = 0; 16 | } 17 | } 18 | 19 | enum MyEnum { 20 | MY_VALUE = 0; 21 | 22 | reserved -2, 15, 9 to 11; 23 | reserved "FOO", "BAR"; 24 | } 25 | 26 | service MyService { 27 | rpc MyMethod(MyMessage) returns (MyMessage); 28 | } 29 | -------------------------------------------------------------------------------- /prost-reflect-tests/src/desc2.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package my.package2; 4 | 5 | message MyMessage { 6 | reserved 2, 15, 9 to 11; 7 | reserved "foo", "bar"; 8 | extensions 100, 110 to 115; 9 | 10 | optional int32 int = 1; 11 | 12 | extend MyMessage { 13 | optional int32 in_extendee = 111; 14 | } 15 | } 16 | 17 | extend MyMessage { 18 | optional float in_file = 112; 19 | } 20 | 21 | message OtherMessage { 22 | extend MyMessage { 23 | optional double in_other = 113; 24 | } 25 | } -------------------------------------------------------------------------------- /prost-reflect-tests/src/desc_no_package.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | message MyMessage { 4 | oneof my_oneof { 5 | int32 my_field = 1; 6 | } 7 | 8 | message MyNestedMessage {} 9 | enum MyNestedEnum { 10 | MY_NESTED_VALUE = 0; 11 | } 12 | } 13 | 14 | enum MyEnum { 15 | MY_VALUE = 0; 16 | } 17 | 18 | service MyService { 19 | rpc MyMethod(MyMessage) returns (MyMessage); 20 | } 21 | -------------------------------------------------------------------------------- /prost-reflect-tests/src/ext.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | import "google/protobuf/descriptor.proto"; 4 | 5 | package demo; 6 | 7 | extend google.protobuf.EnumValueOptions { 8 | optional uint32 len = 50000; 9 | } 10 | 11 | enum Foo { 12 | None = 0 [(len) = 0]; 13 | One = 1 [(len) = 1]; 14 | Two = 2 [(len) = 2]; 15 | } -------------------------------------------------------------------------------- /prost-reflect-tests/src/imports.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | import "google/protobuf/any.proto"; 4 | import "google/protobuf/descriptor.proto"; 5 | 6 | // Dummy message to prevent unused import warnings 7 | message Dummy { 8 | google.protobuf.Any dummy = 1; 9 | google.protobuf.FileDescriptorSet dummy2 = 2; 10 | } 11 | -------------------------------------------------------------------------------- /prost-reflect-tests/src/lib.rs: -------------------------------------------------------------------------------- 1 | use prost_reflect::{DescriptorPool, ReflectMessage}; 2 | use proto::Scalars; 3 | 4 | #[cfg(test)] 5 | mod arbitrary; 6 | #[cfg(test)] 7 | mod decode; 8 | #[cfg(test)] 9 | mod desc; 10 | #[cfg(test)] 11 | mod json; 12 | #[cfg(test)] 13 | mod text_format; 14 | 15 | pub mod proto { 16 | #![allow(clippy::all)] 17 | include!(concat!(env!("OUT_DIR"), "/test.rs")); 18 | include!(concat!(env!("OUT_DIR"), "/test2.rs")); 19 | 20 | pub mod options { 21 | include!(concat!(env!("OUT_DIR"), "/custom.options.rs")); 22 | } 23 | } 24 | 25 | const DESCRIPTOR_POOL_BYTES: &[u8] = 26 | include_bytes!(concat!(env!("OUT_DIR"), "/file_descriptor_set.bin")); 27 | 28 | pub fn test_file_descriptor() -> DescriptorPool { 29 | // Ensure global pool is populated with test descriptors. 30 | let _ = Scalars::default().descriptor(); 31 | 32 | DescriptorPool::global() 33 | } 34 | -------------------------------------------------------------------------------- /prost-reflect-tests/src/options.proto: -------------------------------------------------------------------------------- 1 | syntax = 'proto3'; 2 | 3 | import 'google/protobuf/descriptor.proto'; 4 | 5 | package custom.options; 6 | 7 | extend google.protobuf.FileOptions { 8 | int32 file = 1001; 9 | } 10 | 11 | extend google.protobuf.MessageOptions { 12 | string message = 1001; 13 | } 14 | 15 | extend google.protobuf.FieldOptions { 16 | bytes field = 1001 [(field) = "extension"]; 17 | } 18 | 19 | extend google.protobuf.OneofOptions { 20 | repeated float oneof = 1001; 21 | } 22 | 23 | extend google.protobuf.EnumOptions { 24 | Aggregate enum = 1001; 25 | } 26 | 27 | extend google.protobuf.EnumValueOptions { 28 | Enum value = 1001; 29 | } 30 | 31 | extend google.protobuf.ServiceOptions { 32 | bool service = 1001; 33 | } 34 | 35 | extend google.protobuf.MethodOptions { 36 | uint64 method = 1001; 37 | } 38 | 39 | option (file) = -1; 40 | 41 | message Aggregate { 42 | option (message) = "abc"; 43 | 44 | int32 a = 1 [(field) = "\010"]; 45 | oneof O { 46 | option (oneof) = 5.5; 47 | option (oneof) = -5; 48 | option (oneof) = 5; 49 | 50 | string b = 2; 51 | } 52 | } 53 | 54 | enum Enum { 55 | option (enum) = { a: 32, b: "abc" }; 56 | 57 | VALUE = 0 [(value) = VALUE2]; 58 | VALUE2 = 1 [(value) = VALUE]; 59 | } 60 | 61 | service Service { 62 | option (service) = true; 63 | 64 | rpc rpc(Aggregate) returns (Aggregate) { 65 | option (method) = 6; 66 | } 67 | } -------------------------------------------------------------------------------- /prost-reflect-tests/src/test.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | import "google/protobuf/timestamp.proto"; 4 | import "google/protobuf/duration.proto"; 5 | import "google/protobuf/struct.proto"; 6 | import "google/protobuf/wrappers.proto"; 7 | import "google/protobuf/field_mask.proto"; 8 | import "google/protobuf/empty.proto"; 9 | 10 | package test; 11 | 12 | message Scalars { 13 | double double = 1; 14 | float float = 2; 15 | int32 int32 = 3; 16 | int64 int64 = 4; 17 | uint32 uint32 = 5; 18 | uint64 uint64 = 6; 19 | sint32 sint32 = 7; 20 | sint64 sint64 = 8; 21 | fixed32 fixed32 = 9; 22 | fixed64 fixed64 = 10; 23 | sfixed32 sfixed32 = 11; 24 | sfixed64 sfixed64 = 12; 25 | bool bool = 13; 26 | string string = 14; 27 | bytes bytes = 15; 28 | } 29 | 30 | message ScalarArrays { 31 | repeated double double = 1; 32 | repeated float float = 2; 33 | repeated int32 int32 = 3; 34 | repeated int64 int64 = 4; 35 | repeated uint32 uint32 = 5; 36 | repeated uint64 uint64 = 6; 37 | repeated sint32 sint32 = 7; 38 | repeated sint64 sint64 = 8; 39 | repeated fixed32 fixed32 = 9; 40 | repeated fixed64 fixed64 = 10; 41 | repeated sfixed32 sfixed32 = 11; 42 | repeated sfixed64 sfixed64 = 12; 43 | repeated bool bool = 13; 44 | repeated string string = 14; 45 | repeated bytes bytes = 15; 46 | } 47 | 48 | message ComplexType { 49 | map string_map = 1; 50 | map int_map = 2; 51 | Scalars nested = 3; 52 | repeated MyEnum my_enum = 4; 53 | MyEnum optional_enum = 5; 54 | map enum_map = 6; 55 | 56 | enum MyEnum { 57 | DEFAULT = 0; 58 | FOO = 1; 59 | BAR = 3; 60 | NEG = -4; 61 | } 62 | } 63 | 64 | message WellKnownTypes { 65 | google.protobuf.Timestamp timestamp = 1; 66 | google.protobuf.Duration duration = 2; 67 | google.protobuf.Struct struct = 3; 68 | google.protobuf.FloatValue float = 4; 69 | google.protobuf.DoubleValue double = 5; 70 | google.protobuf.Int32Value int32 = 6; 71 | google.protobuf.Int64Value int64 = 7; 72 | google.protobuf.UInt32Value uint32 = 8; 73 | google.protobuf.UInt64Value uint64 = 9; 74 | google.protobuf.BoolValue bool = 10; 75 | google.protobuf.StringValue string = 11; 76 | google.protobuf.BytesValue bytes = 12; 77 | google.protobuf.FieldMask mask = 13; 78 | google.protobuf.ListValue list = 14; 79 | google.protobuf.NullValue null = 15; 80 | google.protobuf.Empty empty = 16; 81 | } 82 | 83 | message MessageWithOneof { 84 | oneof test_oneof { 85 | string oneof_field_1 = 1; 86 | int32 oneof_field_2 = 2; 87 | google.protobuf.NullValue oneof_null = 3; 88 | google.protobuf.Value oneof_value_null = 4; 89 | } 90 | } 91 | 92 | message Point { 93 | int32 latitude = 1; 94 | int32 longitude = 2; 95 | } 96 | 97 | enum EnumWithAlias { 98 | option allow_alias = true; 99 | 100 | FOO = 0; 101 | BAR = 0; 102 | A = 1; 103 | B = 1; 104 | C = 1; 105 | TWO = 2; 106 | } 107 | 108 | message MessageWithAliasedEnum { 109 | EnumWithAlias aliased = 1; 110 | } 111 | 112 | message IndexOrder { 113 | int32 a = 3; 114 | int32 b = 2; 115 | int32 c = 1; 116 | } 117 | -------------------------------------------------------------------------------- /prost-reflect-tests/src/test2.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package test2; 4 | 5 | message DefaultValues { 6 | optional double double = 1 [default = 1.1]; 7 | optional float float = 2 [default = 2.2]; 8 | optional int32 int32 = 3 [default = -3]; 9 | optional int64 int64 = 4 [default = 4]; 10 | optional uint32 uint32 = 5 [default = 5]; 11 | optional uint64 uint64 = 6 [default = 6]; 12 | optional sint32 sint32 = 7 [default = -7]; 13 | optional sint64 sint64 = 8 [default = 8]; 14 | optional fixed32 fixed32 = 9 [default = 9]; 15 | optional fixed64 fixed64 = 10 [default = 10]; 16 | optional sfixed32 sfixed32 = 11 [default = -11]; 17 | optional sfixed64 sfixed64 = 12 [default = 12]; 18 | optional bool bool = 13 [default = true]; 19 | optional string string = 14 [default = "hello"]; 20 | optional bytes bytes = 15 [default = "\0\x01\x07\x08\x0C\n\r\t\x0B\\\'\"\xFE"]; 21 | optional Proto2Enum defaulted_enum = 16 [default = OTHER]; 22 | optional Proto2Enum enum = 17; 23 | } 24 | 25 | message UnpackedScalarArray { 26 | repeated double unpacked_double = 42; 27 | } 28 | 29 | enum Proto2Enum { 30 | DEFAULT = 2; 31 | OTHER = 3; 32 | } 33 | 34 | message ContainsGroup { 35 | optional group RequiredGroup = 1 { 36 | required string a = 1; 37 | optional int32 b = 2; 38 | } 39 | optional group OptionalGroup = 2 { 40 | required string c = 1; 41 | optional int32 d = 2; 42 | } 43 | repeated group RepeatedGroup = 3 { 44 | required string e = 1; 45 | optional int32 f = 2; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /prost-reflect/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "prost-reflect" 3 | description = "A protobuf library extending prost with reflection support and dynamic messages." 4 | keywords = ["protobuf", "serialization", "json"] 5 | categories = ["encoding"] 6 | version = "0.15.3" 7 | authors = ["Andrew Hickman "] 8 | repository = "https://github.com/andrewhickman/prost-reflect" 9 | documentation = "https://docs.rs/prost-reflect" 10 | license = "MIT OR Apache-2.0" 11 | readme = "../README.md" 12 | edition = "2021" 13 | rust-version = "1.74.0" 14 | exclude = [ 15 | "proptest-regressions", 16 | ] 17 | 18 | [[test]] 19 | name = "main" 20 | path = "tests/main.rs" 21 | required-features = ["serde", "miette", "text-format"] 22 | 23 | [features] 24 | derive = ["dep:prost-reflect-derive"] 25 | serde = ["dep:serde", "dep:base64", "dep:serde-value"] 26 | text-format = ["dep:logos"] 27 | miette = ["dep:miette"] 28 | 29 | [dependencies] 30 | base64 = { version = "0.22.0", optional = true } 31 | logos = { version = "0.15.0", optional = true } 32 | miette = { version = "7.0.0", optional = true } 33 | prost = "0.13.0" 34 | prost-reflect-derive = { path = '../prost-reflect-derive', version = "0.15.1", optional = true } 35 | prost-types = "0.13.0" 36 | serde-value = { version = "0.7.0", optional = true } 37 | serde = { version = "1.0.132", optional = true } 38 | 39 | [dev-dependencies] 40 | insta = { version = "1.23.0", features = ["yaml"] } 41 | once_cell = "1.13.0" 42 | proptest = "1.0.0" 43 | prost-build = "0.13.0" 44 | prost-reflect-build = { path = "../prost-reflect-build" } 45 | serde_json = "1.0.106" 46 | serde_yaml = "0.9.25" 47 | similar-asserts = { version = "1.4.2", features = ["serde"] } 48 | 49 | [package.metadata.docs.rs] 50 | all-features = true 51 | rustdoc-args = ["--cfg", "docsrs"] 52 | -------------------------------------------------------------------------------- /prost-reflect/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | ../LICENSE-APACHE -------------------------------------------------------------------------------- /prost-reflect/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | ../LICENSE-MIT -------------------------------------------------------------------------------- /prost-reflect/doc/decoding.md: -------------------------------------------------------------------------------- 1 | `DynamicMessage` does not implement [`Default`] since it needs a message descriptor to 2 | function. To decode a protobuf byte stream into an instance of this type, use [`DynamicMessage::decode`] 3 | to create a default value for the `MessageDescriptor` instance and merge into it: 4 | 5 | ```rust 6 | use prost::Message; 7 | use prost_types::FileDescriptorSet; 8 | use prost_reflect::{DynamicMessage, DescriptorPool, Value}; 9 | 10 | let pool = DescriptorPool::decode(include_bytes!("file_descriptor_set.bin").as_ref()).unwrap(); 11 | let message_descriptor = pool.get_message_by_name("package.MyMessage").unwrap(); 12 | 13 | let dynamic_message = DynamicMessage::decode(message_descriptor, b"\x08\x96\x01".as_ref()).unwrap(); 14 | 15 | assert_eq!(dynamic_message.get_field_by_name("foo").unwrap().as_ref(), &Value::I32(150)); 16 | ``` -------------------------------------------------------------------------------- /prost-reflect/doc/file_descriptor_set.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andrewhickman/prost-reflect/826a3178981c2f30bb496f3a32a41f53e45003b4/prost-reflect/doc/file_descriptor_set.bin -------------------------------------------------------------------------------- /prost-reflect/doc/intro.md: -------------------------------------------------------------------------------- 1 | This crate provides support for dynamic protobuf messages. These are useful when the 2 | protobuf type definition is not known ahead of time. 3 | 4 | The main entry points into the API of this crate are: 5 | 6 | - [`DescriptorPool`] wraps a [`FileDescriptorSet`][prost_types::FileDescriptorSet] output by 7 | the protobuf compiler to provide an API for inspecting type definitions. 8 | - [`DynamicMessage`] provides encoding, decoding and reflection of an arbitrary protobuf 9 | message definition described by a [`MessageDescriptor`]. -------------------------------------------------------------------------------- /prost-reflect/doc/json.md: -------------------------------------------------------------------------------- 1 | When the `serde` feature is enabled, `DynamicMessage` can be deserialized to and from the 2 | [canonical JSON mapping](https://developers.google.com/protocol-buffers/docs/proto3#json) 3 | defined for protobuf messages. 4 | 5 | ```rust 6 | use prost::Message; 7 | use prost_reflect::{DynamicMessage, DescriptorPool, Value}; 8 | use serde_json::de::Deserializer; 9 | 10 | let pool = DescriptorPool::decode(include_bytes!("file_descriptor_set.bin").as_ref()).unwrap(); 11 | let message_descriptor = pool.get_message_by_name("package.MyMessage").unwrap(); 12 | 13 | let json = r#"{ "foo": 150 }"#; 14 | let mut deserializer = Deserializer::from_str(json); 15 | let dynamic_message = DynamicMessage::deserialize(message_descriptor, &mut deserializer).unwrap(); 16 | deserializer.end().unwrap(); 17 | 18 | assert_eq!(dynamic_message.get_field_by_name("foo").unwrap().as_ref(), &Value::I32(150)); 19 | ``` -------------------------------------------------------------------------------- /prost-reflect/doc/reflect.md: -------------------------------------------------------------------------------- 1 | The [`ReflectMessage`] trait provides a `.descriptor()` method to get type information for a message. It is implemented for `DynamicMessage` and the well-known-types provided by [`prost-types`](https://docs.rs/prost-types/0.10.0/prost_types). 2 | 3 | When the `derive` feature is enabled, it can be derived for [`Message`][prost::Message] implementations. The 4 | derive macro takes the following parameters: 5 | 6 | | Name | Value | 7 | |-----------------|-------| 8 | | descriptor_pool | An expression that resolves to a [`DescriptorPool`] containing the message type. The descriptor should be cached to avoid re-building it. Either this or `file_descriptor_pool_bytes` must be set | 9 | | file_descriptor_pool_bytes | An expression that resolves to an implementation of `Buf` containing an encoded file descriptor set. This will be automatically added to the global descriptor pool the first time `ReflectMessage::descriptor()` is called. | 10 | | message_name | The full name of the message, used to look it up within [`DescriptorPool`]. | 11 | 12 | ```rust 13 | use prost::Message; 14 | use prost_reflect::{DescriptorPool, ReflectMessage}; 15 | use once_cell::sync::Lazy; 16 | 17 | static DESCRIPTOR_POOL: Lazy 18 | = Lazy::new(|| DescriptorPool::decode(include_bytes!("file_descriptor_set.bin").as_ref()).unwrap()); 19 | 20 | #[derive(Message, ReflectMessage)] 21 | #[prost_reflect(descriptor_pool = "DESCRIPTOR_POOL", message_name = "package.MyMessage")] 22 | pub struct MyMessage {} 23 | 24 | let message = MyMessage {}; 25 | assert_eq!(message.descriptor().full_name(), "package.MyMessage"); 26 | ``` 27 | 28 | If you are using `prost-build`, the [`prost-reflect-build`](https://crates.io/crates/prost-reflect-build) crate provides helpers to generate `ReflectMessage` implementations: 29 | 30 | ```rust,no_run 31 | prost_reflect_build::Builder::new() 32 | .compile_protos(&["src/package.proto"], &["src"]) 33 | .unwrap(); 34 | ``` -------------------------------------------------------------------------------- /prost-reflect/proptest-regressions/dynamic/serde/case.txt: -------------------------------------------------------------------------------- 1 | # Seeds for failure cases proptest has generated in the past. It is 2 | # automatically read and these particular cases re-run before any 3 | # novel cases are generated. 4 | # 5 | # It is recommended to check this file in to source control so that 6 | # everyone who runs the test benefits from these saved cases. 7 | cc 1c223f52970c430d1d376aa510580dafbe912cf7ee9b727e77db9894f61aeccd # shrinks to snake_case = "A" 8 | -------------------------------------------------------------------------------- /prost-reflect/src/descriptor/global.rs: -------------------------------------------------------------------------------- 1 | use std::sync::{Mutex, MutexGuard, OnceLock}; 2 | 3 | use prost::bytes::Buf; 4 | use prost_types::FileDescriptorProto; 5 | 6 | use crate::{DescriptorError, DescriptorPool}; 7 | 8 | static INSTANCE: OnceLock> = OnceLock::new(); 9 | 10 | fn instance() -> MutexGuard<'static, DescriptorPool> { 11 | INSTANCE 12 | .get_or_init(|| Mutex::new(crate::reflect::make_wkt_descriptor_pool().unwrap())) 13 | .lock() 14 | .unwrap() 15 | } 16 | 17 | impl DescriptorPool { 18 | /// Gets a copy of the global descriptor pool. By default, this just contains the google well-known types. 19 | /// 20 | /// The global descriptor pool is typically used as a convenient place to store descriptors for `ReflectMessage` implementations. 21 | /// 22 | /// Note that modifications to the returned pool won't affect the global pool - use 23 | /// [`decode_global_file_descriptor_set`](DescriptorPool::decode_global_file_descriptor_set) or 24 | /// [`add_global_file_descriptor_proto`](DescriptorPool::add_global_file_descriptor_proto) to modify the global pool. 25 | pub fn global() -> DescriptorPool { 26 | instance().clone() 27 | } 28 | 29 | /// Decodes and adds a set of file descriptors to the global pool. 30 | /// 31 | /// See [`DescriptorPool::decode_file_descriptor_set`] for more details. 32 | pub fn decode_global_file_descriptor_set(bytes: B) -> Result<(), DescriptorError> 33 | where 34 | B: Buf, 35 | { 36 | instance().decode_file_descriptor_set(bytes)?; 37 | Ok(()) 38 | } 39 | 40 | /// Adds a single file descriptor to the global pool. 41 | /// 42 | /// See [`DescriptorPool::add_file_descriptor_proto`] for more details. 43 | pub fn add_global_file_descriptor_proto( 44 | file: FileDescriptorProto, 45 | ) -> Result<(), DescriptorError> { 46 | instance().add_file_descriptor_proto(file)?; 47 | Ok(()) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /prost-reflect/src/descriptor/tag.rs: -------------------------------------------------------------------------------- 1 | #![allow(dead_code)] 2 | 3 | pub(crate) const UNINTERPRETED_OPTION: i32 = 999; 4 | 5 | pub(crate) mod file_descriptor_set { 6 | pub(crate) const FILE: i32 = 1; 7 | } 8 | 9 | pub(crate) mod file { 10 | pub(crate) const PACKAGE: i32 = 2; 11 | pub(crate) const DEPENDENCY: i32 = 3; 12 | pub(crate) const PUBLIC_DEPENDENCY: i32 = 10; 13 | pub(crate) const WEAK_DEPENDENCY: i32 = 11; 14 | pub(crate) const MESSAGE_TYPE: i32 = 4; 15 | pub(crate) const ENUM_TYPE: i32 = 5; 16 | pub(crate) const SERVICE: i32 = 6; 17 | pub(crate) const EXTENSION: i32 = 7; 18 | pub(crate) const OPTIONS: i32 = 8; 19 | pub(crate) const SYNTAX: i32 = 12; 20 | 21 | pub(crate) mod options { 22 | pub(crate) const JAVA_PACKAGE: i32 = 1; 23 | pub(crate) const JAVA_OUTER_CLASSNAME: i32 = 8; 24 | pub(crate) const JAVA_MULTIPLE_FILES: i32 = 10; 25 | pub(crate) const JAVA_GENERATE_EQUALS_AND_HASH: i32 = 20; 26 | pub(crate) const JAVA_STRING_CHECK_UTF8: i32 = 27; 27 | pub(crate) const OPTIMIZE_FOR: i32 = 9; 28 | pub(crate) const GO_PACKAGE: i32 = 11; 29 | pub(crate) const CC_GENERIC_SERVICES: i32 = 16; 30 | pub(crate) const JAVA_GENERIC_SERVICES: i32 = 17; 31 | pub(crate) const PY_GENERIC_SERVICES: i32 = 18; 32 | pub(crate) const PHP_GENERIC_SERVICES: i32 = 42; 33 | pub(crate) const DEPRECATED: i32 = 23; 34 | pub(crate) const CC_ENABLE_ARENAS: i32 = 31; 35 | pub(crate) const OBJC_CLASS_PREFIX: i32 = 36; 36 | pub(crate) const CSHARP_NAMESPACE: i32 = 37; 37 | pub(crate) const SWIFT_PREFIX: i32 = 39; 38 | pub(crate) const PHP_CLASS_PREFIX: i32 = 40; 39 | pub(crate) const PHP_NAMESPACE: i32 = 41; 40 | pub(crate) const PHP_METADATA_NAMESPACE: i32 = 44; 41 | pub(crate) const RUBY_PACKAGE: i32 = 45; 42 | pub(crate) const FILE_UNINTERPRETED_OPTION: i32 = 999; 43 | } 44 | } 45 | 46 | pub(crate) mod message { 47 | pub(crate) const NAME: i32 = 1; 48 | pub(crate) const FIELD: i32 = 2; 49 | pub(crate) const EXTENSION: i32 = 6; 50 | pub(crate) const NESTED_TYPE: i32 = 3; 51 | pub(crate) const ENUM_TYPE: i32 = 4; 52 | pub(crate) const EXTENSION_RANGE: i32 = 5; 53 | pub(crate) const OPTIONS: i32 = 7; 54 | pub(crate) const ONEOF_DECL: i32 = 8; 55 | pub(crate) const RESERVED_RANGE: i32 = 9; 56 | pub(crate) const RESERVED_NAME: i32 = 10; 57 | 58 | pub(crate) mod extension_range { 59 | pub(crate) const START: i32 = 1; 60 | pub(crate) const END: i32 = 2; 61 | pub(crate) const OPTIONS: i32 = 3; 62 | } 63 | 64 | pub(crate) mod reserved_range { 65 | pub(crate) const START: i32 = 1; 66 | pub(crate) const END: i32 = 2; 67 | } 68 | 69 | pub(crate) mod options { 70 | pub(crate) const MESSAGE_SET_WIRE_FORMAT: i32 = 1; 71 | pub(crate) const NO_STANDARD_DESCRIPTOR_ACCESSOR: i32 = 2; 72 | pub(crate) const DEPRECATED: i32 = 3; 73 | pub(crate) const MAP_ENTRY: i32 = 7; 74 | pub(crate) const UNINTERPRETED_OPTION: i32 = 999; 75 | } 76 | } 77 | 78 | pub(crate) mod field { 79 | pub(crate) const NAME: i32 = 1; 80 | pub(crate) const EXTENDEE: i32 = 2; 81 | pub(crate) const NUMBER: i32 = 3; 82 | pub(crate) const LABEL: i32 = 4; 83 | pub(crate) const TYPE: i32 = 5; 84 | pub(crate) const TYPE_NAME: i32 = 6; 85 | pub(crate) const DEFAULT_VALUE: i32 = 7; 86 | pub(crate) const JSON_NAME: i32 = 10; 87 | pub(crate) const OPTIONS: i32 = 8; 88 | 89 | pub(crate) mod options { 90 | pub(crate) const CTYPE: i32 = 1; 91 | pub(crate) const PACKED: i32 = 2; 92 | pub(crate) const JSTYPE: i32 = 6; 93 | pub(crate) const LAZY: i32 = 5; 94 | pub(crate) const DEPRECATED: i32 = 3; 95 | pub(crate) const WEAK: i32 = 10; 96 | pub(crate) const UNINTERPRETED_OPTION: i32 = 999; 97 | } 98 | } 99 | 100 | pub(crate) mod oneof { 101 | pub(crate) const NAME: i32 = 1; 102 | pub(crate) const OPTIONS: i32 = 2; 103 | } 104 | 105 | pub(crate) mod enum_ { 106 | pub(crate) const NAME: i32 = 1; 107 | pub(crate) const VALUE: i32 = 2; 108 | pub(crate) const OPTIONS: i32 = 3; 109 | pub(crate) const RESERVED_RANGE: i32 = 4; 110 | pub(crate) const RESERVED_NAME: i32 = 5; 111 | 112 | pub(crate) mod reserved_range { 113 | pub(crate) const START: i32 = 1; 114 | pub(crate) const END: i32 = 2; 115 | } 116 | 117 | pub(crate) mod options { 118 | pub(crate) const ALLOW_ALIAS: i32 = 2; 119 | pub(crate) const DEPRECATED: i32 = 3; 120 | pub(crate) const UNINTERPRETED_OPTION: i32 = 999; 121 | } 122 | } 123 | 124 | pub(crate) mod enum_value { 125 | pub(crate) const NAME: i32 = 1; 126 | pub(crate) const NUMBER: i32 = 2; 127 | pub(crate) const OPTIONS: i32 = 3; 128 | 129 | pub(crate) mod options { 130 | pub(crate) const DEPRECATED: i32 = 1; 131 | pub(crate) const UNINTERPRETED_OPTION: i32 = 999; 132 | } 133 | } 134 | 135 | pub(crate) mod service { 136 | pub(crate) const NAME: i32 = 1; 137 | pub(crate) const METHOD: i32 = 2; 138 | pub(crate) const OPTIONS: i32 = 3; 139 | 140 | pub(crate) mod options { 141 | pub(crate) const DEPRECATED: i32 = 33; 142 | pub(crate) const UNINTERPRETED_OPTION: i32 = 999; 143 | } 144 | } 145 | 146 | pub(crate) mod method { 147 | pub(crate) const NAME: i32 = 1; 148 | pub(crate) const INPUT_TYPE: i32 = 2; 149 | pub(crate) const OUTPUT_TYPE: i32 = 3; 150 | pub(crate) const OPTIONS: i32 = 4; 151 | pub(crate) const CLIENT_STREAMING: i32 = 5; 152 | pub(crate) const SERVER_STREAMING: i32 = 6; 153 | 154 | pub(crate) mod options { 155 | pub(crate) const DEPRECATED: i32 = 33; 156 | pub(crate) const IDEMPOTENCY_LEVEL: i32 = 34; 157 | pub(crate) const UNINTERPRETED_OPTION: i32 = 999; 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /prost-reflect/src/doctest.proto: -------------------------------------------------------------------------------- 1 | // Protobuf definitions used in doctests. file_descriptor_set.bin should be the compiled version of this file. 2 | syntax = "proto3"; 3 | 4 | import public "google/protobuf/empty.proto"; 5 | import public "google/protobuf/any.proto"; 6 | 7 | package package; 8 | 9 | message MyMessage { 10 | int32 foo = 1; 11 | 12 | oneof optional { 13 | int32 bar = 2; 14 | } 15 | 16 | MyMessage nested = 3; 17 | } 18 | -------------------------------------------------------------------------------- /prost-reflect/src/dynamic/serde/case.rs: -------------------------------------------------------------------------------- 1 | /// Convert `src` from snake case to camel case, returning an error if roundtripping 2 | /// back to snake case would not be possible. 3 | pub(crate) fn snake_case_to_camel_case(dst: &mut String, src: &str) -> Result<(), ()> { 4 | let mut ucase_next = false; 5 | for ch in src.chars() { 6 | if ch.is_ascii_uppercase() { 7 | return Err(()); 8 | } 9 | 10 | if ucase_next { 11 | let upper_ch = ch.to_ascii_uppercase(); 12 | if upper_ch == ch { 13 | return Err(()); 14 | } 15 | 16 | dst.push(upper_ch); 17 | ucase_next = false; 18 | } else if ch == '_' { 19 | ucase_next = true; 20 | } else { 21 | dst.push(ch) 22 | } 23 | } 24 | 25 | Ok(()) 26 | } 27 | 28 | pub(crate) fn camel_case_to_snake_case(result: &mut String, part: &str) -> Result<(), ()> { 29 | for ch in part.chars() { 30 | if ch.is_ascii_uppercase() { 31 | result.push('_'); 32 | result.push(ch.to_ascii_lowercase()); 33 | } else if ch == '_' { 34 | return Err(()); 35 | } else { 36 | result.push(ch); 37 | } 38 | } 39 | 40 | Ok(()) 41 | } 42 | 43 | #[cfg(test)] 44 | mod tests { 45 | use proptest::prelude::*; 46 | 47 | use super::*; 48 | 49 | #[test] 50 | fn snake_to_camel() { 51 | let mut buf = String::new(); 52 | 53 | snake_case_to_camel_case(&mut buf, "foo").unwrap(); 54 | assert_eq!(&buf, "foo"); 55 | buf.clear(); 56 | 57 | snake_case_to_camel_case(&mut buf, "foo_bar").unwrap(); 58 | assert_eq!(&buf, "fooBar"); 59 | buf.clear(); 60 | } 61 | 62 | #[test] 63 | fn camel_to_snake() { 64 | let mut buf = String::new(); 65 | 66 | camel_case_to_snake_case(&mut buf, "foo").unwrap(); 67 | assert_eq!(&buf, "foo"); 68 | buf.clear(); 69 | 70 | camel_case_to_snake_case(&mut buf, "fooBar").unwrap(); 71 | assert_eq!(&buf, "foo_bar"); 72 | buf.clear(); 73 | } 74 | 75 | #[test] 76 | fn bad_roundtrips() { 77 | let mut buf = String::new(); 78 | assert!(snake_case_to_camel_case(&mut buf, "fooBar").is_err()); 79 | assert!(snake_case_to_camel_case(&mut buf, "foo_3_bar").is_err()); 80 | assert!(snake_case_to_camel_case(&mut buf, "foo__bar").is_err()); 81 | } 82 | 83 | proptest! { 84 | #[test] 85 | fn roundtrip_cases(snake_case in "[a-zA-Z0-9]+") { 86 | let mut camel_case = String::new(); 87 | if snake_case_to_camel_case(&mut camel_case, &snake_case).is_ok() { 88 | let mut roundtripped_snake_case = String::new(); 89 | camel_case_to_snake_case(&mut roundtripped_snake_case, &camel_case).unwrap(); 90 | 91 | prop_assert_eq!(snake_case, roundtripped_snake_case); 92 | } 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /prost-reflect/src/file_descriptor_set.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andrewhickman/prost-reflect/826a3178981c2f30bb496f3a32a41f53e45003b4/prost-reflect/src/file_descriptor_set.bin -------------------------------------------------------------------------------- /prost-reflect/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!("../doc/intro.md")] 2 | #![doc = "# Example - decoding"] 3 | #![doc = include_str!("../doc/decoding.md")] 4 | #![cfg_attr(feature = "serde", doc = "# Example - JSON mapping")] 5 | #![cfg_attr(feature = "serde", doc = include_str!("../doc/json.md"))] 6 | #![cfg_attr(feature = "derive", doc = "# Implementing [`ReflectMessage`]")] 7 | #![cfg_attr(feature = "derive", doc = include_str!("../doc/reflect.md"))] 8 | #![cfg_attr(docsrs, feature(doc_cfg))] 9 | #![warn(missing_debug_implementations, missing_docs)] 10 | #![deny(unsafe_code)] 11 | 12 | mod descriptor; 13 | mod dynamic; 14 | mod reflect; 15 | 16 | pub use {prost, prost::bytes, prost_types}; 17 | 18 | pub use self::descriptor::{ 19 | Cardinality, DescriptorError, DescriptorPool, EnumDescriptor, EnumValueDescriptor, 20 | ExtensionDescriptor, FieldDescriptor, FileDescriptor, Kind, MessageDescriptor, 21 | MethodDescriptor, OneofDescriptor, ServiceDescriptor, Syntax, 22 | }; 23 | pub use self::dynamic::{DynamicMessage, MapKey, SetFieldError, UnknownField, Value}; 24 | pub use self::reflect::ReflectMessage; 25 | 26 | #[cfg(feature = "serde")] 27 | pub use self::dynamic::{DeserializeOptions, SerializeOptions}; 28 | 29 | #[cfg(feature = "derive")] 30 | #[cfg_attr(docsrs, doc(cfg(feature = "derive")))] 31 | pub use prost_reflect_derive::ReflectMessage; 32 | 33 | #[cfg(feature = "text-format")] 34 | pub use self::dynamic::text_format; 35 | -------------------------------------------------------------------------------- /prost-reflect/src/reflect/mod.rs: -------------------------------------------------------------------------------- 1 | mod wkt; 2 | 3 | pub(crate) use wkt::make_wkt_descriptor_pool; 4 | 5 | use prost::Message; 6 | 7 | use crate::{DynamicMessage, MessageDescriptor}; 8 | 9 | /// Trait for message types that support reflection. 10 | pub trait ReflectMessage: Message { 11 | /// Gets a [`MessageDescriptor`] describing the type of this message. 12 | fn descriptor(&self) -> MessageDescriptor; 13 | 14 | /// Converts this message into an instance of [`DynamicMessage`] by going 15 | /// through the byte representation. 16 | fn transcode_to_dynamic(&self) -> DynamicMessage 17 | where 18 | Self: Sized, 19 | { 20 | let mut message = DynamicMessage::new(self.descriptor()); 21 | // This can only fail if `self.descriptor` returns a descriptor incompatible with the 22 | // actual serialized bytes. 23 | message 24 | .transcode_from(self) 25 | .expect("error converting to dynamic message"); 26 | message 27 | } 28 | } 29 | 30 | impl ReflectMessage for Box 31 | where 32 | M: ReflectMessage, 33 | { 34 | fn descriptor(&self) -> MessageDescriptor { 35 | (**self).descriptor() 36 | } 37 | } 38 | 39 | #[test] 40 | fn assert_object_safe() { 41 | fn _foo(_: Box) {} 42 | } 43 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/dependency_not_imported.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: dep.proto 3 | syntax: proto3 4 | messageType: 5 | - name: Dependency 6 | - name: root.proto 7 | syntax: proto3 8 | messageType: 9 | - name: Root 10 | field: 11 | - name: dep 12 | number: 1 13 | label: LABEL_OPTIONAL 14 | typeName: Dependency -------------------------------------------------------------------------------- /prost-reflect/tests/data/dependency_resolution_transitive.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: dep.proto 3 | syntax: proto3 4 | dependency: 5 | - transitive.proto 6 | publicDependency: 7 | - 0 8 | - name: root.proto 9 | syntax: proto3 10 | dependency: 11 | - dep.proto 12 | messageType: 13 | - name: Root 14 | field: 15 | - name: dep 16 | number: 1 17 | label: LABEL_OPTIONAL 18 | typeName: Dependency 19 | - name: transitive.proto 20 | syntax: proto3 21 | messageType: 22 | - name: Dependency -------------------------------------------------------------------------------- /prost-reflect/tests/data/dependency_resolution_transitive2.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: file1.proto 3 | syntax: proto3 4 | package: bar 5 | messageType: 6 | - name: Foo 7 | - name: dep.proto 8 | syntax: proto3 9 | messageType: 10 | - name: Foo 11 | - name: file2.proto 12 | syntax: proto3 13 | package: bar 14 | dependency: 15 | - dep.proto 16 | messageType: 17 | - name: Bar 18 | field: 19 | - name: foo 20 | number: 1 21 | label: LABEL_OPTIONAL 22 | type: TYPE_MESSAGE 23 | typeName: Foo 24 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/dependency_resolution_transitive3.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: dep.proto 3 | syntax: proto3 4 | dependency: 5 | - transitive.proto 6 | - name: root.proto 7 | syntax: proto3 8 | dependency: 9 | - dep.proto 10 | messageType: 11 | - name: Root 12 | field: 13 | - name: dep 14 | number: 1 15 | label: LABEL_OPTIONAL 16 | typeName: Dependency 17 | - name: transitive.proto 18 | syntax: proto3 19 | messageType: 20 | - name: Dependency -------------------------------------------------------------------------------- /prost-reflect/tests/data/enum_default1.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | enumType: 4 | - name: Foo 5 | value: 6 | - name: DEFAULT 7 | number: 1 8 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/enum_default2.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | enumType: 4 | - name: Foo 5 | value: 6 | - name: DEFAULT 7 | number: 1 8 | syntax: proto3 9 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/enum_default3.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | enumType: 4 | - name: Foo 5 | value: 6 | - name: DEFAULT 7 | number: 0 8 | syntax: proto3 9 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/enum_duplicate_number1.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | enumType: 4 | - name: Enum 5 | value: 6 | - name: ZERO 7 | number: 0 8 | - name: ZERO2 9 | number: 0 10 | syntax: proto3 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/enum_duplicate_number2.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Message 5 | enumType: 6 | - name: Enum 7 | value: 8 | - name: ZERO 9 | number: 0 10 | - name: ZERO2 11 | number: 0 12 | options: 13 | uninterpretedOption: 14 | - name: 15 | - namePart: allow_alias 16 | isExtension: false 17 | identifierValue: 'false' 18 | syntax: proto3 19 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/enum_duplicate_number3.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | enumType: 4 | - name: Enum 5 | value: 6 | - name: ZERO 7 | number: 0 8 | - name: ZERO2 9 | number: 0 10 | options: 11 | uninterpretedOption: 12 | - name: 13 | - namePart: allow_alias 14 | isExtension: false 15 | identifierValue: 'true' 16 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/enum_field_invalid_default1.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Message 5 | field: 6 | - name: foo 7 | number: 1 8 | label: LABEL_OPTIONAL 9 | typeName: Foo 10 | defaultValue: ONE 11 | jsonName: foo 12 | enumType: 13 | - name: Foo 14 | value: 15 | - name: ZERO 16 | number: 0 17 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/enum_field_invalid_default2.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Message 5 | field: 6 | - name: foo 7 | number: 1 8 | label: LABEL_OPTIONAL 9 | typeName: Foo 10 | defaultValue: ONE 11 | jsonName: foo 12 | enumType: 13 | - name: Foo 14 | value: 15 | - name: ZERO 16 | number: 0 17 | - name: TWO 18 | number: 2 19 | - name: Bar 20 | value: 21 | - name: NONE 22 | number: 0 23 | - name: ONE 24 | number: 1 25 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/enum_field_invalid_default3.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: dep.proto 3 | package: foo 4 | enumType: 5 | - name: Foo 6 | value: 7 | - name: ZERO 8 | number: 1 9 | - name: root.proto 10 | dependency: 11 | - dep.proto 12 | messageType: 13 | - name: Bar 14 | field: 15 | - name: foo_field 16 | number: 1 17 | label: LABEL_OPTIONAL 18 | typeName: foo.Foo 19 | defaultValue: ONE 20 | jsonName: foo 21 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/enum_field_invalid_default4.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | package: foo 4 | messageType: 5 | - name: Message 6 | field: 7 | - name: foo 8 | number: 1 9 | label: LABEL_OPTIONAL 10 | typeName: Foo 11 | defaultValue: ONE 12 | jsonName: foo 13 | enumType: 14 | - name: Foo 15 | value: 16 | - name: ZERO 17 | number: 0 18 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/enum_field_invalid_default5.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | package: foo 4 | messageType: 5 | - name: Message 6 | field: 7 | - name: foo 8 | number: 1 9 | label: LABEL_OPTIONAL 10 | typeName: Foo 11 | defaultValue: ZERO 12 | jsonName: foo 13 | enumType: 14 | - name: Foo 15 | value: 16 | - name: ZERO 17 | number: 0 18 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/enum_field_invalid_default6.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | package: foo 4 | messageType: 5 | - name: Message 6 | field: 7 | - name: foo 8 | number: 1 9 | label: LABEL_OPTIONAL 10 | typeName: Foo 11 | defaultValue: ONE 12 | jsonName: foo 13 | enumType: 14 | - name: Foo 15 | value: 16 | - name: ZERO 17 | number: 0 18 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/enum_field_invalid_default7.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | package: foo 4 | messageType: 5 | - name: Message 6 | field: 7 | - name: foo 8 | number: 1 9 | label: LABEL_OPTIONAL 10 | typeName: Foo 11 | defaultValue: ZERO 12 | jsonName: foo 13 | enumType: 14 | - name: Foo 15 | value: 16 | - name: ZERO 17 | number: 0 18 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/enum_field_invalid_default8.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | package: foo 4 | messageType: 5 | - name: Message 6 | field: 7 | - name: foo 8 | number: 1 9 | label: LABEL_OPTIONAL 10 | typeName: Parent.Foo 11 | defaultValue: ONE 12 | jsonName: foo 13 | - name: Parent 14 | enumType: 15 | - name: Foo 16 | value: 17 | - name: ZERO 18 | number: 0 19 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/enum_field_invalid_default9.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | package: foo 4 | messageType: 5 | - name: Message 6 | field: 7 | - name: foo 8 | number: 1 9 | label: LABEL_OPTIONAL 10 | typeName: Parent.Foo 11 | defaultValue: ZERO 12 | jsonName: foo 13 | - name: Parent 14 | enumType: 15 | - name: Foo 16 | value: 17 | - name: ZERO 18 | number: 0 19 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/enum_reserved_range_overlap_with_value1.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | enumType: 4 | - name: Enum 5 | value: 6 | - name: ZERO 7 | number: 0 8 | reservedRange: 9 | - start: -5 10 | end: 5 11 | syntax: proto3 12 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/enum_reserved_range_overlap_with_value2.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | enumType: 4 | - name: Enum 5 | value: 6 | - name: ZERO 7 | number: 0 8 | - name: FIVE 9 | number: 5 10 | reservedRange: 11 | - start: 2 12 | end: 2147483647 13 | syntax: proto3 14 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/enum_reserved_range_overlap_with_value3.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | enumType: 4 | - name: Enum 5 | value: 6 | - name: ZERO 7 | number: 0 8 | - name: FIVE 9 | number: 5 10 | reservedRange: 11 | - start: 5 12 | end: 5 13 | syntax: proto3 14 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/extend_field_number_not_in_extensions1.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Message 5 | extensionRange: 6 | - start: 2 7 | end: 6 8 | extension: 9 | - name: a 10 | extendee: Message 11 | number: 1 12 | label: LABEL_OPTIONAL 13 | type: TYPE_INT32 14 | jsonName: a 15 | - name: b 16 | extendee: Message 17 | number: 6 18 | label: LABEL_REPEATED 19 | type: TYPE_INT32 20 | jsonName: b 21 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/extend_field_number_not_in_extensions2.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Message 5 | extensionRange: 6 | - start: 2 7 | end: 6 8 | extension: 9 | - name: a 10 | extendee: Message 11 | number: 1 12 | label: LABEL_OPTIONAL 13 | type: TYPE_INT32 14 | jsonName: a 15 | - name: b 16 | extendee: Message 17 | number: 6 18 | label: LABEL_REPEATED 19 | type: TYPE_INT32 20 | jsonName: b 21 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/extend_group_field.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Message 5 | extensionRange: 6 | - start: 1 7 | end: 2 8 | - name: Foo 9 | field: 10 | - name: bar 11 | number: 1 12 | label: LABEL_REQUIRED 13 | type: TYPE_INT32 14 | jsonName: bar 15 | extension: 16 | - name: foo 17 | extendee: Message 18 | number: 1 19 | label: LABEL_REPEATED 20 | type: TYPE_GROUP 21 | typeName: Foo 22 | jsonName: foo 23 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/field_default_invalid_type1.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Message 5 | field: 6 | - name: foo 7 | number: 1 8 | label: LABEL_OPTIONAL 9 | typeName: Foo 10 | defaultValue: '1' 11 | jsonName: foo 12 | enumType: 13 | - name: Foo 14 | value: 15 | - name: ZERO 16 | number: 0 17 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/field_default_invalid_type2.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Message 5 | field: 6 | - name: foo 7 | number: 1 8 | label: LABEL_OPTIONAL 9 | typeName: Foo 10 | defaultValue: '"ZERO"' 11 | jsonName: foo 12 | enumType: 13 | - name: Foo 14 | value: 15 | - name: ZERO 16 | number: 0 17 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/field_default_invalid_type3.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Message 5 | field: 6 | - name: foo 7 | number: 1 8 | label: LABEL_OPTIONAL 9 | typeName: Foo 10 | defaultValue: 'FALSE' 11 | jsonName: foo 12 | enumType: 13 | - name: Foo 14 | value: 15 | - name: ZERO 16 | number: 0 17 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/field_default_value1.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Message 5 | field: 6 | - name: foo 7 | number: 1 8 | label: LABEL_OPTIONAL 9 | typeName: Message 10 | defaultValue: '""' 11 | jsonName: foo 12 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/field_default_value2.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Message 5 | field: 6 | - name: default_float_exp 7 | number: 23 8 | label: LABEL_OPTIONAL 9 | type: TYPE_FLOAT 10 | defaultValue: '9000000' 11 | jsonName: defaultFloatExp 12 | - name: default_double_exp 13 | number: 24 14 | label: LABEL_OPTIONAL 15 | type: TYPE_DOUBLE 16 | defaultValue: '90000000000000000000000' 17 | jsonName: defaultDoubleExp 18 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/field_set_json_name.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Message 5 | field: 6 | - name: no_json_name 7 | number: 1 8 | label: LABEL_OPTIONAL 9 | type: TYPE_INT32 10 | - name: no_json_name2 11 | number: 2 12 | label: LABEL_OPTIONAL 13 | type: TYPE_INT32 14 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/generate_group_message_name_conflict.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Foo 5 | field: 6 | - name: baz 7 | number: 1 8 | label: LABEL_OPTIONAL 9 | type: TYPE_GROUP 10 | typeName: Baz 11 | jsonName: baz 12 | nestedType: 13 | - name: Baz 14 | enumType: 15 | - name: Baz 16 | value: 17 | - name: ZERO 18 | number: 0 19 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/generate_map_entry_message_name_conflict.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Foo 5 | field: 6 | - name: baz 7 | number: 1 8 | label: LABEL_REPEATED 9 | type: TYPE_MESSAGE 10 | typeName: BazEntry 11 | jsonName: baz 12 | nestedType: 13 | - name: BazEntry 14 | field: 15 | - name: key 16 | number: 1 17 | label: LABEL_OPTIONAL 18 | type: TYPE_UINT32 19 | jsonName: key 20 | - name: value 21 | number: 2 22 | label: LABEL_OPTIONAL 23 | type: TYPE_BYTES 24 | jsonName: value 25 | options: 26 | mapEntry: true 27 | enumType: 28 | - name: BazEntry 29 | value: 30 | - name: ZERO 31 | number: 0 32 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/generate_synthetic_oneof_name_conflict.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Foo 5 | field: 6 | - name: val 7 | number: 1 8 | label: LABEL_OPTIONAL 9 | type: TYPE_FIXED64 10 | oneofIndex: 0 11 | jsonName: val 12 | proto3Optional: true 13 | nestedType: 14 | - name: _val 15 | oneofDecl: 16 | - name: _val 17 | syntax: proto3 18 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/invalid_message_number1.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Foo 5 | field: 6 | - name: i 7 | number: 19000 8 | label: LABEL_OPTIONAL 9 | type: TYPE_INT32 10 | jsonName: i 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/invalid_message_number2.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Foo 5 | field: 6 | - name: i 7 | number: 19999 8 | label: LABEL_OPTIONAL 9 | type: TYPE_INT32 10 | jsonName: i 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/invalid_service_type1.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Message 5 | enumType: 6 | - name: Enum 7 | value: 8 | - name: ZERO 9 | number: 0 10 | service: 11 | - name: Service 12 | method: 13 | - name: rpc 14 | inputType: .Enum 15 | outputType: .Message 16 | syntax: proto3 17 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/invalid_service_type2.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Message 5 | enumType: 6 | - name: Enum 7 | value: 8 | - name: ZERO 9 | number: 0 10 | service: 11 | - name: Service 12 | method: 13 | - name: rpc 14 | inputType: .Message 15 | outputType: .Enum 16 | syntax: proto3 17 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/invalid_service_type3.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Message 5 | service: 6 | - name: Service 7 | method: 8 | - name: rpc 9 | inputType: .Message 10 | outputType: .Service 11 | syntax: proto3 12 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/message_field_duplicate_number1.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Message 5 | field: 6 | - name: foo 7 | number: 1 8 | label: LABEL_OPTIONAL 9 | type: TYPE_INT32 10 | jsonName: foo 11 | - name: bar 12 | number: 1 13 | label: LABEL_OPTIONAL 14 | type: TYPE_INT32 15 | jsonName: bar 16 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/message_field_duplicate_number2.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Message 5 | nestedType: 6 | - name: Nested 7 | field: 8 | - name: foo 9 | number: 1 10 | label: LABEL_OPTIONAL 11 | type: TYPE_INT32 12 | jsonName: foo 13 | - name: bar 14 | number: 1 15 | label: LABEL_OPTIONAL 16 | type: TYPE_INT32 17 | jsonName: bar 18 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/message_reserved_range_message_set1.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Foo 5 | options: 6 | uninterpretedOption: 7 | - name: 8 | - namePart: message_set_wire_format 9 | isExtension: false 10 | identifierValue: 'true' 11 | reservedRange: 12 | - start: 1 13 | end: 2147483647 14 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/message_reserved_range_message_set2.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Foo 5 | extensionRange: 6 | - start: 1 7 | end: 2147483647 8 | options: 9 | uninterpretedOption: 10 | - name: 11 | - namePart: message_set_wire_format 12 | isExtension: false 13 | identifierValue: 'true' 14 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/message_reserved_range_overlap_with_field1.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Message 5 | field: 6 | - name: field 7 | number: 2 8 | label: LABEL_OPTIONAL 9 | type: TYPE_INT32 10 | jsonName: field 11 | reservedRange: 12 | - start: 2 13 | end: 3 14 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/message_reserved_range_overlap_with_field2.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Message 5 | field: 6 | - name: field 7 | number: 2 8 | label: LABEL_OPTIONAL 9 | type: TYPE_INT32 10 | jsonName: field 11 | extensionRange: 12 | - start: 1 13 | end: 6 14 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/name_collision1.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Message 5 | - name: Message 6 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/name_collision2.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Message 5 | enumType: 6 | - name: Message 7 | value: 8 | - name: ZERO 9 | number: 1 10 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/name_collision3.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Message 5 | field: 6 | - name: foo 7 | number: 1 8 | label: LABEL_OPTIONAL 9 | type: TYPE_INT32 10 | jsonName: foo 11 | enumType: 12 | - name: foo 13 | value: 14 | - name: ZERO 15 | number: 1 16 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/name_collision4.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: dep.proto 3 | package: foo 4 | - name: root.proto 5 | dependency: 6 | - dep.proto 7 | messageType: 8 | - name: foo 9 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/name_collision5.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: dep.proto 3 | package: foo.bar 4 | - name: root.proto 5 | dependency: 6 | - dep.proto 7 | messageType: 8 | - name: foo 9 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/name_conflict1.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Foo 5 | - name: Foo 6 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/name_conflict2.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Foo 5 | enumType: 6 | - name: Foo 7 | value: 8 | - name: ZERO 9 | number: 0 10 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/name_conflict3.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Foo 5 | enumType: 6 | - name: Bar 7 | value: 8 | - name: Foo 9 | number: 1 10 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/name_conflict_field_camel_case1.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | syntax: proto3 4 | messageType: 5 | - name: Foo 6 | field: 7 | - name: foo_bar 8 | number: 1 9 | label: LABEL_OPTIONAL 10 | type: TYPE_INT32 11 | oneofIndex: 0 12 | jsonName: fooBar 13 | proto3Optional: true 14 | - name: foobar 15 | number: 2 16 | label: LABEL_OPTIONAL 17 | type: TYPE_INT32 18 | oneofIndex: 1 19 | jsonName: foobar 20 | proto3Optional: true 21 | oneofDecl: 22 | - name: _foo_bar 23 | - name: _foobar 24 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/name_conflict_field_camel_case2.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | syntax: proto3 4 | messageType: 5 | - name: Foo 6 | field: 7 | - name: foo 8 | number: 1 9 | label: LABEL_OPTIONAL 10 | type: TYPE_INT32 11 | oneofIndex: 0 12 | jsonName: foo 13 | proto3Optional: true 14 | - name: FOO 15 | number: 2 16 | label: LABEL_OPTIONAL 17 | type: TYPE_INT32 18 | oneofIndex: 1 19 | jsonName: FOO 20 | proto3Optional: true 21 | oneofDecl: 22 | - name: _foo 23 | - name: _FOO 24 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/name_conflict_field_camel_case3.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Foo 5 | field: 6 | - name: foo 7 | number: 1 8 | label: LABEL_OPTIONAL 9 | type: TYPE_INT32 10 | jsonName: foo 11 | - name: FOO 12 | number: 2 13 | label: LABEL_OPTIONAL 14 | type: TYPE_INT32 15 | jsonName: FOO 16 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/name_conflict_in_imported_files.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: dep1.proto 3 | messageType: 4 | - name: Foo 5 | - name: dep2.proto 6 | messageType: 7 | - name: Foo 8 | - name: root.proto 9 | dependency: 10 | - dep1.proto 11 | - dep2.proto 12 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/name_conflict_package1.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: dep.proto 3 | package: foo 4 | - name: root.proto 5 | dependency: 6 | - dep.proto 7 | messageType: 8 | - name: foo -------------------------------------------------------------------------------- /prost-reflect/tests/data/name_conflict_package2.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: dep.proto 3 | messageType: 4 | - name: foo 5 | - name: root.proto 6 | package: foo 7 | dependency: 8 | - dep.proto -------------------------------------------------------------------------------- /prost-reflect/tests/data/name_conflict_package3.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: dep.proto 3 | package: foo 4 | - name: root.proto 5 | package: foo 6 | dependency: 7 | - dep.proto -------------------------------------------------------------------------------- /prost-reflect/tests/data/name_conflict_with_import.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: dep.proto 3 | messageType: 4 | - name: Foo 5 | - name: root.proto 6 | dependency: 7 | - dep.proto 8 | - dep2.proto 9 | messageType: 10 | - name: Foo 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/name_resolution1.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: dep.proto 3 | package: foo.bar 4 | messageType: 5 | - name: FooBar 6 | - name: root.proto 7 | dependency: 8 | - dep.proto 9 | messageType: 10 | - name: Foo 11 | field: 12 | - name: foobar 13 | number: 1 14 | label: LABEL_OPTIONAL 15 | typeName: .foo.FooBar 16 | jsonName: foobar 17 | syntax: proto3 18 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/name_resolution2.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: dep.proto 3 | package: foo.bar 4 | messageType: 5 | - name: FooBar 6 | - name: root.proto 7 | dependency: 8 | - dep.proto 9 | messageType: 10 | - name: Foo 11 | field: 12 | - name: foobar 13 | number: 1 14 | label: LABEL_OPTIONAL 15 | typeName: .FooBar 16 | jsonName: foobar 17 | syntax: proto3 18 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/name_resolution3.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: include/package.proto 3 | package: foo 4 | messageType: 5 | - name: Foo 6 | syntax: proto3 7 | - name: include/no_package.proto 8 | messageType: 9 | - name: Bar 10 | syntax: proto3 11 | - name: name_resolution.proto 12 | package: foo.bar 13 | dependency: 14 | - include/package.proto 15 | - include/no_package.proto 16 | messageType: 17 | - name: FooBar 18 | - name: Names 19 | field: 20 | - name: field1 21 | number: 1 22 | label: LABEL_OPTIONAL 23 | type: TYPE_MESSAGE 24 | typeName: ".foo.bar.FooBar" 25 | jsonName: field1 26 | - name: field2 27 | number: 2 28 | label: LABEL_OPTIONAL 29 | type: TYPE_MESSAGE 30 | typeName: "foo.bar.FooBar" 31 | jsonName: field2 32 | - name: field3 33 | number: 3 34 | label: LABEL_OPTIONAL 35 | type: TYPE_MESSAGE 36 | typeName: "bar.FooBar" 37 | jsonName: field3 38 | - name: field4 39 | number: 4 40 | label: LABEL_OPTIONAL 41 | type: TYPE_MESSAGE 42 | typeName: "FooBar" 43 | jsonName: field4 44 | - name: field5 45 | number: 5 46 | label: LABEL_OPTIONAL 47 | type: TYPE_MESSAGE 48 | typeName: ".foo.Foo" 49 | jsonName: field5 50 | - name: field6 51 | number: 6 52 | label: LABEL_OPTIONAL 53 | type: TYPE_MESSAGE 54 | typeName: "foo.Foo" 55 | jsonName: field6 56 | - name: field7 57 | number: 7 58 | label: LABEL_OPTIONAL 59 | type: TYPE_MESSAGE 60 | typeName: "Foo" 61 | jsonName: field7 62 | - name: field8 63 | number: 8 64 | label: LABEL_OPTIONAL 65 | type: TYPE_MESSAGE 66 | typeName: ".Bar" 67 | jsonName: field8 68 | - name: field9 69 | number: 9 70 | label: LABEL_OPTIONAL 71 | type: TYPE_MESSAGE 72 | typeName: "Bar" 73 | jsonName: field9 74 | nestedType: 75 | - name: Nested 76 | field: 77 | - name: field1 78 | number: 1 79 | label: LABEL_OPTIONAL 80 | type: TYPE_MESSAGE 81 | typeName: ".foo.bar.FooBar" 82 | jsonName: field1 83 | - name: field2 84 | number: 2 85 | label: LABEL_OPTIONAL 86 | type: TYPE_MESSAGE 87 | typeName: "foo.bar.FooBar" 88 | jsonName: field2 89 | - name: field3 90 | number: 3 91 | label: LABEL_OPTIONAL 92 | type: TYPE_MESSAGE 93 | typeName: "bar.FooBar" 94 | jsonName: field3 95 | - name: field4 96 | number: 4 97 | label: LABEL_OPTIONAL 98 | type: TYPE_MESSAGE 99 | typeName: "FooBar" 100 | jsonName: field4 101 | - name: field5 102 | number: 5 103 | label: LABEL_OPTIONAL 104 | type: TYPE_MESSAGE 105 | typeName: ".foo.Foo" 106 | jsonName: field5 107 | - name: field6 108 | number: 6 109 | label: LABEL_OPTIONAL 110 | type: TYPE_MESSAGE 111 | typeName: "foo.Foo" 112 | jsonName: field6 113 | - name: field7 114 | number: 7 115 | label: LABEL_OPTIONAL 116 | type: TYPE_MESSAGE 117 | typeName: "Foo" 118 | jsonName: field7 119 | - name: field8 120 | number: 8 121 | label: LABEL_OPTIONAL 122 | type: TYPE_MESSAGE 123 | typeName: ".Bar" 124 | jsonName: field8 125 | - name: field9 126 | number: 9 127 | label: LABEL_OPTIONAL 128 | type: TYPE_MESSAGE 129 | typeName: "Bar" 130 | jsonName: field9 131 | syntax: proto3 132 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/name_resolution4.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: dep.proto 3 | package: foo.bar 4 | messageType: 5 | - name: FooBar 6 | - name: root.proto 7 | package: com.foo.bar 8 | dependency: 9 | - dep.proto 10 | messageType: 11 | - name: Foo 12 | field: 13 | - name: foobar 14 | number: 1 15 | label: LABEL_OPTIONAL 16 | typeName: foo.FooBar 17 | jsonName: foobar 18 | syntax: proto3 19 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/name_resolution5.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: root.proto 3 | messageType: 4 | - name: Parent 5 | field: 6 | - name: ChildMessage 7 | number: 1 8 | label: LABEL_OPTIONAL 9 | type: TYPE_MESSAGE 10 | typeName: ChildMessage 11 | jsonName: ChildMessage 12 | - name: ChildEnum 13 | number: 2 14 | label: LABEL_OPTIONAL 15 | type: TYPE_ENUM 16 | typeName: ChildEnum 17 | jsonName: ChildEnum 18 | - name: ChildMessage 19 | field: 20 | - name: field 21 | number: 1 22 | label: LABEL_OPTIONAL 23 | type: TYPE_STRING 24 | jsonName: field 25 | enumType: 26 | - name: ChildEnum 27 | value: 28 | - name: UNKNOWN 29 | number: 0 30 | - name: A 31 | number: 1 32 | - name: B 33 | number: 2 34 | syntax: proto3 35 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/name_resolution6.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: dep.proto 3 | package: foo 4 | messageType: 5 | - name: Foo 6 | syntax: proto3 7 | - name: root.proto 8 | package: sample 9 | dependency: 10 | - dep.proto 11 | messageType: 12 | - name: Sample 13 | field: 14 | - name: foo 15 | number: 2 16 | label: LABEL_OPTIONAL 17 | type: TYPE_MESSAGE 18 | typeName: foo.Foo 19 | jsonName: foo 20 | syntax: proto3 21 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/oneof_group_field.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Message 5 | field: 6 | - name: group 7 | number: 1 8 | label: LABEL_OPTIONAL 9 | type: TYPE_GROUP 10 | typeName: Group 11 | oneofIndex: 0 12 | jsonName: group 13 | nestedType: 14 | - name: Group 15 | field: 16 | - name: bar 17 | number: 1 18 | label: LABEL_REPEATED 19 | type: TYPE_FLOAT 20 | jsonName: bar 21 | oneofDecl: 22 | - name: oneof 23 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_already_set.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Message 5 | field: 6 | - name: foo 7 | number: 1 8 | label: LABEL_OPTIONAL 9 | type: TYPE_INT32 10 | options: 11 | uninterpretedOption: 12 | - name: 13 | - namePart: deprecated 14 | isExtension: false 15 | identifierValue: 'true' 16 | - name: 17 | - namePart: deprecated 18 | isExtension: false 19 | identifierValue: 'false' 20 | jsonName: foo 21 | syntax: proto3 22 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_extension_dependency_not_imported.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | options: 4 | uninterpretedOption: 5 | - name: 6 | - namePart: unknown.extension 7 | isExtension: true 8 | positiveIntValue: '1' 9 | - name: dep.proto 10 | package: unknown 11 | dependency: 12 | - google/protobuf/descriptor.proto 13 | extension: 14 | - name: extension 15 | extendee: google.protobuf.FileOptions 16 | number: 1001 17 | label: LABEL_OPTIONAL 18 | type: TYPE_INT32 19 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_extension_dependency_transitive.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | dependency: 4 | - dep.proto 5 | options: 6 | uninterpretedOption: 7 | - name: 8 | - namePart: unknown.extension 9 | isExtension: true 10 | positiveIntValue: '1' 11 | - name: dep.proto 12 | dependency: 13 | - transitive.proto 14 | publicDependency: 15 | - 0 16 | - name: transitive.proto 17 | package: unknown 18 | dependency: 19 | - google/protobuf/descriptor.proto 20 | extension: 21 | - name: extension 22 | extendee: google.protobuf.FileOptions 23 | number: 1001 24 | label: LABEL_OPTIONAL 25 | type: TYPE_INT32 26 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_extension_invalid_type.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | options: 4 | uninterpretedOption: 5 | - name: 6 | - namePart: extension 7 | isExtension: true 8 | positiveIntValue: '1' 9 | messageType: 10 | - name: extension -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_extension_wrong_extendee.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | dependency: 4 | - dep.proto 5 | options: 6 | uninterpretedOption: 7 | - name: 8 | - namePart: extension 9 | isExtension: true 10 | positiveIntValue: '1' 11 | dependency: 12 | - google/protobuf/descriptor.proto 13 | extension: 14 | - name: extension 15 | extendee: google.protobuf.FieldOptions 16 | number: 1001 17 | label: LABEL_OPTIONAL 18 | type: TYPE_INT32 19 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_map_entry_set_explicitly.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: Foo 5 | options: 6 | uninterpretedOption: 7 | - name: 8 | - namePart: map_entry 9 | isExtension: false 10 | identifierValue: 'true' 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_resolution1.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | dependency: 4 | - google/protobuf/descriptor.proto 5 | messageType: 6 | - name: Foo 7 | field: 8 | - name: a 9 | number: 1 10 | label: LABEL_OPTIONAL 11 | type: TYPE_INT32 12 | jsonName: a 13 | - name: b 14 | number: 2 15 | label: LABEL_OPTIONAL 16 | type: TYPE_INT32 17 | jsonName: b 18 | extension: 19 | - name: foo 20 | extendee: google.protobuf.FileOptions 21 | number: 1001 22 | label: LABEL_OPTIONAL 23 | typeName: Foo 24 | jsonName: foo 25 | options: 26 | uninterpretedOption: 27 | - name: 28 | - namePart: foo 29 | isExtension: true 30 | - namePart: a 31 | isExtension: false 32 | positiveIntValue: '1' 33 | - name: 34 | - namePart: optimize_for 35 | isExtension: false 36 | identifierValue: SPEED 37 | - name: 38 | - namePart: foo 39 | isExtension: true 40 | - namePart: b 41 | isExtension: false 42 | positiveIntValue: '1' 43 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_resolution10.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | dependency: 4 | - google/protobuf/descriptor.proto 5 | messageType: 6 | - name: Foo 7 | field: 8 | - name: a 9 | number: 1 10 | label: LABEL_OPTIONAL 11 | type: TYPE_GROUP 12 | typeName: A 13 | jsonName: a 14 | nestedType: 15 | - name: A 16 | field: 17 | - name: key 18 | number: 1 19 | label: LABEL_OPTIONAL 20 | type: TYPE_FLOAT 21 | jsonName: key 22 | extension: 23 | - name: a 24 | extendee: google.protobuf.FileOptions 25 | number: 1001 26 | label: LABEL_REPEATED 27 | typeName: Foo.A 28 | jsonName: a 29 | options: 30 | uninterpretedOption: 31 | - name: 32 | - namePart: a 33 | isExtension: true 34 | aggregateValue: 'key : - inf ;' 35 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_resolution11.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | dependency: 4 | - google/protobuf/any.proto 5 | - google/protobuf/descriptor.proto 6 | messageType: 7 | - name: Foo 8 | field: 9 | - name: foo 10 | number: 1 11 | label: LABEL_OPTIONAL 12 | type: TYPE_STRING 13 | jsonName: foo 14 | extension: 15 | - name: a 16 | extendee: google.protobuf.FileOptions 17 | number: 1001 18 | label: LABEL_REPEATED 19 | typeName: google.protobuf.Any 20 | jsonName: a 21 | options: 22 | uninterpretedOption: 23 | - name: 24 | - namePart: a 25 | isExtension: true 26 | aggregateValue: '[ type . googleapis . com / Foo ] { foo : "bar" }' 27 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_resolution12.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | dependency: 4 | - google/protobuf/descriptor.proto 5 | messageType: 6 | - name: Foo 7 | field: 8 | - name: foo 9 | number: 1 10 | label: LABEL_OPTIONAL 11 | typeName: Foo 12 | jsonName: foo 13 | extension: 14 | - name: a 15 | extendee: google.protobuf.FileOptions 16 | number: 1001 17 | label: LABEL_REPEATED 18 | typeName: Foo 19 | jsonName: a 20 | options: 21 | uninterpretedOption: 22 | - name: 23 | - namePart: a 24 | isExtension: true 25 | aggregateValue: 'foo : < >' 26 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_resolution13.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | dependency: 4 | - google/protobuf/descriptor.proto 5 | messageType: 6 | - name: Foo 7 | field: 8 | - name: foo 9 | number: 1 10 | label: LABEL_REPEATED 11 | type: TYPE_INT32 12 | jsonName: foo 13 | extension: 14 | - name: a 15 | extendee: google.protobuf.FileOptions 16 | number: 1001 17 | label: LABEL_REPEATED 18 | typeName: Foo 19 | jsonName: a 20 | options: 21 | uninterpretedOption: 22 | - name: 23 | - namePart: a 24 | isExtension: true 25 | aggregateValue: 'foo : [ 1 , 2 , 3 ]' 26 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_resolution14.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | dependency: 4 | - google/protobuf/descriptor.proto 5 | messageType: 6 | - name: Foo 7 | field: 8 | - name: foo 9 | number: 1 10 | label: LABEL_REPEATED 11 | type: TYPE_INT32 12 | jsonName: foo 13 | extension: 14 | - name: a 15 | extendee: google.protobuf.FileOptions 16 | number: 1001 17 | label: LABEL_REPEATED 18 | typeName: Foo 19 | jsonName: a 20 | options: 21 | uninterpretedOption: 22 | - name: 23 | - namePart: a 24 | isExtension: true 25 | aggregateValue: 'foo : 1 foo : 2 foo : 3' 26 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_resolution15.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | dependency: 4 | - google/protobuf/descriptor.proto 5 | messageType: 6 | - name: Foo 7 | field: 8 | - name: foo 9 | number: 1 10 | label: LABEL_OPTIONAL 11 | type: TYPE_GROUP 12 | typeName: Foo 13 | jsonName: foo 14 | nestedType: 15 | - name: Foo 16 | extension: 17 | - name: a 18 | extendee: google.protobuf.FileOptions 19 | number: 1001 20 | label: LABEL_REPEATED 21 | typeName: Foo 22 | jsonName: a 23 | options: 24 | uninterpretedOption: 25 | - name: 26 | - namePart: a 27 | isExtension: true 28 | aggregateValue: Foo { } 29 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_resolution16.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | dependency: 4 | - google/protobuf/descriptor.proto 5 | messageType: 6 | - name: Foo 7 | field: 8 | - name: foo 9 | number: 1 10 | label: LABEL_OPTIONAL 11 | type: TYPE_GROUP 12 | typeName: Foo 13 | jsonName: foo 14 | nestedType: 15 | - name: Foo 16 | extension: 17 | - name: a 18 | extendee: google.protobuf.FileOptions 19 | number: 1001 20 | label: LABEL_REPEATED 21 | typeName: Foo 22 | jsonName: a 23 | options: 24 | uninterpretedOption: 25 | - name: 26 | - namePart: a 27 | isExtension: true 28 | aggregateValue: 'Foo : { }' 29 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_resolution17.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | dependency: 4 | - google/protobuf/descriptor.proto 5 | messageType: 6 | - name: Foo 7 | field: 8 | - name: foo 9 | number: 1 10 | label: LABEL_REPEATED 11 | type: TYPE_INT32 12 | jsonName: foo 13 | - name: bar 14 | number: 2 15 | label: LABEL_OPTIONAL 16 | type: TYPE_INT32 17 | jsonName: bar 18 | extension: 19 | - name: a 20 | extendee: google.protobuf.FileOptions 21 | number: 1001 22 | label: LABEL_OPTIONAL 23 | typeName: Foo 24 | jsonName: a 25 | options: 26 | uninterpretedOption: 27 | - name: 28 | - namePart: a 29 | isExtension: true 30 | aggregateValue: 'foo : 1' 31 | - name: 32 | - namePart: a 33 | isExtension: true 34 | - namePart: foo 35 | isExtension: false 36 | positiveIntValue: '2' 37 | - name: 38 | - namePart: a 39 | isExtension: true 40 | - namePart: bar 41 | isExtension: false 42 | positiveIntValue: '2' 43 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_resolution18.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | dependency: 4 | - google/protobuf/descriptor.proto 5 | messageType: 6 | - name: Foo 7 | field: 8 | - name: foo 9 | number: 1 10 | label: LABEL_REPEATED 11 | type: TYPE_INT32 12 | jsonName: foo 13 | - name: bar 14 | number: 2 15 | label: LABEL_OPTIONAL 16 | type: TYPE_INT32 17 | jsonName: bar 18 | extension: 19 | - name: a 20 | extendee: google.protobuf.FileOptions 21 | number: 1001 22 | label: LABEL_REPEATED 23 | typeName: Foo 24 | jsonName: a 25 | options: 26 | uninterpretedOption: 27 | - name: 28 | - namePart: a 29 | isExtension: true 30 | aggregateValue: 'foo : 1' 31 | - name: 32 | - namePart: a 33 | isExtension: true 34 | - namePart: foo 35 | isExtension: false 36 | positiveIntValue: '2' 37 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_resolution19.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | package: google.protobuf 4 | messageType: 5 | - name: FileOptions 6 | field: 7 | - name: java_outer_classname 8 | number: 1 9 | label: LABEL_OPTIONAL 10 | type: TYPE_STRING 11 | oneofIndex: 0 12 | jsonName: javaOuterClassname 13 | proto3Optional: true 14 | oneofDecl: 15 | - name: _java_outer_classname 16 | options: 17 | uninterpretedOption: 18 | - name: 19 | - namePart: java_outer_classname 20 | isExtension: false 21 | stringValue: Q2xhc3NOYW1l 22 | syntax: proto3 23 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_resolution2.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | dependency: 4 | - google/protobuf/descriptor.proto 5 | messageType: 6 | - name: Hello 7 | field: 8 | - name: bar 9 | number: 1 10 | label: LABEL_OPTIONAL 11 | type: TYPE_INT32 12 | oneofIndex: 0 13 | jsonName: bar 14 | oneofDecl: 15 | - name: something 16 | options: 17 | uninterpretedOption: 18 | - name: 19 | - namePart: my_option 20 | isExtension: true 21 | positiveIntValue: '54321' 22 | extension: 23 | - name: my_option 24 | extendee: google.protobuf.OneofOptions 25 | number: 12345 26 | label: LABEL_OPTIONAL 27 | type: TYPE_INT32 28 | jsonName: myOption 29 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_resolution20.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: dep.proto 3 | package: dep 4 | dependency: 5 | - google/protobuf/descriptor.proto 6 | extension: 7 | - name: ext 8 | extendee: google.protobuf.FileOptions 9 | number: 1001 10 | label: LABEL_REPEATED 11 | type: TYPE_INT32 12 | jsonName: ext 13 | options: 14 | uninterpretedOption: 15 | - name: 16 | - namePart: ext 17 | isExtension: true 18 | positiveIntValue: '1' 19 | - name: 20 | - namePart: dep.ext 21 | isExtension: true 22 | positiveIntValue: '2' 23 | - name: 24 | - namePart: .dep.ext 25 | isExtension: true 26 | positiveIntValue: '3' 27 | syntax: proto3 28 | - name: root.proto 29 | dependency: 30 | - dep.proto 31 | - google/protobuf/descriptor.proto 32 | options: 33 | uninterpretedOption: 34 | - name: 35 | - namePart: dep.ext 36 | isExtension: true 37 | positiveIntValue: '4' 38 | - name: 39 | - namePart: .dep.ext 40 | isExtension: true 41 | positiveIntValue: '5' 42 | syntax: proto3 43 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_resolution21.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | dependency: 4 | - google/protobuf/descriptor.proto 5 | messageType: 6 | - name: Foo 7 | extension: 8 | - name: ext 9 | extendee: google.protobuf.MessageOptions 10 | number: 1001 11 | label: LABEL_OPTIONAL 12 | type: TYPE_STRING 13 | jsonName: ext 14 | proto3Optional: true 15 | options: 16 | uninterpretedOption: 17 | - name: 18 | - namePart: ext 19 | isExtension: true 20 | stringValue: Zm9v 21 | - name: Bar 22 | options: 23 | uninterpretedOption: 24 | - name: 25 | - namePart: Foo.ext 26 | isExtension: true 27 | stringValue: YmFy 28 | syntax: proto3 29 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_resolution22.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | dependency: 4 | - google/protobuf/descriptor.proto 5 | messageType: 6 | - name: Map 7 | field: 8 | - name: map 9 | number: 1 10 | label: LABEL_REPEATED 11 | type: TYPE_MESSAGE 12 | typeName: MapEntry 13 | jsonName: map 14 | nestedType: 15 | - name: MapEntry 16 | field: 17 | - name: key 18 | number: 1 19 | label: LABEL_OPTIONAL 20 | type: TYPE_STRING 21 | jsonName: key 22 | - name: value 23 | number: 2 24 | label: LABEL_OPTIONAL 25 | type: TYPE_INT32 26 | jsonName: value 27 | options: 28 | mapEntry: true 29 | extension: 30 | - name: ext 31 | extendee: google.protobuf.FileOptions 32 | number: 1001 33 | label: LABEL_OPTIONAL 34 | typeName: Map 35 | jsonName: ext 36 | options: 37 | uninterpretedOption: 38 | - name: 39 | - namePart: ext 40 | isExtension: true 41 | aggregateValue: 'map : { key : "a" , value : 1 } map : { key : "b" , value : 2 } map : { key : "c" , value : 3 }' 42 | syntax: proto3 43 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_resolution23.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | dependency: 4 | - google/protobuf/descriptor.proto 5 | messageType: 6 | - name: Map 7 | field: 8 | - name: map 9 | number: 1 10 | label: LABEL_REPEATED 11 | type: TYPE_MESSAGE 12 | typeName: MapEntry 13 | jsonName: map 14 | nestedType: 15 | - name: MapEntry 16 | field: 17 | - name: key 18 | number: 1 19 | label: LABEL_OPTIONAL 20 | type: TYPE_STRING 21 | jsonName: key 22 | - name: value 23 | number: 2 24 | label: LABEL_OPTIONAL 25 | type: TYPE_INT32 26 | jsonName: value 27 | options: 28 | mapEntry: true 29 | extension: 30 | - name: ext 31 | extendee: google.protobuf.FileOptions 32 | number: 1001 33 | label: LABEL_OPTIONAL 34 | typeName: Map 35 | jsonName: ext 36 | options: 37 | uninterpretedOption: 38 | - name: 39 | - namePart: ext 40 | isExtension: true 41 | - namePart: map 42 | isExtension: false 43 | aggregateValue: 'key : "a" , value : 1' 44 | - name: 45 | - namePart: ext 46 | isExtension: true 47 | - namePart: map 48 | isExtension: false 49 | aggregateValue: 'key : "b" , value : 2' 50 | - name: 51 | - namePart: ext 52 | isExtension: true 53 | - namePart: map 54 | isExtension: false 55 | aggregateValue: 'key : "c" , value : 3' 56 | syntax: proto3 57 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_resolution24.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | messageType: 4 | - name: FieldDescriptorProto 5 | field: 6 | - name: double_value 7 | number: 1 8 | jsonName: doubleValue 9 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_resolution3.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | package: exttest 4 | dependency: 5 | - google/protobuf/descriptor.proto 6 | messageType: 7 | - name: Message 8 | field: 9 | - name: a 10 | number: 1 11 | label: LABEL_OPTIONAL 12 | type: TYPE_INT32 13 | jsonName: a 14 | - name: b 15 | number: 3 16 | label: LABEL_OPTIONAL 17 | typeName: Message 18 | jsonName: b 19 | extensionRange: 20 | - start: 5 21 | end: 7 22 | extension: 23 | - name: c 24 | extendee: Message 25 | number: 5 26 | label: LABEL_OPTIONAL 27 | type: TYPE_INT32 28 | jsonName: c 29 | - name: d 30 | extendee: Message 31 | number: 6 32 | label: LABEL_OPTIONAL 33 | typeName: Message 34 | jsonName: d 35 | - name: foo 36 | extendee: google.protobuf.FileOptions 37 | number: 50000 38 | label: LABEL_OPTIONAL 39 | typeName: Message 40 | jsonName: foo 41 | options: 42 | uninterpretedOption: 43 | - name: 44 | - namePart: exttest.foo 45 | isExtension: true 46 | - namePart: exttest.d 47 | isExtension: true 48 | - namePart: a 49 | isExtension: false 50 | positiveIntValue: '1' 51 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_resolution4.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | dependency: 4 | - google/protobuf/descriptor.proto 5 | messageType: 6 | - name: Foo 7 | field: 8 | - name: a 9 | number: 1 10 | label: LABEL_OPTIONAL 11 | type: TYPE_GROUP 12 | typeName: A 13 | jsonName: a 14 | nestedType: 15 | - name: A 16 | field: 17 | - name: key 18 | number: 1 19 | label: LABEL_OPTIONAL 20 | type: TYPE_INT32 21 | jsonName: key 22 | extension: 23 | - name: a 24 | extendee: google.protobuf.FileOptions 25 | number: 1001 26 | label: LABEL_OPTIONAL 27 | typeName: Foo.A 28 | jsonName: a 29 | options: 30 | uninterpretedOption: 31 | - name: 32 | - namePart: a 33 | isExtension: true 34 | - namePart: key 35 | isExtension: false 36 | positiveIntValue: '1' 37 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_resolution5.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | dependency: 4 | - google/protobuf/descriptor.proto 5 | messageType: 6 | - name: Foo 7 | field: 8 | - name: a 9 | number: 1 10 | label: LABEL_OPTIONAL 11 | type: TYPE_GROUP 12 | typeName: A 13 | jsonName: a 14 | nestedType: 15 | - name: A 16 | field: 17 | - name: key 18 | number: 1 19 | label: LABEL_OPTIONAL 20 | type: TYPE_INT32 21 | jsonName: key 22 | extension: 23 | - name: a 24 | extendee: google.protobuf.FileOptions 25 | number: 1001 26 | label: LABEL_REPEATED 27 | typeName: Foo.A 28 | jsonName: a 29 | options: 30 | uninterpretedOption: 31 | - name: 32 | - namePart: a 33 | isExtension: true 34 | aggregateValue: 'key : 1 ,' 35 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_resolution6.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | package: demo 4 | dependency: 5 | - google/protobuf/descriptor.proto 6 | enumType: 7 | - name: Foo 8 | value: 9 | - name: None 10 | number: 0 11 | options: 12 | uninterpretedOption: 13 | - name: 14 | - namePart: len 15 | isExtension: true 16 | positiveIntValue: '0' 17 | - name: One 18 | number: 1 19 | options: 20 | uninterpretedOption: 21 | - name: 22 | - namePart: len 23 | isExtension: true 24 | positiveIntValue: '1' 25 | - name: Two 26 | number: 2 27 | options: 28 | uninterpretedOption: 29 | - name: 30 | - namePart: len 31 | isExtension: true 32 | positiveIntValue: '2' 33 | extension: 34 | - name: len 35 | extendee: google.protobuf.EnumValueOptions 36 | number: 50000 37 | label: LABEL_OPTIONAL 38 | type: TYPE_UINT32 39 | jsonName: len 40 | proto3Optional: true 41 | syntax: proto3 42 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_resolution7.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | dependency: 4 | - google/protobuf/descriptor.proto 5 | messageType: 6 | - name: Foo 7 | field: 8 | - name: a 9 | number: 1 10 | label: LABEL_OPTIONAL 11 | type: TYPE_GROUP 12 | typeName: A 13 | jsonName: a 14 | nestedType: 15 | - name: A 16 | field: 17 | - name: key 18 | number: 1 19 | label: LABEL_OPTIONAL 20 | type: TYPE_FLOAT 21 | jsonName: key 22 | extension: 23 | - name: a 24 | extendee: google.protobuf.FileOptions 25 | number: 1001 26 | label: LABEL_REPEATED 27 | typeName: Foo.A 28 | jsonName: a 29 | options: 30 | uninterpretedOption: 31 | - name: 32 | - namePart: a 33 | isExtension: true 34 | aggregateValue: 'key : 1.0' 35 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_resolution8.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | dependency: 4 | - google/protobuf/descriptor.proto 5 | messageType: 6 | - name: Foo 7 | field: 8 | - name: a 9 | number: 1 10 | label: LABEL_OPTIONAL 11 | type: TYPE_GROUP 12 | typeName: A 13 | jsonName: a 14 | nestedType: 15 | - name: A 16 | field: 17 | - name: key 18 | number: 1 19 | label: LABEL_OPTIONAL 20 | type: TYPE_STRING 21 | jsonName: key 22 | extension: 23 | - name: a 24 | extendee: google.protobuf.FileOptions 25 | number: 1001 26 | label: LABEL_REPEATED 27 | typeName: Foo.A 28 | jsonName: a 29 | options: 30 | uninterpretedOption: 31 | - name: 32 | - namePart: a 33 | isExtension: true 34 | aggregateValue: 'key : "hello" "gdfg"' 35 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_resolution9.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | dependency: 4 | - google/protobuf/descriptor.proto 5 | messageType: 6 | - name: Foo 7 | field: 8 | - name: a 9 | number: 1 10 | label: LABEL_OPTIONAL 11 | type: TYPE_GROUP 12 | typeName: A 13 | jsonName: a 14 | nestedType: 15 | - name: A 16 | field: 17 | - name: key 18 | number: 1 19 | label: LABEL_OPTIONAL 20 | type: TYPE_STRING 21 | jsonName: key 22 | extension: 23 | - name: a 24 | extendee: google.protobuf.FileOptions 25 | number: 1001 26 | label: LABEL_REPEATED 27 | type: TYPE_STRING 28 | jsonName: a 29 | options: 30 | uninterpretedOption: 31 | - name: 32 | - namePart: a 33 | isExtension: true 34 | stringValue: aGVsbG9nZGZn 35 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_unknown_extension.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | options: 4 | uninterpretedOption: 5 | - name: 6 | - namePart: an.extension 7 | isExtension: true 8 | positiveIntValue: '1' 9 | -------------------------------------------------------------------------------- /prost-reflect/tests/data/option_unknown_field.yml: -------------------------------------------------------------------------------- 1 | file: 2 | - name: test.proto 3 | options: 4 | uninterpretedOption: 5 | - name: 6 | - namePart: unknown 7 | isExtension: false 8 | positiveIntValue: '1' 9 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__dependency_not_imported.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | help: "'Dependency' is defined in 'dep.proto', which is not imported by 'root.proto'" 7 | labels: [] 8 | message: "name 'Dependency' is not defined" 9 | related: [] 10 | severity: error 11 | 12 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__dependency_resolution_transitive.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - dependency: 7 | - transitive.proto 8 | name: dep.proto 9 | publicDependency: 10 | - 0 11 | syntax: proto3 12 | - dependency: 13 | - dep.proto 14 | messageType: 15 | - field: 16 | - jsonName: dep 17 | label: LABEL_OPTIONAL 18 | name: dep 19 | number: 1 20 | type: TYPE_MESSAGE 21 | typeName: ".Dependency" 22 | name: Root 23 | name: root.proto 24 | syntax: proto3 25 | - messageType: 26 | - name: Dependency 27 | name: transitive.proto 28 | syntax: proto3 29 | 30 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__dependency_resolution_transitive2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - messageType: 7 | - name: Foo 8 | name: file1.proto 9 | package: bar 10 | syntax: proto3 11 | - messageType: 12 | - name: Foo 13 | name: dep.proto 14 | syntax: proto3 15 | - dependency: 16 | - dep.proto 17 | messageType: 18 | - field: 19 | - jsonName: foo 20 | label: LABEL_OPTIONAL 21 | name: foo 22 | number: 1 23 | type: TYPE_MESSAGE 24 | typeName: ".Foo" 25 | name: Bar 26 | name: file2.proto 27 | package: bar 28 | syntax: proto3 29 | 30 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__dependency_resolution_transitive3.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | help: "'Dependency' is defined in 'transitive.proto', which is not imported by 'root.proto'" 7 | labels: [] 8 | message: "name 'Dependency' is not defined" 9 | related: [] 10 | severity: error 11 | 12 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__enum_default1.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - enumType: 7 | - name: Foo 8 | value: 9 | - name: DEFAULT 10 | number: 1 11 | name: test.proto 12 | 13 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__enum_default2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: the first value for proto3 enums must be 0 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__enum_default3.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - enumType: 7 | - name: Foo 8 | value: 9 | - name: DEFAULT 10 | number: 0 11 | name: test.proto 12 | syntax: proto3 13 | 14 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__enum_duplicate_number1.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | help: "set the 'allow_alias' option allow re-using enum numbers" 7 | labels: [] 8 | message: "enum number '0' has already been used" 9 | related: [] 10 | severity: error 11 | 12 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__enum_duplicate_number2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | help: "set the 'allow_alias' option allow re-using enum numbers" 7 | labels: [] 8 | message: "enum number '0' has already been used" 9 | related: [] 10 | severity: error 11 | 12 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__enum_duplicate_number3.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - enumType: 7 | - name: Enum 8 | options: 9 | allowAlias: true 10 | value: 11 | - name: ZERO 12 | number: 0 13 | - name: ZERO2 14 | number: 0 15 | name: test.proto 16 | 17 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__enum_field_invalid_default1.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "invalid default value 'ONE' for type 'Foo'" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__enum_field_invalid_default2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "invalid default value 'ONE' for type 'Foo'" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__enum_field_invalid_default3.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "invalid default value 'ONE' for type 'foo.Foo'" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__enum_field_invalid_default4.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "invalid default value 'ONE' for type 'foo.Foo'" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__enum_field_invalid_default5.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - enumType: 7 | - name: Foo 8 | value: 9 | - name: ZERO 10 | number: 0 11 | messageType: 12 | - field: 13 | - defaultValue: ZERO 14 | jsonName: foo 15 | label: LABEL_OPTIONAL 16 | name: foo 17 | number: 1 18 | type: TYPE_ENUM 19 | typeName: ".foo.Foo" 20 | name: Message 21 | name: test.proto 22 | package: foo 23 | 24 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__enum_field_invalid_default6.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "invalid default value 'ONE' for type 'foo.Message.Foo'" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__enum_field_invalid_default7.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - messageType: 7 | - enumType: 8 | - name: Foo 9 | value: 10 | - name: ZERO 11 | number: 0 12 | field: 13 | - defaultValue: ZERO 14 | jsonName: foo 15 | label: LABEL_OPTIONAL 16 | name: foo 17 | number: 1 18 | type: TYPE_ENUM 19 | typeName: ".foo.Message.Foo" 20 | name: Message 21 | name: test.proto 22 | package: foo 23 | 24 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__enum_field_invalid_default8.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "invalid default value 'ONE' for type 'foo.Parent.Foo'" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__enum_field_invalid_default9.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - messageType: 7 | - field: 8 | - defaultValue: ZERO 9 | jsonName: foo 10 | label: LABEL_OPTIONAL 11 | name: foo 12 | number: 1 13 | type: TYPE_ENUM 14 | typeName: ".foo.Parent.Foo" 15 | name: Message 16 | - enumType: 17 | - name: Foo 18 | value: 19 | - name: ZERO 20 | number: 0 21 | name: Parent 22 | name: test.proto 23 | package: foo 24 | 25 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__enum_reserved_range_overlap_with_value1.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "enum number '0' conflicts with reserved range '-5 to 5'" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__enum_reserved_range_overlap_with_value2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "enum number '5' conflicts with reserved range '2 to 2147483647'" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__enum_reserved_range_overlap_with_value3.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "enum number '5' conflicts with reserved range '5 to 5'" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__extend_field_number_not_in_extensions1.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "message 'Message' does not define '1' as an extension number" 8 | related: 9 | - causes: [] 10 | labels: [] 11 | message: "message 'Message' does not define '6' as an extension number" 12 | related: [] 13 | severity: error 14 | severity: error 15 | 16 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__extend_field_number_not_in_extensions2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "message 'Message' does not define '1' as an extension number" 8 | related: 9 | - causes: [] 10 | labels: [] 11 | message: "message 'Message' does not define '6' as an extension number" 12 | related: [] 13 | severity: error 14 | severity: error 15 | 16 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__extend_group_field.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - extension: 7 | - extendee: ".Message" 8 | jsonName: foo 9 | label: LABEL_REPEATED 10 | name: foo 11 | number: 1 12 | type: TYPE_GROUP 13 | typeName: ".Foo" 14 | messageType: 15 | - extensionRange: 16 | - end: 2 17 | start: 1 18 | name: Message 19 | - field: 20 | - jsonName: bar 21 | label: LABEL_REQUIRED 22 | name: bar 23 | number: 1 24 | type: TYPE_INT32 25 | name: Foo 26 | name: test.proto 27 | 28 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__field_default_invalid_type1.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "invalid default value '1' for type 'Foo'" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__field_default_invalid_type2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "invalid default value '\"ZERO\"' for type 'Foo'" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__field_default_invalid_type3.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "invalid default value 'FALSE' for type 'Foo'" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__field_default_value1.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "invalid default value '\"\"' for type 'message type'" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__field_default_value2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - messageType: 7 | - field: 8 | - defaultValue: "9000000" 9 | jsonName: defaultFloatExp 10 | label: LABEL_OPTIONAL 11 | name: default_float_exp 12 | number: 23 13 | type: TYPE_FLOAT 14 | - defaultValue: "90000000000000000000000" 15 | jsonName: defaultDoubleExp 16 | label: LABEL_OPTIONAL 17 | name: default_double_exp 18 | number: 24 19 | type: TYPE_DOUBLE 20 | name: Message 21 | name: test.proto 22 | 23 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__field_set_json_name.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - messageType: 7 | - field: 8 | - jsonName: noJsonName 9 | label: LABEL_OPTIONAL 10 | name: no_json_name 11 | number: 1 12 | type: TYPE_INT32 13 | - jsonName: noJsonName2 14 | label: LABEL_OPTIONAL 15 | name: no_json_name2 16 | number: 2 17 | type: TYPE_INT32 18 | name: Message 19 | name: test.proto 20 | 21 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__generate_group_message_name_conflict.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "name 'Foo.Baz' is defined twice" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__generate_map_entry_message_name_conflict.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "name 'Foo.BazEntry' is defined twice" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__generate_synthetic_oneof_name_conflict.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "name 'Foo._val' is defined twice" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__invalid_message_number1.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | help: field numbers 19000 to 19999 are reserved 7 | labels: [] 8 | message: "invalid field number '19000'" 9 | related: [] 10 | severity: error 11 | 12 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__invalid_message_number2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | help: field numbers 19000 to 19999 are reserved 7 | labels: [] 8 | message: "invalid field number '19999'" 9 | related: [] 10 | severity: error 11 | 12 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__invalid_service_type1.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "'Enum' is not a message type" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__invalid_service_type2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "'Enum' is not a message type" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__invalid_service_type3.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "'Service' is not a message type" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__message_field_duplicate_number1.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "field number '1' is already used" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__message_field_duplicate_number2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "field number '1' is already used" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__message_reserved_range_message_set1.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - messageType: 7 | - name: Foo 8 | options: 9 | messageSetWireFormat: true 10 | reservedRange: 11 | - end: 2147483647 12 | start: 1 13 | name: test.proto 14 | 15 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__message_reserved_range_message_set2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - messageType: 7 | - extensionRange: 8 | - end: 2147483647 9 | start: 1 10 | name: Foo 11 | options: 12 | messageSetWireFormat: true 13 | name: test.proto 14 | 15 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__message_reserved_range_overlap_with_field1.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "field number '2' conflicts with reserved range '2 to 2'" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__message_reserved_range_overlap_with_field2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "field number '2' conflicts with extension range '1 to 5'" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__name_collision1.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "name 'Message' is defined twice" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__name_collision2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "name 'Message' is defined twice" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__name_collision3.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "name 'Message.foo' is defined twice" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__name_collision4.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "name 'foo' is already defined in file 'dep.proto'" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__name_collision5.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "name 'foo' is already defined in file 'dep.proto'" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__name_conflict1.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "name 'Foo' is defined twice" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__name_conflict2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "name 'Foo' is defined twice" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__name_conflict3.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "name 'Foo' is defined twice" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__name_conflict_field_camel_case1.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "camel-case name of field 'foo_bar' conflicts with field 'foobar'" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__name_conflict_field_camel_case2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "camel-case name of field 'foo' conflicts with field 'FOO'" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__name_conflict_field_camel_case3.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - messageType: 7 | - field: 8 | - jsonName: foo 9 | label: LABEL_OPTIONAL 10 | name: foo 11 | number: 1 12 | type: TYPE_INT32 13 | - jsonName: FOO 14 | label: LABEL_OPTIONAL 15 | name: FOO 16 | number: 2 17 | type: TYPE_INT32 18 | name: Foo 19 | name: test.proto 20 | 21 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__name_conflict_in_imported_files.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "name 'Foo' is already defined in file 'dep1.proto'" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__name_conflict_package1.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "name 'foo' is already defined in file 'dep.proto'" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__name_conflict_package2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "name 'foo' is already defined in file 'dep.proto'" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__name_conflict_package3.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - name: dep.proto 7 | package: foo 8 | - dependency: 9 | - dep.proto 10 | name: root.proto 11 | package: foo 12 | 13 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__name_conflict_with_import.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "name 'Foo' is already defined in file 'dep.proto'" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__name_resolution1.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "name '.foo.FooBar' is not defined" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__name_resolution2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "name '.FooBar' is not defined" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__name_resolution3.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - messageType: 7 | - name: Foo 8 | name: include/package.proto 9 | package: foo 10 | syntax: proto3 11 | - messageType: 12 | - name: Bar 13 | name: include/no_package.proto 14 | syntax: proto3 15 | - dependency: 16 | - include/package.proto 17 | - include/no_package.proto 18 | messageType: 19 | - name: FooBar 20 | - field: 21 | - jsonName: field1 22 | label: LABEL_OPTIONAL 23 | name: field1 24 | number: 1 25 | type: TYPE_MESSAGE 26 | typeName: ".foo.bar.FooBar" 27 | - jsonName: field2 28 | label: LABEL_OPTIONAL 29 | name: field2 30 | number: 2 31 | type: TYPE_MESSAGE 32 | typeName: ".foo.bar.FooBar" 33 | - jsonName: field3 34 | label: LABEL_OPTIONAL 35 | name: field3 36 | number: 3 37 | type: TYPE_MESSAGE 38 | typeName: ".foo.bar.FooBar" 39 | - jsonName: field4 40 | label: LABEL_OPTIONAL 41 | name: field4 42 | number: 4 43 | type: TYPE_MESSAGE 44 | typeName: ".foo.bar.FooBar" 45 | - jsonName: field5 46 | label: LABEL_OPTIONAL 47 | name: field5 48 | number: 5 49 | type: TYPE_MESSAGE 50 | typeName: ".foo.Foo" 51 | - jsonName: field6 52 | label: LABEL_OPTIONAL 53 | name: field6 54 | number: 6 55 | type: TYPE_MESSAGE 56 | typeName: ".foo.Foo" 57 | - jsonName: field7 58 | label: LABEL_OPTIONAL 59 | name: field7 60 | number: 7 61 | type: TYPE_MESSAGE 62 | typeName: ".foo.Foo" 63 | - jsonName: field8 64 | label: LABEL_OPTIONAL 65 | name: field8 66 | number: 8 67 | type: TYPE_MESSAGE 68 | typeName: ".Bar" 69 | - jsonName: field9 70 | label: LABEL_OPTIONAL 71 | name: field9 72 | number: 9 73 | type: TYPE_MESSAGE 74 | typeName: ".Bar" 75 | name: Names 76 | nestedType: 77 | - field: 78 | - jsonName: field1 79 | label: LABEL_OPTIONAL 80 | name: field1 81 | number: 1 82 | type: TYPE_MESSAGE 83 | typeName: ".foo.bar.FooBar" 84 | - jsonName: field2 85 | label: LABEL_OPTIONAL 86 | name: field2 87 | number: 2 88 | type: TYPE_MESSAGE 89 | typeName: ".foo.bar.FooBar" 90 | - jsonName: field3 91 | label: LABEL_OPTIONAL 92 | name: field3 93 | number: 3 94 | type: TYPE_MESSAGE 95 | typeName: ".foo.bar.FooBar" 96 | - jsonName: field4 97 | label: LABEL_OPTIONAL 98 | name: field4 99 | number: 4 100 | type: TYPE_MESSAGE 101 | typeName: ".foo.bar.FooBar" 102 | - jsonName: field5 103 | label: LABEL_OPTIONAL 104 | name: field5 105 | number: 5 106 | type: TYPE_MESSAGE 107 | typeName: ".foo.Foo" 108 | - jsonName: field6 109 | label: LABEL_OPTIONAL 110 | name: field6 111 | number: 6 112 | type: TYPE_MESSAGE 113 | typeName: ".foo.Foo" 114 | - jsonName: field7 115 | label: LABEL_OPTIONAL 116 | name: field7 117 | number: 7 118 | type: TYPE_MESSAGE 119 | typeName: ".foo.Foo" 120 | - jsonName: field8 121 | label: LABEL_OPTIONAL 122 | name: field8 123 | number: 8 124 | type: TYPE_MESSAGE 125 | typeName: ".Bar" 126 | - jsonName: field9 127 | label: LABEL_OPTIONAL 128 | name: field9 129 | number: 9 130 | type: TYPE_MESSAGE 131 | typeName: ".Bar" 132 | name: Nested 133 | name: name_resolution.proto 134 | package: foo.bar 135 | syntax: proto3 136 | 137 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__name_resolution4.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | help: "The innermost scope is searched first in name resolution. Consider using a leading '.' (i.e., '.foo.FooBar') to start from the outermost scope." 7 | labels: [] 8 | message: "'foo.FooBar' resolves to 'com.foo.FooBar', which is not defined" 9 | related: [] 10 | severity: error 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__name_resolution5.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - enumType: 7 | - name: ChildEnum 8 | value: 9 | - name: UNKNOWN 10 | number: 0 11 | - name: A 12 | number: 1 13 | - name: B 14 | number: 2 15 | messageType: 16 | - field: 17 | - jsonName: ChildMessage 18 | label: LABEL_OPTIONAL 19 | name: ChildMessage 20 | number: 1 21 | type: TYPE_MESSAGE 22 | typeName: ".ChildMessage" 23 | - jsonName: ChildEnum 24 | label: LABEL_OPTIONAL 25 | name: ChildEnum 26 | number: 2 27 | type: TYPE_ENUM 28 | typeName: ".ChildEnum" 29 | name: Parent 30 | - field: 31 | - jsonName: field 32 | label: LABEL_OPTIONAL 33 | name: field 34 | number: 1 35 | type: TYPE_STRING 36 | name: ChildMessage 37 | name: root.proto 38 | syntax: proto3 39 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__name_resolution6.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - messageType: 7 | - name: Foo 8 | name: dep.proto 9 | package: foo 10 | syntax: proto3 11 | - dependency: 12 | - dep.proto 13 | messageType: 14 | - field: 15 | - jsonName: foo 16 | label: LABEL_OPTIONAL 17 | name: foo 18 | number: 2 19 | type: TYPE_MESSAGE 20 | typeName: ".foo.Foo" 21 | name: Sample 22 | name: root.proto 23 | package: sample 24 | syntax: proto3 25 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__oneof_group_field.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - messageType: 7 | - field: 8 | - jsonName: group 9 | label: LABEL_OPTIONAL 10 | name: group 11 | number: 1 12 | oneofIndex: 0 13 | type: TYPE_GROUP 14 | typeName: ".Message.Group" 15 | name: Message 16 | nestedType: 17 | - field: 18 | - jsonName: bar 19 | label: LABEL_REPEATED 20 | name: bar 21 | number: 1 22 | type: TYPE_FLOAT 23 | name: Group 24 | oneofDecl: 25 | - name: oneof 26 | name: test.proto 27 | 28 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_already_set.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "option field 'deprecated' has already been set" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_extension_dependency_not_imported.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | help: "'unknown.extension' is defined in 'dep.proto', which is not imported by 'test.proto'" 7 | labels: [] 8 | message: "name 'unknown.extension' is not defined" 9 | related: [] 10 | severity: error 11 | 12 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_extension_dependency_transitive.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - dependency: 7 | - dep.proto 8 | name: test.proto 9 | options: 10 | "[unknown.extension]": 1 11 | - dependency: 12 | - transitive.proto 13 | name: dep.proto 14 | publicDependency: 15 | - 0 16 | - dependency: 17 | - google/protobuf/descriptor.proto 18 | extension: 19 | - extendee: ".google.protobuf.FileOptions" 20 | jsonName: extension 21 | label: LABEL_OPTIONAL 22 | name: extension 23 | number: 1001 24 | type: TYPE_INT32 25 | name: transitive.proto 26 | package: unknown 27 | 28 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_extension_invalid_type.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "'extension' is not an extension" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_extension_wrong_extendee.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "expected an extension to type 'google.protobuf.FileOptions', but 'extension' extends 'google.protobuf.FieldOptions'" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_map_entry_set_explicitly.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - messageType: 7 | - name: Foo 8 | options: 9 | mapEntry: true 10 | name: test.proto 11 | 12 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_resolution1.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - dependency: 7 | - google/protobuf/descriptor.proto 8 | extension: 9 | - extendee: ".google.protobuf.FileOptions" 10 | jsonName: foo 11 | label: LABEL_OPTIONAL 12 | name: foo 13 | number: 1001 14 | type: TYPE_MESSAGE 15 | typeName: ".Foo" 16 | messageType: 17 | - field: 18 | - jsonName: a 19 | label: LABEL_OPTIONAL 20 | name: a 21 | number: 1 22 | type: TYPE_INT32 23 | - jsonName: b 24 | label: LABEL_OPTIONAL 25 | name: b 26 | number: 2 27 | type: TYPE_INT32 28 | name: Foo 29 | name: test.proto 30 | options: 31 | "[foo]": 32 | a: 1 33 | b: 1 34 | optimizeFor: SPEED 35 | 36 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_resolution10.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - dependency: 7 | - google/protobuf/descriptor.proto 8 | extension: 9 | - extendee: ".google.protobuf.FileOptions" 10 | jsonName: a 11 | label: LABEL_REPEATED 12 | name: a 13 | number: 1001 14 | type: TYPE_MESSAGE 15 | typeName: ".Foo.A" 16 | messageType: 17 | - field: 18 | - jsonName: a 19 | label: LABEL_OPTIONAL 20 | name: a 21 | number: 1 22 | type: TYPE_GROUP 23 | typeName: ".Foo.A" 24 | name: Foo 25 | nestedType: 26 | - field: 27 | - jsonName: key 28 | label: LABEL_OPTIONAL 29 | name: key 30 | number: 1 31 | type: TYPE_FLOAT 32 | name: A 33 | name: test.proto 34 | options: 35 | "[a]": 36 | - key: "-Infinity" 37 | 38 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_resolution11.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - dependency: 7 | - google/protobuf/any.proto 8 | - google/protobuf/descriptor.proto 9 | extension: 10 | - extendee: ".google.protobuf.FileOptions" 11 | jsonName: a 12 | label: LABEL_REPEATED 13 | name: a 14 | number: 1001 15 | type: TYPE_MESSAGE 16 | typeName: ".google.protobuf.Any" 17 | messageType: 18 | - field: 19 | - jsonName: foo 20 | label: LABEL_OPTIONAL 21 | name: foo 22 | number: 1 23 | type: TYPE_STRING 24 | name: Foo 25 | name: test.proto 26 | options: 27 | "[a]": 28 | - "@type": type.googleapis.com/Foo 29 | foo: bar 30 | 31 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_resolution12.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - dependency: 7 | - google/protobuf/descriptor.proto 8 | extension: 9 | - extendee: ".google.protobuf.FileOptions" 10 | jsonName: a 11 | label: LABEL_REPEATED 12 | name: a 13 | number: 1001 14 | type: TYPE_MESSAGE 15 | typeName: ".Foo" 16 | messageType: 17 | - field: 18 | - jsonName: foo 19 | label: LABEL_OPTIONAL 20 | name: foo 21 | number: 1 22 | type: TYPE_MESSAGE 23 | typeName: ".Foo" 24 | name: Foo 25 | name: test.proto 26 | options: 27 | "[a]": 28 | - foo: {} 29 | 30 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_resolution13.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - dependency: 7 | - google/protobuf/descriptor.proto 8 | extension: 9 | - extendee: ".google.protobuf.FileOptions" 10 | jsonName: a 11 | label: LABEL_REPEATED 12 | name: a 13 | number: 1001 14 | type: TYPE_MESSAGE 15 | typeName: ".Foo" 16 | messageType: 17 | - field: 18 | - jsonName: foo 19 | label: LABEL_REPEATED 20 | name: foo 21 | number: 1 22 | type: TYPE_INT32 23 | name: Foo 24 | name: test.proto 25 | options: 26 | "[a]": 27 | - foo: 28 | - 1 29 | - 2 30 | - 3 31 | 32 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_resolution14.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - dependency: 7 | - google/protobuf/descriptor.proto 8 | extension: 9 | - extendee: ".google.protobuf.FileOptions" 10 | jsonName: a 11 | label: LABEL_REPEATED 12 | name: a 13 | number: 1001 14 | type: TYPE_MESSAGE 15 | typeName: ".Foo" 16 | messageType: 17 | - field: 18 | - jsonName: foo 19 | label: LABEL_REPEATED 20 | name: foo 21 | number: 1 22 | type: TYPE_INT32 23 | name: Foo 24 | name: test.proto 25 | options: 26 | "[a]": 27 | - foo: 28 | - 1 29 | - 2 30 | - 3 31 | 32 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_resolution15.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - dependency: 7 | - google/protobuf/descriptor.proto 8 | extension: 9 | - extendee: ".google.protobuf.FileOptions" 10 | jsonName: a 11 | label: LABEL_REPEATED 12 | name: a 13 | number: 1001 14 | type: TYPE_MESSAGE 15 | typeName: ".Foo" 16 | messageType: 17 | - field: 18 | - jsonName: foo 19 | label: LABEL_OPTIONAL 20 | name: foo 21 | number: 1 22 | type: TYPE_GROUP 23 | typeName: ".Foo.Foo" 24 | name: Foo 25 | nestedType: 26 | - name: Foo 27 | name: test.proto 28 | options: 29 | "[a]": 30 | - foo: {} 31 | 32 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_resolution16.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - dependency: 7 | - google/protobuf/descriptor.proto 8 | extension: 9 | - extendee: ".google.protobuf.FileOptions" 10 | jsonName: a 11 | label: LABEL_REPEATED 12 | name: a 13 | number: 1001 14 | type: TYPE_MESSAGE 15 | typeName: ".Foo" 16 | messageType: 17 | - field: 18 | - jsonName: foo 19 | label: LABEL_OPTIONAL 20 | name: foo 21 | number: 1 22 | type: TYPE_GROUP 23 | typeName: ".Foo.Foo" 24 | name: Foo 25 | nestedType: 26 | - name: Foo 27 | name: test.proto 28 | options: 29 | "[a]": 30 | - foo: {} 31 | 32 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_resolution17.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - dependency: 7 | - google/protobuf/descriptor.proto 8 | extension: 9 | - extendee: ".google.protobuf.FileOptions" 10 | jsonName: a 11 | label: LABEL_OPTIONAL 12 | name: a 13 | number: 1001 14 | type: TYPE_MESSAGE 15 | typeName: ".Foo" 16 | messageType: 17 | - field: 18 | - jsonName: foo 19 | label: LABEL_REPEATED 20 | name: foo 21 | number: 1 22 | type: TYPE_INT32 23 | - jsonName: bar 24 | label: LABEL_OPTIONAL 25 | name: bar 26 | number: 2 27 | type: TYPE_INT32 28 | name: Foo 29 | name: test.proto 30 | options: 31 | "[a]": 32 | bar: 2 33 | foo: 34 | - 1 35 | - 2 36 | 37 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_resolution18.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "cannot set field for option '(a)' value of type 'repeated Foo'" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_resolution19.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - messageType: 7 | - field: 8 | - jsonName: javaOuterClassname 9 | label: LABEL_OPTIONAL 10 | name: java_outer_classname 11 | number: 1 12 | oneofIndex: 0 13 | proto3Optional: true 14 | type: TYPE_STRING 15 | name: FileOptions 16 | oneofDecl: 17 | - name: _java_outer_classname 18 | name: test.proto 19 | options: 20 | javaPackage: ClassName 21 | uninterpretedOption: 22 | - name: 23 | - isExtension: false 24 | namePart: java_outer_classname 25 | stringValue: Q2xhc3NOYW1l 26 | package: google.protobuf 27 | syntax: proto3 28 | 29 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_resolution2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - dependency: 7 | - google/protobuf/descriptor.proto 8 | extension: 9 | - extendee: ".google.protobuf.OneofOptions" 10 | jsonName: myOption 11 | label: LABEL_OPTIONAL 12 | name: my_option 13 | number: 12345 14 | type: TYPE_INT32 15 | messageType: 16 | - field: 17 | - jsonName: bar 18 | label: LABEL_OPTIONAL 19 | name: bar 20 | number: 1 21 | oneofIndex: 0 22 | type: TYPE_INT32 23 | name: Hello 24 | oneofDecl: 25 | - name: something 26 | options: 27 | "[my_option]": 54321 28 | name: test.proto 29 | 30 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_resolution20.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - dependency: 7 | - google/protobuf/descriptor.proto 8 | extension: 9 | - extendee: ".google.protobuf.FileOptions" 10 | jsonName: ext 11 | label: LABEL_REPEATED 12 | name: ext 13 | number: 1001 14 | type: TYPE_INT32 15 | name: dep.proto 16 | options: 17 | "[dep.ext]": 18 | - 1 19 | - 2 20 | - 3 21 | package: dep 22 | syntax: proto3 23 | - dependency: 24 | - dep.proto 25 | - google/protobuf/descriptor.proto 26 | name: root.proto 27 | options: 28 | "[dep.ext]": 29 | - 4 30 | - 5 31 | syntax: proto3 32 | 33 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_resolution21.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - dependency: 7 | - google/protobuf/descriptor.proto 8 | messageType: 9 | - extension: 10 | - extendee: ".google.protobuf.MessageOptions" 11 | jsonName: ext 12 | label: LABEL_OPTIONAL 13 | name: ext 14 | number: 1001 15 | proto3Optional: true 16 | type: TYPE_STRING 17 | name: Foo 18 | options: 19 | "[Foo.ext]": foo 20 | - name: Bar 21 | options: 22 | "[Foo.ext]": bar 23 | name: test.proto 24 | syntax: proto3 25 | 26 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_resolution22.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - dependency: 7 | - google/protobuf/descriptor.proto 8 | extension: 9 | - extendee: ".google.protobuf.FileOptions" 10 | jsonName: ext 11 | label: LABEL_OPTIONAL 12 | name: ext 13 | number: 1001 14 | type: TYPE_MESSAGE 15 | typeName: ".Map" 16 | messageType: 17 | - field: 18 | - jsonName: map 19 | label: LABEL_REPEATED 20 | name: map 21 | number: 1 22 | type: TYPE_MESSAGE 23 | typeName: ".Map.MapEntry" 24 | name: Map 25 | nestedType: 26 | - field: 27 | - jsonName: key 28 | label: LABEL_OPTIONAL 29 | name: key 30 | number: 1 31 | type: TYPE_STRING 32 | - jsonName: value 33 | label: LABEL_OPTIONAL 34 | name: value 35 | number: 2 36 | type: TYPE_INT32 37 | name: MapEntry 38 | options: 39 | mapEntry: true 40 | name: test.proto 41 | options: 42 | "[ext]": 43 | map: 44 | a: 1 45 | b: 2 46 | c: 3 47 | syntax: proto3 48 | 49 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_resolution23.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - dependency: 7 | - google/protobuf/descriptor.proto 8 | extension: 9 | - extendee: ".google.protobuf.FileOptions" 10 | jsonName: ext 11 | label: LABEL_OPTIONAL 12 | name: ext 13 | number: 1001 14 | type: TYPE_MESSAGE 15 | typeName: ".Map" 16 | messageType: 17 | - field: 18 | - jsonName: map 19 | label: LABEL_REPEATED 20 | name: map 21 | number: 1 22 | type: TYPE_MESSAGE 23 | typeName: ".Map.MapEntry" 24 | name: Map 25 | nestedType: 26 | - field: 27 | - jsonName: key 28 | label: LABEL_OPTIONAL 29 | name: key 30 | number: 1 31 | type: TYPE_STRING 32 | - jsonName: value 33 | label: LABEL_OPTIONAL 34 | name: value 35 | number: 2 36 | type: TYPE_INT32 37 | name: MapEntry 38 | options: 39 | mapEntry: true 40 | name: test.proto 41 | options: 42 | "[ext]": 43 | map: 44 | a: 1 45 | b: 2 46 | c: 3 47 | syntax: proto3 48 | 49 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_resolution24.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - messageType: 7 | - field: 8 | - jsonName: doubleValue 9 | name: double_value 10 | number: 1 11 | name: FieldDescriptorProto 12 | name: test.proto 13 | 14 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_resolution3.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - dependency: 7 | - google/protobuf/descriptor.proto 8 | extension: 9 | - extendee: ".exttest.Message" 10 | jsonName: c 11 | label: LABEL_OPTIONAL 12 | name: c 13 | number: 5 14 | type: TYPE_INT32 15 | - extendee: ".exttest.Message" 16 | jsonName: d 17 | label: LABEL_OPTIONAL 18 | name: d 19 | number: 6 20 | type: TYPE_MESSAGE 21 | typeName: ".exttest.Message" 22 | - extendee: ".google.protobuf.FileOptions" 23 | jsonName: foo 24 | label: LABEL_OPTIONAL 25 | name: foo 26 | number: 50000 27 | type: TYPE_MESSAGE 28 | typeName: ".exttest.Message" 29 | messageType: 30 | - extensionRange: 31 | - end: 7 32 | start: 5 33 | field: 34 | - jsonName: a 35 | label: LABEL_OPTIONAL 36 | name: a 37 | number: 1 38 | type: TYPE_INT32 39 | - jsonName: b 40 | label: LABEL_OPTIONAL 41 | name: b 42 | number: 3 43 | type: TYPE_MESSAGE 44 | typeName: ".exttest.Message" 45 | name: Message 46 | name: test.proto 47 | options: 48 | "[exttest.foo]": 49 | "[exttest.d]": 50 | a: 1 51 | package: exttest 52 | 53 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_resolution4.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - dependency: 7 | - google/protobuf/descriptor.proto 8 | extension: 9 | - extendee: ".google.protobuf.FileOptions" 10 | jsonName: a 11 | label: LABEL_OPTIONAL 12 | name: a 13 | number: 1001 14 | type: TYPE_MESSAGE 15 | typeName: ".Foo.A" 16 | messageType: 17 | - field: 18 | - jsonName: a 19 | label: LABEL_OPTIONAL 20 | name: a 21 | number: 1 22 | type: TYPE_GROUP 23 | typeName: ".Foo.A" 24 | name: Foo 25 | nestedType: 26 | - field: 27 | - jsonName: key 28 | label: LABEL_OPTIONAL 29 | name: key 30 | number: 1 31 | type: TYPE_INT32 32 | name: A 33 | name: test.proto 34 | options: 35 | "[a]": 36 | key: 1 37 | 38 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_resolution5.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - dependency: 7 | - google/protobuf/descriptor.proto 8 | extension: 9 | - extendee: ".google.protobuf.FileOptions" 10 | jsonName: a 11 | label: LABEL_REPEATED 12 | name: a 13 | number: 1001 14 | type: TYPE_MESSAGE 15 | typeName: ".Foo.A" 16 | messageType: 17 | - field: 18 | - jsonName: a 19 | label: LABEL_OPTIONAL 20 | name: a 21 | number: 1 22 | type: TYPE_GROUP 23 | typeName: ".Foo.A" 24 | name: Foo 25 | nestedType: 26 | - field: 27 | - jsonName: key 28 | label: LABEL_OPTIONAL 29 | name: key 30 | number: 1 31 | type: TYPE_INT32 32 | name: A 33 | name: test.proto 34 | options: 35 | "[a]": 36 | - key: 1 37 | 38 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_resolution6.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - dependency: 7 | - google/protobuf/descriptor.proto 8 | enumType: 9 | - name: Foo 10 | value: 11 | - name: None 12 | number: 0 13 | options: 14 | "[demo.len]": 0 15 | - name: One 16 | number: 1 17 | options: 18 | "[demo.len]": 1 19 | - name: Two 20 | number: 2 21 | options: 22 | "[demo.len]": 2 23 | extension: 24 | - extendee: ".google.protobuf.EnumValueOptions" 25 | jsonName: len 26 | label: LABEL_OPTIONAL 27 | name: len 28 | number: 50000 29 | proto3Optional: true 30 | type: TYPE_UINT32 31 | name: test.proto 32 | package: demo 33 | syntax: proto3 34 | 35 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_resolution7.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - dependency: 7 | - google/protobuf/descriptor.proto 8 | extension: 9 | - extendee: ".google.protobuf.FileOptions" 10 | jsonName: a 11 | label: LABEL_REPEATED 12 | name: a 13 | number: 1001 14 | type: TYPE_MESSAGE 15 | typeName: ".Foo.A" 16 | messageType: 17 | - field: 18 | - jsonName: a 19 | label: LABEL_OPTIONAL 20 | name: a 21 | number: 1 22 | type: TYPE_GROUP 23 | typeName: ".Foo.A" 24 | name: Foo 25 | nestedType: 26 | - field: 27 | - jsonName: key 28 | label: LABEL_OPTIONAL 29 | name: key 30 | number: 1 31 | type: TYPE_FLOAT 32 | name: A 33 | name: test.proto 34 | options: 35 | "[a]": 36 | - key: 1 37 | 38 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_resolution8.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - dependency: 7 | - google/protobuf/descriptor.proto 8 | extension: 9 | - extendee: ".google.protobuf.FileOptions" 10 | jsonName: a 11 | label: LABEL_REPEATED 12 | name: a 13 | number: 1001 14 | type: TYPE_MESSAGE 15 | typeName: ".Foo.A" 16 | messageType: 17 | - field: 18 | - jsonName: a 19 | label: LABEL_OPTIONAL 20 | name: a 21 | number: 1 22 | type: TYPE_GROUP 23 | typeName: ".Foo.A" 24 | name: Foo 25 | nestedType: 26 | - field: 27 | - jsonName: key 28 | label: LABEL_OPTIONAL 29 | name: key 30 | number: 1 31 | type: TYPE_STRING 32 | name: A 33 | name: test.proto 34 | options: 35 | "[a]": 36 | - key: hellogdfg 37 | 38 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_resolution9.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | file: 6 | - dependency: 7 | - google/protobuf/descriptor.proto 8 | extension: 9 | - extendee: ".google.protobuf.FileOptions" 10 | jsonName: a 11 | label: LABEL_REPEATED 12 | name: a 13 | number: 1001 14 | type: TYPE_STRING 15 | messageType: 16 | - field: 17 | - jsonName: a 18 | label: LABEL_OPTIONAL 19 | name: a 20 | number: 1 21 | type: TYPE_GROUP 22 | typeName: ".Foo.A" 23 | name: Foo 24 | nestedType: 25 | - field: 26 | - jsonName: key 27 | label: LABEL_OPTIONAL 28 | name: key 29 | number: 1 30 | type: TYPE_STRING 31 | name: A 32 | name: test.proto 33 | options: 34 | "[a]": 35 | - hellogdfg 36 | 37 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_unknown_extension.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "name 'an.extension' is not defined" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /prost-reflect/tests/snapshots/main__option_unknown_field.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: prost-reflect/tests/main.rs 3 | expression: actual 4 | --- 5 | causes: [] 6 | labels: [] 7 | message: "option field 'unknown' is not defined" 8 | related: [] 9 | severity: error 10 | 11 | -------------------------------------------------------------------------------- /release-plz.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | changelog_update = false 3 | 4 | [[package]] 5 | name = "prost-reflect" 6 | changelog_update = true 7 | changelog_path = "./CHANGELOG.md" 8 | changelog_include = ["prost-reflect-build", "prost-reflect-derive"] 9 | -------------------------------------------------------------------------------- /rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | # https://github.com/dtolnay/trybuild/issues/126 2 | [toolchain] 3 | components = ["rust-src"] 4 | --------------------------------------------------------------------------------