-
Notifications
You must be signed in to change notification settings - Fork 519
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
Nullreference exception when build Binding project in .net 7 #18025
Comments
Please attach the binding project that causes this error (it's likely you did something unexpected, and it's unlikely we would do the same thing, which means that having the actual binding project you used would really speed up tracking this down). |
Hi @jmmortega. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
@rolfbjarne all yours! Thank you for your quick answer |
Thanks for the test project, I was able to reproduce the issue, and a fix will be coming in a future release. The trigger is that you don't have a namespace in your ApiDefinition.cs: if you add a namespace, then you won't hit the bug. Additionally, you need to change the type for one of the fields for the binding to be correct. This means the diff would be: diff --git a/BrazeBinding.ios/ApiDefinitions.cs b/BrazeBinding.ios/ApiDefinitions.cs
index 960aeb0..a922138 100644
--- a/BrazeBinding.ios/ApiDefinitions.cs
+++ b/BrazeBinding.ios/ApiDefinitions.cs
@@ -7,6 +7,8 @@ using UIKit;
using UserNotifications;
using WebKit;
+namespace XYZ {
+
[Static]
////[Verify (ConstantsInterfaceAssociation)]
partial interface Constants
@@ -3050,5 +3052,7 @@ partial interface Constants
// extern const unsigned char[] Appboy_iOS_SDKVersionString;
[Field ("Appboy_iOS_SDKVersionString", "__Internal")]
- byte[] Appboy_iOS_SDKVersionString { get; }
+ IntPtr Appboy_iOS_SDKVersionString { get; }
+}
+
}
and this should make your project compile. |
Steps to Reproduce
I'm here because the build log advice me to do it
Trying to create a Binding project with this guide https://learn.microsoft.com/en-us/events/dotnetconf-focus-on-maui/binding-native-libraries-for-dotnet-maui
For this libraries: https://github.com/braze-inc/braze-xamarin-sdk/tree/master/appboy-component/src/ios-unified
Expected Behavior
Binding library output
Actual Behavior
Receive a null reference from building
Environment
Visual Studio Community 2022 for Mac
Version 17.5.1 (build 23)
Installation UUID: 3021d4e8-9600-4b02-afbb-663ca8bc4415
Runtime
.NET 7.0.1 (64-bit)
Architecture: Arm64
Microsoft.macOS.Sdk 12.3.2372; git-rev-head:754abbf6a3563f6267e5717ae832b4ac25b1f2fb; git-branch:release/7.0.1xx-xcode13.3
Roslyn (Language Service)
4.5.0-3.23056.2+97881342e427ff5cdcba8f12b12ff8e6f3564431
NuGet
Version: 6.4.0.117
.NET SDK (Arm64)
SDK: /usr/local/share/dotnet/sdk/7.0.201/Sdks
SDK Versions:
7.0.201
7.0.102
7.0.101
7.0.100
6.0.406
6.0.405
6.0.404
6.0.403
6.0.100
MSBuild SDKs: /Applications/Visual Studio.app/Contents/MonoBundle/MSBuild/Current/bin/Sdks
.NET SDK (x64)
SDK Version: 3.1.426
.NET Runtime (Arm64)
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
7.0.3
7.0.2
7.0.1
7.0.0
6.0.14
6.0.13
6.0.12
6.0.11
6.0.0
.NET Runtime (x64)
Runtime: /usr/local/share/dotnet/x64/dotnet
Runtime Versions:
7.0.3
3.1.32
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 21812
Build: 14E222b
Xamarin Designer
Version: 17.5.3.47
Hash: e8b5d371c3
Branch: remotes/origin/d17-5
Build date: 2023-03-02 06:10:08 UTC
Xamarin.Android
Version: 13.2.0.0 (Visual Studio Community)
Commit: xamarin-android/d17-5/797e2e1
Android SDK: /Users/jmmontero/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
12.1 (API level 32)
8.0 (API level 26)
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.1
Build Information:
Mono: 6dd9def
Java.Interop: xamarin/java.interop/main@149d70fe
SQLite: xamarin/sqlite@fdc1e34
Xamarin.Android Tools: xamarin/xamarin-android-tools/main@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.5.0.33
Hash: f0c0c52
Branch: remotes/origin/d17-5~2
Build date: 2023-03-02 06:10:13 UTC
Android Device Manager
Version: 0.0.0.1245
Hash: 7f8a990
Branch: 7f8a990
Build date: 2023-03-02 06:10:13 UTC
Xamarin.Mac
Version: 9.1.0.5 Visual Studio Community
Hash: 7738c90
Branch: xcode14.2
Build date: 2023-01-25 15:56:14-0500
Xamarin.iOS
Version: 16.2.0.5 Visual Studio Community
Hash: 7738c90
Branch: xcode14.2
Build date: 2023-01-25 15:56:15-0500
Build Information
Release ID: 1705010023
Git revision: 4ea4e8aba0157d7f608399614482546551c0ee08
Build date: 2023-03-02 06:08:04+00
Build branch: release-17.5
Build lane: release-17.5
Operating System
Mac OS X 13.1.0
Darwin 22.2.0 Darwin Kernel Version 22.2.0
Fri Nov 11 02:03:51 PST 2022
root:xnu-8792.61.2~4/RELEASE_ARM64_T6000 arm64
Build Logs
BTOUCH : warning BI1103: bgen: 'Appboy' does not live under a namespace; namespaces are a highly recommended .NET best practice
BTOUCH : error BI0000: Unexpected error - Please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new
System.NullReferenceException: Object reference not set to an instance of an object.
at Generator.IsInSupportedFramework(MemberInfo klass, PlatformName platform) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/generator.cs:line 3531
at Generator.AddUnlistedAvailability(MemberInfo containingClass, List`1 availability) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/generator.cs:line 3539
at Generator.GetPlatformAttributesToPrint(MemberInfo mi, Type type, MemberInfo inlinedType) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/generator.cs:line 3696
at Generator.PrintPlatformAttributes(MemberInfo mi, Type type, Boolean is_enum) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/generator.cs:line 3737
at Generator.PrintMethodAttributes(MemberInformation minfo) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/generator.cs:line 5835
at Generator.GenerateMethod(MemberInformation minfo) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/generator.cs:line 5936
at Generator.Generate(Type type) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/generator.cs:line 7303
at Generator.Go() in /Users/builder/azdo/_work/1/s/xamarin-macios/src/generator.cs:line 2629
at BindingTouch.Main3(String[] args) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/btouch.cs:line 575
at BindingTouch.Main2(String[] args) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/btouch.cs:line 207
at BindingTouch.Main(String[] args) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/btouch.cs:line 96
at System.Environment.get_StackTrace()
at ErrorHelper.ShowInternal(Exception e) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/error.cs:line 175
at ErrorHelper.Show(Exception e, Boolean rethrow_errors) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/error.cs:line 125
at BindingTouch.Main(String[] args) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/btouch.cs:line 96
Done building target "_GenerateBindings" in project "BrazeBinding.ios.csproj" -- FAILED.
The text was updated successfully, but these errors were encountered: