Skip to content

Commit

Permalink
Indexer Support (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
ds5678 authored Dec 31, 2023
1 parent 9581010 commit 052a238
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Cpp2IL.Core/Utils/AsmResolver/AsmResolverAssemblyPopulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,24 @@ private static void CopyPropertiesInType(ReferenceImporter importer, TypeAnalysi
if (managedSetter != null)
managedProperty.Semantics.Add(new(managedSetter, MethodSemanticsAttributes.Setter));

//Indexer parameters
if (managedGetter != null && managedGetter.Parameters.Count > 0)
{
foreach (var parameter in managedGetter.Parameters)
{
propertySignature.ParameterTypes.Add(parameter.ParameterType);
}
}
else if (managedSetter != null && managedSetter.Parameters.Count > 1)
{
//value parameter is always last
for (var i = 0; i < managedSetter.Parameters.Count - 1; i++)
{
var parameter = managedSetter.Parameters[i];
propertySignature.ParameterTypes.Add(parameter.ParameterType);
}
}

propertyCtx.PutExtraData("AsmResolverProperty", managedProperty);

ilTypeDefinition.Properties.Add(managedProperty);
Expand Down

0 comments on commit 052a238

Please sign in to comment.