dep-protobuf/csharp/protos
Lethe cf3a0ea109 C#: Fix redundant has_bits alloc for multi of 32 (#26455)
### Description
This PR fixes the issue where an unused `_hasBits` field is allocated in the generated C# code when the number of presence bits is an exact multiple of 32.

**Changes:**
- Updated the `has_bit_field_count_` calculation in `MessageGenerator` to use the formula: `(presence_bit_count + 31) / 32`.
- This ensures that exactly 1 `int32` is allocated for 32 fields, 2 for 64 fields, etc., instead of over-allocating.

**Testing:**
- Added `TestPresenceBits` to `unittest_issues.proto` which includes exactly 32 optional fields.
- Added a unit test in `Proto3OptionalTest.cs` to assert that exactly one `_hasBits0` field is generated via reflection.

Fixes #26391

Closes #26455

PiperOrigin-RevId: 885948073
2026-03-18 21:27:46 -07:00
..
map_unittest_proto3.proto Shorten our license headers into an abbreviated form that references LICENSE instead of including it in full. 2023-09-11 16:33:19 -07:00
old_extensions1.proto Shorten our license headers into an abbreviated form that references LICENSE instead of including it in full. 2023-09-11 16:33:19 -07:00
old_extensions2.proto Shorten our license headers into an abbreviated form that references LICENSE instead of including it in full. 2023-09-11 16:33:19 -07:00
README.md Move C#-only test protos to csharp/protos 2017-11-12 15:29:15 +00:00
unittest.proto Remove lazy=true from repeated fields. 2024-02-05 15:53:12 -08:00
unittest_custom_options_proto3.proto Shorten our license headers into an abbreviated form that references LICENSE instead of including it in full. 2023-09-11 16:33:19 -07:00
unittest_import.proto Shorten our license headers into an abbreviated form that references LICENSE instead of including it in full. 2023-09-11 16:33:19 -07:00
unittest_import_proto3.proto Shorten our license headers into an abbreviated form that references LICENSE instead of including it in full. 2023-09-11 16:33:19 -07:00
unittest_import_public.proto Shorten our license headers into an abbreviated form that references LICENSE instead of including it in full. 2023-09-11 16:33:19 -07:00
unittest_import_public_proto3.proto Shorten our license headers into an abbreviated form that references LICENSE instead of including it in full. 2023-09-11 16:33:19 -07:00
unittest_issue6936_a.proto Shorten our license headers into an abbreviated form that references LICENSE instead of including it in full. 2023-09-11 16:33:19 -07:00
unittest_issue6936_b.proto Shorten our license headers into an abbreviated form that references LICENSE instead of including it in full. 2023-09-11 16:33:19 -07:00
unittest_issue6936_c.proto Shorten our license headers into an abbreviated form that references LICENSE instead of including it in full. 2023-09-11 16:33:19 -07:00
unittest_issues.proto C#: Fix redundant has_bits alloc for multi of 32 (#26455) 2026-03-18 21:27:46 -07:00
unittest_proto3.proto Shorten our license headers into an abbreviated form that references LICENSE instead of including it in full. 2023-09-11 16:33:19 -07:00
unittest_selfreferential_options.proto Shorten our license headers into an abbreviated form that references LICENSE instead of including it in full. 2023-09-11 16:33:19 -07:00

This directory contains unit test protos adapted from those in src/google/protobuf, and C#-specific test protos for regression tests against bugs found in the C# codegen or library.