google / flatbuffers

FlatBuffers: Memory Efficient Serialization Library

Home Page:https://flatbuffers.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[C#][23.3.3] flatc doesn't generate Verify class for unions

fefe-mercurio-teaching opened this issue · comments

Schema:

table StringType {
    value: string;
}

table IntType {
    value: int;
}

table SingleType {
    value: float;
}

table BoolType {
    value: bool;
}

union BaseType { StringType, IntType, SingleType, BoolType }

table ScriptCallParam {
    name: string;
    value: BaseType;
}

Generated BaseType.cs:

public enum BaseType : byte
{
  NONE = 0,
  StringType = 1,
  IntType = 2,
  SingleType = 3,
  BoolType = 4,
};

Issue on ScriptCallParam.cs: BaseTypeVerify doesn't exist

[...]
static public class ScriptCallParamVerify
{
  static public bool Verify(Google.FlatBuffers.Verifier verifier, uint tablePos)
  {
    return verifier.VerifyTableStart(tablePos)
      && verifier.VerifyString(tablePos, 4 /*Name*/, false)
      && verifier.VerifyField(tablePos, 6 /*ValueType*/, 1 /*BaseType*/, 1, false)
      && verifier.VerifyUnion(tablePos, 6, 8 /*Value*/, BaseTypeVerify.Verify, false)
      && verifier.VerifyTableEnd(tablePos);
  }
}

I am seeing this as well.. To get around it for now I just removed the && VerifyUnion().

I am also experiencing this, with the same flatc version. Do you know if this is an issue with previous versions? I might just downgrade.

Downgrading became an issue because the version gets put into the generated .cs files.

Schema:

table StringType {
    value: string;
}

table IntType {
    value: int;
}

table SingleType {
    value: float;
}

table BoolType {
    value: bool;
}

union BaseType { StringType, IntType, SingleType, BoolType }

table ScriptCallParam {
    name: string;
    value: BaseType;
}

Generated BaseType.cs:

public enum BaseType : byte
{
  NONE = 0,
  StringType = 1,
  IntType = 2,
  SingleType = 3,
  BoolType = 4,
};

Issue on ScriptCallParam.cs: BaseTypeVerify doesn't exist

[...]
static public class ScriptCallParamVerify
{
  static public bool Verify(Google.FlatBuffers.Verifier verifier, uint tablePos)
  {
    return verifier.VerifyTableStart(tablePos)
      && verifier.VerifyString(tablePos, 4 /*Name*/, false)
      && verifier.VerifyField(tablePos, 6 /*ValueType*/, 1 /*BaseType*/, 1, false)
      && verifier.VerifyUnion(tablePos, 6, 8 /*Value*/, BaseTypeVerify.Verify, false)
      && verifier.VerifyTableEnd(tablePos);
  }
}

using to reclamos on autentify

tengo problemas de uso