Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C#] Union type enum names are not qualified #5375

Open
thurn opened this issue May 27, 2019 · 3 comments

Comments

Projects
None yet
3 participants
@thurn
Copy link

commented May 27, 2019

Using flatc on OSX built at master (commit #43dbac5d25c81918f917761d350a7a59db0fe84b).

If you make a schema containing a union-typed field:

namespace Test;

table StartRoundAction {
}

union Action {
  StartRoundAction
}

table Request {
  action: Action;
}

root_type Request;

The compiler with --csharp will generate several unqualified Action.NONE enum references like this:

public Action ActionType { get { int o = __p.__offset(4); return o != 0 ? (Action)__p.bb.Get(o + __p.bb_pos) : Action.NONE; } }

This code does not compile because of the name conflict in the (extremely common) case where a type name and a field name overlap. The correct generated code would fully-qualify references like this:

public Action ActionType { get { int o = __p.__offset(4); return o != 0 ? (Action)__p.bb.Get(o + __p.bb_pos) : Test.Action.NONE; } }
@aardappel

This comment has been minimized.

Copy link
Collaborator

commented May 30, 2019

Agree, that seems to be a code generator oversight. Are you able to create a PR to fix this? In idl_gen_general.cpp there should be examples of where it does emit Test. correctly.

@lux

This comment has been minimized.

Copy link
Contributor

commented Jun 13, 2019

It looks like this PR may address this:

#5404

@aardappel

This comment has been minimized.

Copy link
Collaborator

commented Jun 14, 2019

It likely does.. @thurn can you confirm?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.