diff --git a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs index a2230d19..a76aa0bb 100644 --- a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs +++ b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs @@ -1216,8 +1216,15 @@ namespace CppSharp.Generators.CSharp private string GetPropertyName(Property prop) { - return prop.Parameters.Count == 0 ? prop.Name - : string.Format("this[{0}]", FormatMethodParameters(prop.Parameters)); + var isIndexer = prop.Parameters.Count != 0; + var @params = prop.Parameters.Select(param => { + var p = new Parameter(param); + if (isIndexer) + p.Usage = ParameterUsage.In; + return p; + }); + return !isIndexer ? prop.Name + : string.Format("this[{0}]", FormatMethodParameters(@params)); } private void GenerateVariable(Class @class, Type type, Variable variable) diff --git a/tests/Common/Common.h b/tests/Common/Common.h index 9452a922..a68a718b 100644 --- a/tests/Common/Common.h +++ b/tests/Common/Common.h @@ -556,6 +556,9 @@ public: foo_t operator[](TestProperties b); Bar& operator[](unsigned long i); Bar& operator[](const TypeMappedIndex& key); + // Test that we do not generate 'ref int' parameters as C# does not allow it + int operator[](CS_OUT char key); + private: foo_t p; TestProperties f; @@ -578,6 +581,11 @@ Bar& TestIndexedProperties::operator[](const TypeMappedIndex& key) { return bar; } +int TestIndexedProperties::operator[](CS_OUT char key) +{ + return key; +} + struct DLL_API TestIndexedPropertiesInValueType {