dotnet / dotnet/macios

[RFC][Generator] Add support for indexers

Open
#9,506 0 comments 0 reactions 0 assignees View on GitHub
generator request-for-comments
Dominant language
C#
Stars
2.9k
Forks
576
Avg merge
2d 12h
Merged PRs (30d)
123

Description

Apple usually provides classes that are collection of objects that provide a GetObject (obj) and SetObject(obj, index) methods. On C# we will like to expose these methods AND and indexer so that the users can do obj[i].

The binding could use a very similar syntax as that one used for properties with a Wrap:

```csharp
MTLBlitPassSampleBufferAttachmentDescriptor this[nuint i] {
[Wrap ("GetObject (i)")]
get;
[Wrap ("SetObject (value, i);")]
set;
}
```

The generator can later write:
```csharp
MTLBlitPassSampleBufferAttachmentDescriptor this[nuint i] {
get => GetObject (i);
set => SetObject (value, i);
}
```

This will safe us a good amount of manual code for this classes.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.