Commit 93f74c03 authored by Marc Butler's avatar Marc Butler Committed by Wouter van Oortmerssen

Generate FlagsAttribute for Csharp (#5370)

For schema enums with the bit_flags attribute, generate the
corresponding System.FlagsAttribute in generated Csharp code.
parent 43dbac5d
......@@ -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
......
......@@ -5,6 +5,7 @@
namespace MyGame.Example
{
[System.FlagsAttribute]
public enum Color : byte
{
Red = 1,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment