dotnet / dotnet/macios

Simpler bindings for [StrongDictionary]

Open
#6,785 2 comments 4 reactions 0 assignees View on GitHub
enhancement iOS macOS request-for-comments
Dominant language
C#
Stars
2.9k
Forks
576
Avg merge
2d 12h
Merged PRs (30d)
123

Description

We can simplify them by re-use the smart enums pattern, inlining the `[Field]` into the dictionary. E.g.

Today
```csharp
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
[Internal]
[Static]
interface MLFeatureValueImageOptionKeys {

[Field ("MLFeatureValueImageOptionCropRect")]
NSString CropRectKey { get; }

[Field ("MLFeatureValueImageOptionCropAndScale")]
NSString CropAndScaleKey { get; }
}

[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
[StrongDictionary ("MLFeatureValueImageOptionKeys")]
interface MLFeatureValueImageOption {
CGRect CropRect { get; set; }
VNImageCropAndScaleOption CropAndScale { get; set; }
}
```

Future
```csharp
[Watch (6,0), TV (13,0), Mac (10,15), iOS (13,0)]
[StrongDictionary]
interface MLFeatureValueImageOption {
[Field ("MLFeatureValueImageOptionCropRect")]
CGRect CropRect { get; set; }
[Field ("MLFeatureValueImageOptionCropAndScale")]
VNImageCropAndScaleOption CropAndScale { get; set; }
}
```

Pros:
* Easier to review code (no scrolling to compare)
* Availability attributes could not mismatch (intro only checks `[Field]`)

Cons:
* generator change :)

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.