Accessing a __value enum enumerated value from another assembly

  • Thread starter Thread starter Edward Diener
  • Start date Start date
E

Edward Diener

In an assembly I have a __value enum with some enumerated constants, ie.

namespace X
{
public __value enum MyEnum
{
ValueA,
ValueB
};
}

From another assembly which references the assembly in which the above
exists, I attempt to refer to the ValueA as X::ValueA, only to get an error
message saying that ValueA is not a member of X. When I attempt to refer to
ValueA as X::MyEnum::ValueA, all is well.

The change is not a big thing but I was was under the distinct impression
that one only needed to specify the longer syntax when there was another
ValueA in namespace X. Is this a bug in the current compiler, or have I
missed something in the ability to specify an enumerated constant ?
 
Edward Diener said:
In an assembly I have a __value enum with some enumerated constants, ie.

namespace X
{
public __value enum MyEnum
{
ValueA,
ValueB
};
}

From another assembly which references the assembly in which the above
exists, I attempt to refer to the ValueA as X::ValueA, only to get an error
message saying that ValueA is not a member of X. When I attempt to refer to
ValueA as X::MyEnum::ValueA, all is well.

The change is not a big thing but I was was under the distinct impression
that one only needed to specify the longer syntax when there was another
ValueA in namespace X. Is this a bug in the current compiler, or have I
missed something in the ability to specify an enumerated constant ?

It appears to be a bug in the compiler, as the short syntax works when you
are working with a local enum, atleast it did in a quick test. However I
don't know for sure, perhaps the compiler relys on header files instead of
the assembly metadata?
 
This is changing the subject slightly, but....

I use enumerators as a programmer convenience. For example, I have an
array that parallels a form. Instead of using the indices of the array
(0,1,2, etc) I use names corresponding to the form's columns. If, later
in the development cycle, I have to change the order of two columns on the
form I make the parallel change in the enumerator and the recoding is done.

In other words, in my usage an enumerator is always an entity that is local
to a given module/routine. Member "B" that uses X::ValueA wouldn't be
written that way since I hate to have a module change on recompile because
different source-code changed. It is probably just a matter of programming
style, but I never run into the issue.

I know this doesn't address the issue raised, but thought I'd comment
anyway.
 
Daniel said:
It appears to be a bug in the compiler, as the short syntax works
when you are working with a local enum, atleast it did in a quick
test. However I don't know for sure, perhaps the compiler relys on
header files instead of the assembly metadata?

The last seems dubious since the compiler relies on metadata for everything
else, and works using the long form without having to use an include file.
Hopefully someone will pass on this bug to MS.
 
Back
Top