Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support delegates with nullable return values not generated correctly #17109

Closed
mattjohnsonpint opened this issue Dec 21, 2022 · 3 comments · Fixed by #21094
Closed

Support delegates with nullable return values not generated correctly #17109

mattjohnsonpint opened this issue Dec 21, 2022 · 3 comments · Fixed by #21094
Labels
generator Issues affecting the generator good first issue This is a good first issue for someone to start working with our code
Milestone

Comments

@mattjohnsonpint
Copy link

Steps to Reproduce

  1. Create an iOS binding project
dotnet new iosbinding -n MyBindingProject
  1. Add the following to the API definitions:
using Foundation;

namespace MyBindingProject
{
    [return: NullAllowed]
    delegate NSObject MyCallback ([NullAllowed] NSObject obj);

    [BaseType (typeof (NSObject))]
    interface Widget
    {
        [Export ("foo")]
        [NullAllowed]
        MyCallback Foo { get; set; }
    }
}
  1. Compile
  2. Examine the generated SupportDelegates.g.cs file (in obj/Debug/net7.0-ios/iOS)

Expected Behavior

The delegate should have been generated with a nullable return type.

public delegate NSObject? MyCallback (NSObject? obj);

Actual Behavior

The delegate was generated with a non-nullable return type.

public delegate NSObject MyCallback (NSObject? obj);

Environment

Version information
Visual Studio Enterprise 2022 for Mac Preview
Version 17.5 Preview (17.5 build 437)
Installation UUID: 7fccecb1-31c0-40dd-afc6-4ad5fcaafe9b

Runtime
.NET 7.0.0 (64-bit)
Architecture: Arm64

Roslyn (Language Service)
4.4.0-3.22461.4+8ab250290a4010c11a21521f78dbc87dbb7aac81

NuGet
Version: 6.3.1.1

.NET SDK (Arm64)
SDK: /usr/local/share/dotnet/sdk/7.0.101/Sdks
SDK Versions:
	7.0.101
	7.0.100
	6.0.404
	6.0.403
	6.0.402
MSBuild SDKs: /Applications/Visual Studio (Preview).app/Contents/MonoBundle/MSBuild/Current/bin/Sdks

.NET SDK (x64)
SDK Versions:
	6.0.404
	6.0.403
	3.1.426
	3.1.425

.NET Runtime (Arm64)
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
	7.0.1
	7.0.0
	6.0.12
	6.0.11
	6.0.10

.NET Runtime (x64)
Runtime: /usr/local/share/dotnet/x64/dotnet
Runtime Versions:
	6.0.12
	6.0.11
	3.1.32
	3.1.31
	3.1.30

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

Updater
Version: 11

Apple Developer Tools
Xcode 14.2 (21534)
Build 14C18

Xamarin.Mac
Version: 8.12.0.2 (Visual Studio Enterprise)
Hash: 87f98a75e
Branch: d17-3
Build date: 2022-07-25 20:18:54-0400

Xamarin.iOS
Version: 16.0.0.72 (Visual Studio Enterprise)
Hash: 6756a1146
Branch: release/6.0.4xx-xcode14
Build date: 2022-09-21 08:51:06-0400

Xamarin Designer
Version: 17.5.1.13
Hash: 14bdde937f
Branch: remotes/origin/d17-5
Build date: 2022-11-02 21:36:49 UTC

Xamarin.Android
Version: 13.1.0.1 (Visual Studio Enterprise)
Commit: xamarin-android/d17-4/13ba222
Android SDK: /Users/matt/Library/Android/sdk
	Supported Android versions:
		12.1 (API level 32)
		12.0 (API level 31)
		8.1  (API level 27)
		11.0 (API level 30)
		10.0 (API level 29)
		9.0  (API level 28)
		13.0 (API level 33)

SDK Command-line Tools Version: 7.0
SDK Platform Tools Version: 33.0.3
SDK Build Tools Version: 33.0.0 rc4

Build Information: 
Mono: a96bde9
Java.Interop: xamarin/java.interop/d17-4@fcc33ce2
SQLite: xamarin/sqlite/3.39.3@23e1ae7
Xamarin.Android Tools: xamarin/xamarin-android-tools/main@0be567a

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.5.0.8
Hash: 6f27afd
Branch: remotes/origin/HEAD
Build date: 2022-11-02 21:36:54 UTC

Android Device Manager
Version: 0.0.0.1217
Hash: 6175224
Branch: main
Build date: 2022-11-02 21:36:54 UTC

Build Information
Release ID: 1705000437
Git revision: a5d0fb913c1ff781c80fe725a3e0511c34e26a08
Build date: 2022-11-02 21:34:22+00
Build branch: release-17.5
Build lane: release-17.5

Operating System
Mac OS X 12.6.1
Darwin 21.6.0 Darwin Kernel Version 21.6.0
    Thu Sep 29 20:13:56 PDT 2022
    root:xnu-8020.240.7~1/RELEASE_ARM64_T6000 arm64

Build Logs

msbuild.binlog.zip

Example Project (If Possible)

MyBindingProject.zip

@mattjohnsonpint
Copy link
Author

Additionally, the associated generated trampoline will also need to be fixed to allow a nullable return type.

@rolfbjarne rolfbjarne added good first issue This is a good first issue for someone to start working with our code generator Issues affecting the generator labels Jan 19, 2023
@rolfbjarne rolfbjarne added this to the Future milestone Jan 19, 2023
@bruno-garcia
Copy link
Contributor

Any plans to adjust this?
Maintaining bindings is the biggest pain point of the Sentry SDK to date

@rolfbjarne
Copy link
Member

rolfbjarne commented Aug 22, 2024

Any updates on this one? (going through our bindings script and checking links for updates). Updating bindings is extremely difficult

I've just implemented a fix for this. It might take a little while until it's released though (at the very latest it'll be with .NET 9 later in the fall).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
generator Issues affecting the generator good first issue This is a good first issue for someone to start working with our code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants