From daef4342c144d61ce532de6f526affb23f9572e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joa=CC=83o=20Matos?= Date: Sun, 5 Apr 2020 18:05:51 +0100 Subject: [PATCH] Fix generation of field property setters in C++ generator. --- src/Generator/Generators/C/CppSources.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Generator/Generators/C/CppSources.cs b/src/Generator/Generators/C/CppSources.cs index f98a55d1..8cc45a6a 100644 --- a/src/Generator/Generators/C/CppSources.cs +++ b/src/Generator/Generators/C/CppSources.cs @@ -226,10 +226,10 @@ namespace CppSharp.Generators.Cpp if (property.HasGetter) GeneratePropertyGetter(property.GetMethod); - if (property.HasSetter) + if (property.HasSetter && property.SetMethod != null) GeneratePropertySetter(property.SetMethod); - PopBlock(); + PopBlock(NewLineKind.Never); return true; } @@ -447,11 +447,18 @@ namespace CppSharp.Generators.Cpp var method = function as Method; var @class = function.Namespace as Class; - var field = (method?.AssociatedDeclaration as Property)?.Field; + var property = method?.AssociatedDeclaration as Property; + var field = property?.Field; if (field != null) { Write($"((::{@class.QualifiedOriginalName}*){Helpers.InstanceIdentifier})->"); - WriteLine ($"{field.OriginalName};"); + Write($"{field.OriginalName}"); + + var isGetter = property.GetMethod == method; + if (isGetter) + WriteLine(";"); + else + WriteLine($" = {@params[0].Name};"); } else {