Skip to content

C# flags: keep the underlying type in the bitwise operators and Remov… - #112

Closed
jccarvalhosa wants to merge 2 commits into
chronoxor:mainfrom
TOOQ-TECHNOLOGY:fix-csharp-flags-underlying-type-main
Closed

jccarvalhosa wants to merge 2 commits into
chronoxor:mainfrom
TOOQ-TECHNOLOGY:fix-csharp-flags-underlying-type-main

Conversation

@jccarvalhosa

Copy link
Copy Markdown

…eFlags

The C# flags template cast the result of &, |, ^ and the complement in RemoveFlags to byte, whatever the declared base type. For a flags type on int32 (the default) or any type wider than a byte, combining two values above 0xFF lost them (0x400 | 0x1000 gave 0) and RemoveFlags cleared every flag from 0x100 up. The casts now use FLAGS_TYPE, as the constructor and the deserializer already do; byte-based flags generate the same code as before.

Jonathan Carvalhosa and others added 2 commits October 13, 2026 16:34
…eFlags

The C# flags template cast the result of &, |, ^ and the complement in
RemoveFlags to byte, whatever the declared base type. For a flags type
on int32 (the default) or any type wider than a byte, combining two
values above 0xFF lost them (0x400 | 0x1000 gave 0) and RemoveFlags
cleared every flag from 0x100 up. The casts now use _FLAGS_TYPE_, as the
constructor and the deserializer already do; byte-based flags generate
the same code as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chronoxor

Copy link
Copy Markdown
Owner

Fixed! Thanks for reporting!

@chronoxor chronoxor closed this Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants