Skip to content

Reference to anonymous enum when using exclude-using-statics-for-enums #681

@theKidOfArcrania

Description

@theKidOfArcrania

When the config exclude-using-statics-for-enums is enabled, enum members will be fully qualified, which means this will reference an anonymously defined enumeration that is not actually generated. Running the unit test WithAnonymousEnumTestImpl with config exlclude-using-statics-for-enums (copied below for convenience)

enum
{
    MyEnum1_Value1 = 1,
};

enum MyEnum2 : int
{
    MyEnum2_Value1 = MyEnum1_Value1,
};

Will yield the resulting C# code (I actually used the command ClangSharpPInvokeGenerator.exe -f header.h --output test.cs -n Test.Bar --config exclude-using-statics-for-enums to yield the result):

namespace Test.Bar
{
    public enum MyEnum2
    {
        MyEnum2_Value1 = __AnonymousEnum_header_L1_C1.MyEnum1_Value1,
    }

    public static partial class Methods
    {
        public const int MyEnum1_Value1 = 1;
    }
}

Which in this case notably references this mysteriously named __AnonymousEnum_header_L1_C1 enum that is not defined, which would not then compile properly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions