Browse Source

Ensure enumerations lack conflicts when renamed

Fixes https://github.com/mono/CppSharp/issues/965.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
const-wchar_t
Dimitar Dobrev 5 years ago
parent
commit
dcd11e9433
  1. 7
      src/Generator/Passes/RenamePass.cs
  2. 16
      tests/Common/Common.Tests.cs
  3. 4
      tests/Common/Common.h

7
src/Generator/Passes/RenamePass.cs

@ -215,9 +215,14 @@ namespace CppSharp.Passes @@ -215,9 +215,14 @@ namespace CppSharp.Passes
var property = decl as Property;
if (property != null && property.Field != null)
return ((Class) decl.Namespace).Properties.FirstOrDefault(
return ((Class) decl.Namespace).Properties.Find(
p => p != decl && p.Name == newName) != null;
var enumItem = decl as Enumeration.Item;
if (enumItem != null)
return ((Enumeration) enumItem.Namespace).Items.Any(
i => i != decl && i.Name == newName);
return false;
}

16
tests/Common/Common.Tests.cs

@ -51,14 +51,14 @@ public class CommonTests : GeneratorTestFixture @@ -51,14 +51,14 @@ public class CommonTests : GeneratorTestFixture
{
hasPropertyNamedAsParent.hasPropertyNamedAsParent.GetHashCode();
}
EnumWithUnderscores e = EnumWithUnderscores.lOWER_BEFORE_CAPITAL;
e = EnumWithUnderscores.UnderscoreAtEnd;
e = EnumWithUnderscores.CAPITALS_More;
e = EnumWithUnderscores.UsesDigits1_0;
e.GetHashCode();
ItemsDifferByCase itemsDifferByCase = ItemsDifferByCase.Case_a;
itemsDifferByCase = ItemsDifferByCase.CaseA;
itemsDifferByCase.GetHashCode();
EnumWithUnderscores.lOWER_BEFORE_CAPITAL.GetHashCode();
EnumWithUnderscores.UnderscoreAtEnd.GetHashCode();
EnumWithUnderscores.CAPITALS_More.GetHashCode();
EnumWithUnderscores.UsesDigits1_0.GetHashCode();
ItemsDifferByCase.Case_a.GetHashCode();
ItemsDifferByCase.CaseA.GetHashCode();
Enum.NAME_A.GetHashCode();
Enum.NAME__A.GetHashCode();
new AmbiguousParamNames(0, 0).Dispose();
Common.SMallFollowedByCapital();
Common.IntegerOverload(0);

4
tests/Common/Common.h

@ -191,7 +191,9 @@ enum Enum @@ -191,7 +191,9 @@ enum Enum
A = 0, B = 2, C = 5,
//D = 0x80000000,
E = 0x1,
F = -9
F = -9,
NAME_A = 10,
NAME__A = 20
};
typedef char TypedefChar;

Loading…
Cancel
Save