[ast] Improve ManagedQualifiedName to deal correctly with synthetic fields acessors.

This commit is contained in:
Joao Matos 2017-11-23 16:58:14 +00:00
Родитель 4f05650d00
Коммит 22ffe670a2
1 изменённых файлов: 18 добавлений и 1 удалений

Просмотреть файл

@ -13,8 +13,25 @@ namespace Embeddinator.Generators
{
public static string ManagedQualifiedName(this Declaration decl)
{
string managedName;
var field = decl.AssociatedDeclaration as Field;
if (decl is Method && field != null)
{
managedName = ASTGenerator.ManagedNames[field];
var property = field.AssociatedDeclaration as Property;
var isGetter = property.GetMethod == decl;
var suffix = isGetter ? "get" : "set";
managedName = $"{managedName}:{suffix}";
}
else
{
managedName = ASTGenerator.ManagedNames[decl];
}
// Replace + with / since that's what mono_class_from_name expects for nested types.
return ASTGenerator.ManagedNames[decl].Replace("+", "/");
return managedName.Replace("+", "/");
}
}