mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-10 15:16:28 +00:00
Generate FlagsAttribute for Csharp (#5370)
For schema enums with the bit_flags attribute, generate the corresponding System.FlagsAttribute in generated Csharp code.
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
43dbac5d25
commit
93f74c0363
@@ -510,6 +510,11 @@ class GeneralGenerator : public BaseGenerator {
|
||||
std::string &code = *code_ptr;
|
||||
if (enum_def.generated) return;
|
||||
|
||||
// In C# this indicates enumeration values can be treated as bit flags.
|
||||
if (lang_.language == IDLOptions::kCSharp && enum_def.attributes.Lookup("bit_flags")) {
|
||||
code += "[System.FlagsAttribute]\n";
|
||||
}
|
||||
|
||||
// Generate enum definitions of the form:
|
||||
// public static (final) int name = value;
|
||||
// In Java, we use ints rather than the Enum feature, because we want them
|
||||
|
||||
Reference in New Issue
Block a user