dotnet / dotnet/macios

Doing a block delegate breaks the generator

Open
#18,633 0 comments 0 reactions 0 assignees View on GitHub
binding-projects bug
Dominant language
C#
Stars
2.9k
Forks
576
Avg merge
2d 13h
Merged PRs (30d)
96

Description

### Steps to Reproduce

1. Open a binding project
2. Add the following code

```csharp
using Foundation;

namespace NativeLibrary {

delegate Widget2[] MeRompo();

[BaseType (typeof (NSObject))]
interface Widget
{
[Export("center")]
MeRompo Center { get; set; }
}

[BaseType(typeof(NSObject))]
interface Widget2
{

}
}
```

3. Breaks

### Expected Behavior

it compiles

### Actual Behavior

```
ManuelEscapo/obj/Debug/iOS/ObjCRuntime/Trampolines.g.cs(100,39,100,46): error CS0246: The type or namespace name 'Widget2' could not be found (are you missing a using directive or an assembly reference?)
ManuelEscapo/obj/Debug/iOS/ObjCRuntime/Trampolines.g.cs(101,12,101,15): error CS0029: Cannot implicitly convert type 'Widget2?[]' to 'NativeLibrary.Widget2[]'
```

### Generated code

```csharp
[BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
unsafe global::NativeLibrary.Widget2[] Invoke ()
{
var ret = CFArray.ArrayFromHandle(invoker (BlockPointer))!;
return ret!;
}
```

Looks like we are missing doing `global::NativeLibrary.` for `Widget2` and the nullability issue.

### Environment

Version information

```
Visual Studio Community 2022 for Mac
Version 17.6.2 (build 405)
Installation UUID: 08855383-8aba-4ca1-8603-1a1eb0aae505

Runtime
.NET 7.0.3 (64-bit)
Architecture: X64
Microsoft.macOS.Sdk 13.1.1007; git-rev-head:8afca776a0a96613dfb7200e0917bb57f9ed5583; git-branch:release/7.0.1xx-xcode14.2

Roslyn (Language Service)
4.6.0-3.23180.6+99e956e42697a6dd886d1e12478ea2b27cceacfa

NuGet
Version: 6.4.0.117

.NET SDK (x64)
SDK: /usr/local/share/dotnet/sdk/7.0.306/Sdks
SDK Versions:
7.0.306
7.0.304
7.0.101
6.0.412
6.0.410
6.0.404
6.0.400
6.0.302
5.0.408
5.0.402
5.0.400
5.0.201
5.0.200
5.0.101
5.0.100-preview.6.20265.2
3.1.426
3.1.422
3.1.421
3.1.414
3.1.412
3.1.407
3.1.401
3.1.302
3.1.100
MSBuild SDKs: /Applications/Visual Studio.app/Contents/MonoBundle/MSBuild/Current/bin/Sdks

.NET Runtime (x64)
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
7.0.9
7.0.7
7.0.1
6.0.20
6.0.18
6.0.12
6.0.8
6.0.7
5.0.17
5.0.11
5.0.9
5.0.4
5.0.3
5.0.1
5.0.0-preview.6.20264.1
3.1.32
3.1.28
3.1.27
3.1.20
3.1.18
3.1.13
3.1.7
3.1.6
3.1.0
2.1.23
2.1.21
2.1.20

Xamarin.Profiler
Version: 1.8.0.49
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Updater
Version: 11

Apple Developer Tools
Xcode: 14.3.1 21815
Build: 14E300c

Xamarin.Mac
Version: 9.3.0.6 Visual Studio Community
Hash: 97731c92c
Branch: xcode14.3
Build date: 2023-04-11 22:38:35-0400

Xamarin.iOS
Version: 16.4.0.6 Visual Studio Community
Hash: 97731c92c
Branch: xcode14.3
Build date: 2023-04-11 22:38:36-0400

Xamarin Designer
Version: 17.6.3.9
Hash: 2648399ae8
Branch: remotes/origin/d17-6
Build date: 2023-07-26 17:08:56 UTC

Xamarin.Android
Version: 13.2.0.6 (Visual Studio Community)
Commit: xamarin-android/d17-5/a200af1
Android SDK: /Users/alex/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
12.0 (API level 31)
10.0 (API level 29)
9.0 (API level 28)

SDK Command-line Tools Version: 5.0
SDK Platform Tools Version: 31.0.3
SDK Build Tools Version: 30.0.3

Build Information:
Mono: 6dd9def
Java.Interop: xamarin/java.interop/d17-5@149d70fe
SQLite: xamarin/sqlite/3.40.1@68c69d8
Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-5@9f02d77

Microsoft Build of OpenJDK
Java SDK: /Library/Java/JavaVirtualMachines/microsoft-11.jdk
11.0.16.1
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Eclipse Temurin JDK
Java SDK: /Library/Java/JavaVirtualMachines/temurin-8.jdk
1.8.0.302
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Android SDK Manager
Version: 17.6.0.50
Hash: a715dca
Branch: HEAD
Build date: 2023-07-26 17:09:02 UTC

Android Device Manager
Version: 0.0.0.1309
Hash: 06e3e77
Branch: HEAD
Build date: 2023-07-26 17:09:02 UTC

Build Information
Release ID: 1706020405
Git revision: beaff930b1a0035595265bd63d6ef6d670e93e9e
Build date: 2023-07-26 17:07:10+00
Build branch: release-17.6
Build lane: release-17.6

Operating System
Mac OS X 13.4.1
Darwin 22.5.0 Darwin Kernel Version 22.5.0
Thu Jun 8 22:22:22 PDT 2023
root:xnu-8796.121.3~7/RELEASE_X86_64 x86_64

```

### Build Logs

### Example Project (If Possible)

[ManuelEscapo.zip](https://github.com/xamarin/xamarin-macios/files/12253924/ManuelEscapo.zip)

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.