diff --git a/src/Core/Parser/ASTConverter.cs b/src/Core/Parser/ASTConverter.cs index 8803e982..2dbb728d 100644 --- a/src/Core/Parser/ASTConverter.cs +++ b/src/Core/Parser/ASTConverter.cs @@ -1023,7 +1023,7 @@ namespace CppSharp { var item = decl.getItems(i); var _item = Visit(item) as AST.Enumeration.Item; - _enum.Items.Add(_item); + _enum.AddItem(_item); } return _enum; diff --git a/src/Generator.Tests/AST/TestAST.cs b/src/Generator.Tests/AST/TestAST.cs index cf4b2d24..3292e1df 100644 --- a/src/Generator.Tests/AST/TestAST.cs +++ b/src/Generator.Tests/AST/TestAST.cs @@ -160,5 +160,13 @@ namespace CppSharp.Generator.Tests.AST .First(); Assert.IsTrue(plusOperator.Visit(testVisitor)); } + + [Test] + public void TestASTEnumItemByName() + { + var @enum = AstContext.FindEnum("TestASTEnumItemByName").Single(); + Assert.NotNull(@enum); + Assert.IsTrue(@enum.ItemsByName.ContainsKey("TestItemByName")); + } } } diff --git a/tests/Native/AST.h b/tests/Native/AST.h index 6db63b44..0a7091de 100644 --- a/tests/Native/AST.h +++ b/tests/Native/AST.h @@ -19,4 +19,7 @@ namespace Math Complex Complex::operator+(Complex &other) { return Complex(re + other.re, im + other.im); } -} \ No newline at end of file +} + +// Tests Enum.ItemByName +enum TestASTEnumItemByName { TestItemByName }; \ No newline at end of file