Permalink
Browse files

Fixed the generated C# when a field is named after a property to be g…

…enerated.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
  • Loading branch information...
ddobrev committed Jun 13, 2017
1 parent b1253d1 commit cfc6da4600d4c6a2fea5255302cca97441055a33
Showing with 9 additions and 3 deletions.
  1. +6 −3 src/Generator/Passes/GetterSetterToPropertyPass.cs
  2. +3 −0 tests/Common/Common.h
@@ -77,8 +77,7 @@ private void GenerateProperties(IEnumerable<Method> settersToUse, bool readOnly)
char.ToUpperInvariant(@event.Name[0]), @event.Name.Substring(1));
Diagnostics.Debug("Event {0}::{1} renamed to {2}", @event.Namespace.Name, oldName, @event.Name);
}
getter.Name = name;
GenerateProperty(getter.Namespace, getter, readOnly ? null : setter);
GenerateProperty(name, getter.Namespace, getter, readOnly ? null : setter);
goto next;
}
}
@@ -132,9 +131,13 @@ private static Type GetUnderlyingType(QualifiedType type)
}
private static void GenerateProperty(DeclarationContext context, Method getter, Method setter = null)
{
GenerateProperty(GetPropertyName(getter.Name), context, getter, setter);
}
private static void GenerateProperty(string name, DeclarationContext context, Method getter, Method setter)
{
var type = (Class) context;
var name = GetPropertyName(getter.Name);
if (type.Properties.Any(p => p.Name == name &&
p.ExplicitInterfaceImpl == getter.ExplicitInterfaceImpl))
return;
@@ -531,11 +531,14 @@ DLL_API int Function()
// Tests properties
struct DLL_API TestProperties
{
public:
TestProperties();
int Field;
int getFieldValue();
void setFieldValue(int Value);
private:
int FieldValue;
};
TestProperties::TestProperties() : Field(0) {}

0 comments on commit cfc6da4

Please sign in to comment.