diff --git a/tests/generator-Tests/Unit-Tests/CodeGeneratorTests.cs b/tests/generator-Tests/Unit-Tests/CodeGeneratorTests.cs
index 8df7ff753..a743e20c6 100644
--- a/tests/generator-Tests/Unit-Tests/CodeGeneratorTests.cs
+++ b/tests/generator-Tests/Unit-Tests/CodeGeneratorTests.cs
@@ -967,5 +967,54 @@ public void WriteMethodWithInvalidParameterName ()
// Ensure we escape dollar signs
Assert.False (result.Contains ("$this"));
}
+
+ [Test]
+ public void WritePropertyExplicitInterfaceParameterName ()
+ {
+ // Fix a case where we were not overriding a property setter's parameter name ("p0")
+ // to "value", resulting in invalid C#. Like:
+ // public string MyProperty {
+ // set => my_property = p0;
+ // }
+ var gens = ParseApiDefinition (@"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ");
+
+ var @class = gens.OfType ().First (c => c.Name == "SingleDateSelector");
+
+ generator.Context.ContextTypes.Push (@class);
+ generator.WriteClass (@class, string.Empty, new GenerationInfo ("", "", "MyAssembly"));
+ generator.Context.ContextTypes.Pop ();
+
+ var result = writer.ToString ().NormalizeLineEndings ();
+ Assert.False (result.Contains ("p0"));
+ }
}
}
diff --git a/tools/generator/Java.Interop.Tools.Generator.CodeGeneration/CodeGenerator.cs b/tools/generator/Java.Interop.Tools.Generator.CodeGeneration/CodeGenerator.cs
index a0a1d77ea..b199d0e45 100644
--- a/tools/generator/Java.Interop.Tools.Generator.CodeGeneration/CodeGenerator.cs
+++ b/tools/generator/Java.Interop.Tools.Generator.CodeGeneration/CodeGenerator.cs
@@ -1605,7 +1605,13 @@ public void WritePropertyExplicitInterface (Property property, string indent, Ge
if (property.Setter.GenericArguments != null && property.Setter.GenericArguments.Any ())
writer.WriteLine ("{0}{1}", indent, property.Setter.GenericArguments.ToGeneratedAttributeString ());
writer.WriteLine ("{0}\t[Register (\"{1}\", \"{2}\", \"{3}:{4}\"{5})] set {{", indent, property.Setter.JavaName, property.Setter.JniSignature, property.Setter.ConnectorName, property.Setter.GetAdapterName (opt, adapter), property.Setter.AdditionalAttributeString ());
+
+ // Temporarily rename the parameter to "value"
+ var pname = property.Setter.Parameters [0].Name;
+ property.Setter.Parameters [0].Name = "value";
writer.WriteLine ("{0}\t\t{1} = {2};", indent, property.Name, property.Setter.Parameters.GetGenericCall (opt, mappings));
+ property.Setter.Parameters [0].Name = pname;
+
writer.WriteLine ("{0}\t}}", indent);
}
writer.WriteLine ("{0}}}", indent);