dotnet / dotnet/macios

IUIContentConfiguration.MakeContentView() result fails to cast to UIView

Open
#21,738 2 comments 0 reactions 0 assignees View on GitHub
api-bindings bug
Dominant language
C#
Stars
2.9k
Forks
576
Avg merge
2d 12h
Merged PRs (30d)
123

Description

### Apple platform

iOS

### Framework version

net8.0-*

### Affected platform version

.NET 8.0.100 18.0.8303

### Description

The return type of `IUIContentConfiguration.MakeContentView()` is simply `IUIContentView`. By contrast, in Swift it is `UIView & UIContentView` (and similarly in Objective-C), so we're missing the idea that the return type is not just an object that conforms to `UIContentView`, but it's specifically a `UIView`. Attempting to cast the result of `MakeContentView()` to `UIView` fails, which is also incorrect. This makes the composability aspect of content configurations unusable in C#: you can't take one configuration's view and embed it inside another.

### Steps to Reproduce

1. Attempt to cast the result of a `MakeContentView()` call to `UIView`.
2. The result is null, which is incorrect. The result is always a `UIView`.

### Did you find any workaround?

I haven't tried it yet, but I could make a subclass of `UIView` that implements `IUIContentView`, and return that from my custom content configurations. I think that would get around the casting issue for those cases, but it would not help for when I want to embed a system content configuration inside a custom one.

### Relevant log output

_No response_

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.